Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Javascript colour picker/changer

  • 20-03-2013 09:14PM
    #1
    Registered Users, Registered Users 2 Posts: 2,559 ✭✭✭


    So I've got a <canvas> element that I need the user to be able to change the colour of on the fly using some sort of slider or anything else, just the user has to be able to select the colour, so I can't just have it change randomly onclick.

    Any ideas on the best way to approach this?

    Or put another way:

    Help me make this work http://codepen.io/Shane24/pen/cEGsb

    I have this red box, I need to be able to change the colour of the box on the fly. Any tips?


    Edit: Found something that I can probably rework, but any help/suggestions still appreciated


    Further edit: Got it working! http://codepen.io/Shane24/pen/dGcHs


Comments

  • Registered Users, Registered Users 2 Posts: 12,025 ✭✭✭✭Giblet


    Seeing as you are using canvas, this might get you some mileage.
    <input type="color"></input>
    


  • Registered Users, Registered Users 2 Posts: 2,559 ✭✭✭KonFusion


    Here's what I've got so far

    http://codepen.io/Shane24/pen/cEGsb

    So how the frick do I get those numbers in the input boxes (that you can change via the sliders) into a variable?


  • Registered Users, Registered Users 2 Posts: 12,025 ✭✭✭✭Giblet


    The slide event sets the textbox, but it can also set other things.

    Also, an onchange event could set a variable too.


  • Registered Users, Registered Users 2 Posts: 2,559 ✭✭✭KonFusion


    Got it working

    http://codepen.io/Shane24/pen/dGcHs

    I was executing code before the html was parsed, among other silly things.

    Now for some much needed sleepzzzzzzzzzzzzzz.......


Advertisement