Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript colour picker/changer

Options
  • 20-03-2013 9:14pm
    #1
    Moderators, Education Moderators, Technology & Internet Moderators Posts: 2,588 Mod ✭✭✭✭


    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 Posts: 11,977 ✭✭✭✭Giblet


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


  • Moderators, Education Moderators, Technology & Internet Moderators Posts: 2,588 Mod ✭✭✭✭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 Posts: 11,977 ✭✭✭✭Giblet


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

    Also, an onchange event could set a variable too.


  • Moderators, Education Moderators, Technology & Internet Moderators Posts: 2,588 Mod ✭✭✭✭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