I'm currently working on a MS paint clone that I call Helium and I'm at the part where I need some colours instead of the current grey colour I'm using.
The idea is this:
1. I have ten colours, which I can pick and choose from 0-9 on the numeric pad on the keyboard and I want to assign each colour a "numeric value" .
2. And to be able to see what kind of colour you're currently using I have a ui (the ui is a work in progress) and if you see the attached image file you can see a white blank square, in that square I want the colour you picked between 0-9 to show up inside (or be drawn behind the ui within said square).
I will also attach the code for you to view.
I thank you for your co-operation!
Code: Select all
function love.load()
squares = {}
xPos = 0
yPos = 0
--Draws canvas
canvas = love.graphics.newCanvas(800, 480)
end
function love.update( dt )
local x, y = love.mouse.getPosition()
local newPosition = {}
if love.mouse.isDown( "l" ) then
newPosition.x = x
newPosition.y = y
table.insert( squares, newPosition )
end
local newPosition = {}
if love.mouse.isDown("l" ) then
newPosition.x = x
newPosition.y = y
end
end
-- Draws All The Graphics --
function love.draw()
-- Prints X And Y Position On The Upper Left Screen
local x, y = love.mouse.getPosition()
love.graphics.print("X:" ..x, 10, 10)
love.graphics.print("Y:" ..y, 10, 40)
-- Set The Background To White
love.graphics.setBackgroundColor(255, 255, 255)
-- UI: Banner Grey
love.graphics.setColor(195 , 195, 195)
love.graphics.rectangle("fill", 0, 480, 800, 120)
-- Draws A 16x16 Square That Follows The Mouse
love.graphics.rectangle("line", x, y, 16, 16)
-- Draws A 16x16 Square "brush"
for key, square in ipairs( squares ) do
love.graphics.rectangle( "fill", square.x, square.y, 16, 16 )
end
end