experiment: blinking cursor

I've tried to keep the time period of the blinking similar to my
terminal.

Honestly I'm no longer sure if any of my experiments are showing a
statistically significant result. Let's see how it feels over a period
of time.
This commit is contained in:
Kartik K. Agaram 2022-06-09 13:45:52 -07:00
parent 25190676ea
commit fe170fc579
2 changed files with 10 additions and 3 deletions

View File

@ -82,6 +82,9 @@ Search_backup = nil -- stuff to restore when cancelling search
-- resize
Last_resize_time = nil
-- blinking cursor
Cursor_time = 0
end -- App.initialize_globals
function App.initialize(arg)
@ -249,6 +252,7 @@ function App.draw()
end
function App.update(dt)
Cursor_time = Cursor_time + dt
-- some hysteresis while resizing
if Last_resize_time then
if love.timer.getTime() - Last_resize_time < 0.1 then

View File

@ -85,9 +85,12 @@ end
-- draw with small line_width of 100
function Text.draw_cursor(x, y)
love.graphics.setColor(1,0,0, 0.8)
love.graphics.rectangle('fill', x,y, 3,Line_height)
love.graphics.setColor(0,0,0)
-- blink every 0.5s
if math.floor(Cursor_time*2)%2 == 0 then
love.graphics.setColor(1,0,0)
love.graphics.rectangle('fill', x,y, 3,Line_height)
love.graphics.setColor(0,0,0)
end
Cursor_x = x
Cursor_y = y+Line_height
end