anonymous
  • anonymous
Can someone help me on this, hints, tips anything. But I am really confused how to get this done. Processing has functions that let you determine the time of day: second(), minute(), and hour(). You will use the minute and second functions to control a sketch with two items in it. Save the sketch with the name time. Use the minute() function to control the position of one item. Use the second() function to control the size of the other item. The position and size changes must be evident. The fill color for the “seconds” indicator must not change. For example, you might choose a triangle as the indicator for the minute, and move it vertically down the sketch as time progresses. You might choose an ellipse for the second indicator, and make it longer as the seconds progress. None of this requires the use of any conditionals (though if you do want to use conditionals for extra visual effect, feel free). Here are two further specifications which do require conditionals: Change the background color of the sketch depending upon which quarter-minute it is: 0-14, 15-29, 30-44, 45-59. Change the fill color of the minute indicator depending upon whether the minute is an even or odd number. Although you are using the time functions, your sketch does not have to look like a clock. I don’t care if nobody can tell what time it is by looking at your sketch. It can be as representational or as abstract as you like, so be creative! Here is an example; it is the clock as described above. Yours, of course, will look different. How do you find out if a number is odd or even? You use the % operator. This gives you the remainder after division. For example, 17 % 3 gives you 2, because 17 divided by 3 is 5 with a remainder of 2. Here’s the trick: if you divide a number by 2, you get a remainder of zero if the number is even, and a remainder of one if it’s odd. So this code will print the appropriate message: int n = 27; if (n % 2 == 0) { println("n is even"); } else { println("n is odd"); } This is what I have so far void setup() { size(400, 400); smooth(); } void draw() { background(255, 102, 104) triangle(200, 200, 180, 220, 220, 220); rect(20, 20, 60, 60); }
Computer Science
chestercat
  • chestercat
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
I am stuck on how to change the background every 15 seconds. Not sure how that is done?
anonymous
  • anonymous
Here is the link to what this might look like, it does not have to be exactly like this. http://evc-cit.info/cit020/clock_applet/index.html
anonymous
  • anonymous
Im guessing the solution is done in Java? If so it seems you'd need to create a new thread to control when the image is updated. One way of doing this is to extend the Thread class and then call the 'run()' method to compute the new image. In the run() method you'll need to create a loop and call the sleep() method at the end of the loop so that it'll wait for 15 seconds before updating again. For example: public void run() { while (1==1) { ...... ...... sleep(15000); } } Also, you might want to change the 'while(1==1)' to something that'll eventually exit. It's not really good practice to create infinite loops. Hope this helps.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Oh I am doing this in processing.
anonymous
  • anonymous
Ah ok, I'm afraid I don't know anything about Processing. But as a general solution you should be able to substitute the parameters for your shapes with the return value of the minute(), second() methods. So for example, where you have 'rect(20, 20, 60, 60);' you could write 'rect(minute(), 20, 60, 60);' so that if the current minute is '24' the compiler will read it as 'rect(24, 20, 60, 60);' I don't know how Processing handles the timing of the threads so I can't really help you with changing the background every 15 seconds. But maybe have a look at checking which quarter of the minute it is currently and change the background depending on what it is. For example: int quarter = second()/15; //if its the first 15 seconds of the minute it will be '0', the second quarter will be '1' the third quarter will be '2' and fourth quarter will be '3'. if(quarter == 0) { background(255, 102, 104); } else if (quarter == 1) { background(0,0,0); } else if... ..and so on. Hope this makes sense.
anonymous
  • anonymous
wait why did you put quarter because isn't it suppose to be minute. I am working with minute and seconds. The other thing was rectangle is set to minute and the triangle seconds.
anonymous
  • anonymous
I used quarter for this part of the solution: "Change the background color of the sketch depending upon which quarter-minute it is: 0-14, 15-29, 30-44, 45-59." since you were asking about how to change the background colour every 15 seconds. If you divide the current seconds by 15 you will get which quarter of the minute you are in. I'm assuming that Processor will constantly run the draw() method so long as the program is running so it will check every second and change the background only when the second is in the next quarter of the minute i.e every 15 seconds.
anonymous
  • anonymous
ok, thanks. I am going to try figuring this out.
anonymous
  • anonymous
No problem, good luck with the solution!
anonymous
  • anonymous
@Daire like you put so on does that go on until 15?
anonymous
  • anonymous
{ if (quarter == 0) { background(255, 102, 104); } else if (quarter == 1) { background(121, 12, 232); }else if (quarter == 2) { background(121, 149, 245); }else if (quarter == 3) background(161, 242, 95); }else if (quarter == 3) { background(192, 206, 181); }else if (quarter == 4); This is how I am doing right now
anonymous
  • anonymous
No, it only goes up to 3 since there are only four quarters in a minute (0, 1, 2 and 3). You will also need to define the variable 'quarter' by adding the line 'int quarter = second()/15' before your 'if' statements. So the code will be: { int quarter = second()/15; if (quarter == 0) { background(0,0,0); } else if (quarter == 1) { background(10,10,10); } else if (quarter == 2) { background(50,50,50); } else if (quarter == 3) { background(100,100,100); } } There was a small syntax error in that post btw, where you had your third 'if' statement but I've corrected it here. Hope that clarifies.
anonymous
  • anonymous
Ok I took out the quarter 4. I am realizing that it is still not changing.
anonymous
  • anonymous
Is there an example on how to put the changing every 15 seconds part?
anonymous
  • anonymous
How are you getting along? I've downloaded Processor and had a little play about with it. I got the background changing every 15 seconds using this: void setup() { size(400, 400); smooth(); } void draw() { int quarter = second()/15; if (quarter == 0) { background(0,0,0); } else if (quarter == 1) { background(255,10,10); } else if (quarter == 2) { background(50,255,50); } else if (quarter == 3) { background(255,255,255); } }
anonymous
  • anonymous
@Daire your setup worked it changes, thanks.
anonymous
  • anonymous
Excellent, glad I could help. Did you find a solution for the triangle and rectangle moving?

Looking for something else?

Not the answer you are looking for? Search for more explanations.