I Imagine A Color Picker Has Been Done A Thousand Times
Posted: Thu Dec 21, 2023 3:46 pm
I just did one as part of my learning curve.
press "r" and ("down arrow" or "up arrow")
or
press "g" and ("down arrow" or "up arrow")
or
press "b" and ("down arrow" or "up arrow")
to adjust the color levels.
press "r" and ("down arrow" or "up arrow")
or
press "g" and ("down arrow" or "up arrow")
or
press "b" and ("down arrow" or "up arrow")
to adjust the color levels.
Code: Select all
function love.load()
love.window.setFullscreen(true, "desktop")
width, height = love.window.getDesktopDimensions(1)
red = 512
green = 512
blue = 512
end
function love.update(dt)
down = love.keyboard.isDown("escape")
if down == true then
love.event.quit()
end
down = love.keyboard.isDown("r")
if down == true then
down = love.keyboard.isDown("up")
if down == true then
red = red + 1
if red > 1020 then red = 1020 end
end
down = love.keyboard.isDown("down")
if down == true then
red = red - 1
if red < 0 then red = 0 end
end
end
down = love.keyboard.isDown("g")
if down == true then
down = love.keyboard.isDown("up")
if down == true then
green = green + 1
if green > 1020 then green = 1020 end
end
down = love.keyboard.isDown("down")
if down == true then
green = green - 1
if green < 0 then green = 0 end
end
end
down = love.keyboard.isDown("b")
if down == true then
down = love.keyboard.isDown("up")
if down == true then
blue = blue + 1
if blue > 1020 then blue = 1020 end
end
down = love.keyboard.isDown("down")
if down == true then
blue = blue - 1
if blue < 0 then blue = 0 end
end
end
end
function love.draw()
love.graphics.setColor(1, 0, 0)
love.graphics.print("Red", width/2-200, height/2-200, 0, 2, 2)
love.graphics.print(math.floor(red/4), width/2, height/2-200, 0, 2, 2)
love.graphics.setColor(0, 1, 0)
love.graphics.print("green", width/2-200, height/2-160, 0, 2, 2)
love.graphics.print(math.floor(green/4), width/2, height/2-160, 0, 2, 2)
love.graphics.setColor(0.24, 0.24, 1)
love.graphics.print("blue", width/2-200, height/2-120, 0, 2, 2)
love.graphics.print(math.floor(blue/4), width/2, height/2-120, 0, 2, 2)
love.graphics.setColor(red/1020, green/1020, blue/1020)
love.graphics.rectangle("fill", width/2-200, height/2-80, 400, 400)
end