We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hi guys.
finding my way with p5, help and resources are excellent however i've come to a point where i need some extra guidance.
what i'm trying to do is create a circle on the canvas that is a clickable link that i can dynamically update the colours of the two states. the circle is defined in the class ' one'.
i have this p5 code :
sendLink = select('.one'); sendLink.mouseMoved(updateCss); sendLink.mouseOut(updateCssBack);
function updateCss(){
sendLink.style('background-color','rgba(0,0,0,0.5)');
}
function updateCssBack(){
sendLink.style('background-color', 'rgba(23,120,45,0.5)');
}
this works great.
elsewhere in my code i have three variables controlling r,g,b values of some triangles. what i'd really like to do is parse the variable values into one of the functions so when the mouse moves over and out the colour of the dom element is the same as the triangle.
simply replacing the numeric values with r , g, and b sees no change in colour. i don't get any error messages even.
i've tried using ' + r ' for example and that doesn't work.
am i trying to do something that i shouldn't be trying to do ?
how can i get the variables into the rgba section of code and for it to work ?
Answers
https://Forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text
http://JSBeautifier.org
You haven't posted your attempt to use style() w/ those r, g, b variables. :-@
Regardless, according to p5.Element::style()'s reference, we can pass a p5.Color as its 2nd argument:
https://p5js.org/reference/#/p5.Element/style
So you can do something like this:
sendLink.style('background-color', color(r, g, b));
https://p5js.org/reference/#/p5/color