Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Color Generator

edited December 2019 in Code Sharing Posts: 2

Simple app to create colors and make some random cool ones.

-- Random Color Picker

-- Initialize sliders used to pick colors. Set initial random rgb values.
function setup()
    parameter.number("Red", 0, 255, randomColorCode())
    parameter.number("Green", 0, 255, randomColorCode())
    parameter.number("Blue", 0, 255, randomColorCode())
    displayMode(FULLSCREEN)
end

function draw()
    -- color is redered to the background.
    background(Red, Green, Blue)

end

function touched(touch)
    -- if the screen is touched and it is a BEGAN touch randomize the color.
    if touch.state == BEGAN then
        Red = randomColorCode()
        Green = randomColorCode()
        Blue = randomColorCode()
    end
end

-- Helper function to return new random color code value.
function randomColorCode()
    return math.random(0, 255)
end
Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 8,505

    @heyitsgeo Welcome to the forum. It’s good to see new users posting code. Hope to see more from you. Anytime you post code, put ~~~ on a line before and after your code so it shows the correct way. I added them to your code above.

  • @dave1707 thanks for the update. I was struggling with getting the code to format the way I wanted to. I appreciate you going ahead and fixing it!

  • AnatolyAnatoly Mod
    Posts: 889

    I've also been coding on a colors API. Here it is. I hope you can make us of it.

Sign In or Register to comment.