We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I'm Irene and I'm new here, I made this code and I would like to make fill changing while time is passing, how could I do it? Thanks!
> void setup(){
> size(800, 570);
> }
>
> void draw(){
> strokeWeight(7);
> fill(235);
> rect(3,3,40,100);//fila1
> rect(43,3,310,30);
> fill(27,11,118);
> rect(43,33,310,70);
> fill(235);
> rect(353,3,360,30);
> rect(353,33,120,70);
> fill(27,11,118);
> rect(473,33,240,70);
> fill(235);
> rect(713,3,50,280);
> fill(246,196,21);
> rect(757,3,40,280);
> fill(0);
> rect(3,103,40,245); //fila2
> fill(235);
> rect(43,103,115,245);
> fill(0);
> rect(143,103,40,400);
> fill(235);
> rect(183,103,130,180);
> rect(313,103,40,180);
> fill(240,190,15);
> rect(353,103,120,180);
> fill(201,7,5);
> rect(473,103,180,180);
> rect(653,103,60,180);
> fill(240,190,15);
> rect(183,283,40,65); //fila3
> fill(201,7,5);
> rect(223,283,130,65);
> fill(27,11,118);
> rect(353,283,120,65);
> fill(235);
> rect(473,283,180,65);
> rect(653,283,60,65);
> fill(0);
> rect(713,283,84,65);
> fill(235);
> rect(3,349,40,154); //fila4
> fill(201,7,5);
> rect(43,349,100,154);
> fill(240,190,15);
> rect(183,349,40,219);
> fill(235);
> rect(223,349,210,124);
> rect(433,349,150,124);
> fill(27,11,118);
> rect(583,349,70,124);
> fill(240,190,15);
> rect(653,349,60,124);
> fill(235);
> rect(713,349,85,124);
> rect(3,505,180,62); //fila5
> fill(201,7,5);
> rect(223,475,120,92);
> fill(0);
> rect(343,475,240,92);
> fill(235);
> rect(583,475,213,92);
> }
>
Comments
I mean, I'd like to transform the colors red, blue and yellow to a clock: each second red becomes darkest, each minute blue becomes darkest and each hour yellow become darkest...how can I do?
@lizhubersen== please format your code with the 'C' button after having selected it... as for your question you only have to create a timer() method.
thanks @akenaton, I'm gonna try :)
mh, how can I do? it's a few weeks that I use processing and since yesterday I'm trying to transform my rects into a clock...but without results, can you please post here the right method? I tried a lot of them, but I think I put them in the wrong place.. @akenaton thanks a lot
I'd like to let rectangles change color instead of background...what do I have to change? Because if I put "fill" instead of "background" it's not working, I'd like to incorporate this code with mine...how can I do..? :/
Processing has built-in functions that get the time of day:
- second(): https://processing.org/reference/second_.html
- minute(): https://processing.org/reference/minute_.html
- hour(): https://processing.org/reference/hour_.html
Calling background() fills the entire screen with some color. For example, background(0) will always make the entire screen black
To change the interior color of a rect(), call fill() before calling that rect(). For example, to make a red rect() and then a green rect() somewhere else on a black background:
Below is an example of one way how to do what you were talking about the color and time. It doesn't need background() because the rect()s cover the entire screen:
@lizhubersen===
see below what i have found as solution. It works but in order to make things running faster you have to work in HSB mode, so you can modify only 1 parameter (B).
Thank you all, I was meaning just that! :) I also did, while waiting, another sketch, that is more or less what I wanted to. Still thanks! Irene