• anonymous
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"); } I have this almost done, but I am having trouble with this if anybody could help me out. For the last step, the minute indicator needs to change color on even and odd minutes. I don't that is happening and shapes such as the rectangle is suppose to move right I don't understand how to do and the triangle is suppose to expand, which is not happening. So while the background is changing every 15 seconds the shapes are suppose to present while moving and changing colors but that is not happening. I am not sure what I am doing wrong.
Computer Science
• Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
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.
 show full answer Looking for something else? Not the answer you are looking for? Search for more explanations. setupTrackingForm('searchOnBrainlyForm') More answers anonymous 5 years ago @Daire I think so, not sure. But what do you mean? anonymous 5 years ago You need to focus on what your code actually does on each line and how the program flows. I'll explain what you have here. int x = second(); int n = 27; if (x % 2 == 0) { fill(247, 5, 41); triangle(200, 200, 180, 220, 220, 220); } else if (x % 2 == 1) { fill(29, 37, 224); rect(20, 20, 60, 60); } } int x = second(); -This gives the variable x the value of second() int n = 27; -Gives the variable n the value 27 (not sure why that's here, it isn't used) if (x % 2 == 0) { fill(247, 5, 41); triangle(200, 200, 180, 220, 220, 220); } -Checks if the value of x is an even number. If it is even, draw a triangle with the fill colour. else if (x % 2 == 1) { fill(29, 37, 224); rect(20, 20, 60, 60); } -Checks if the value of x is an odd number. If it is odd, draws a rectangle with the fill colour. So the flow of this code goes like this: -Get the current second -Draw a (red?) triangle if the second is even -Draw a (blue?) rectangle if the second is odd What you want it do do is: -Get the current minute -Change fill if minute is even -Change fill if minute is odd -Then draw shape representing minute -Then draw shape representing second A few hints: -The colour of the shape will be the colour of the last 'fill()' you used. -To make an object move you substitute the coordinates with the second()/minute() functions e.g 'rect(second(), 0, 50,50);' will move the rectangle x-coordinate every second. I hope this helps. anonymous 5 years ago @Daire I am still having trouble with making the square move anonymous 5 years ago Can you post what code you have so far? anonymous 5 years ago @Daire void setup() { size(400, 400); smooth(); } void draw() { int s = second(); int m = minute(); int quarter = second()/15; if (quarter == 0) { background(237, 170, 171); } else if (quarter == 1) { background(197, 160, 240); } else if (quarter == 2) { background(147, 245, 146); } else if (quarter == 3) { background(219, 211, 135); } { int n = 27; if (n % 2 == 0) { println("n is even"); } else { println("n is odd"); } fill(247, 5, 41); triangle(200, 200, 180, 220, 220, 220); triangle(200, s, 180, 220, 220, 220); } { fill(29, 37, 224); rect(20, 20, 60, 60); rect(m, 20, 60, 60); } } anonymous 5 years ago This is what I have I noticed the triangle is moving down which is good but it needs to change color and the square is not moving also. anonymous 5 years ago i forgot to post this, it might help.This is just a hint what it might look like, http://evc-cit.info/cit020/clock_applet/index.html anonymous 5 years ago Hey @malibugranprix2000 This looks good, you're almost done. There's just two minor changes you need to make. int n = 27; if (n % 2 == 0) { println("n is even"); } else { println("n is odd"); } fill(247, 5, 41); triangle(200, 200, 180, 220, 220, 220); triangle(200, s, 180, 220, 220, 220); This code to control the triangle is a little off. The line 'int n = 27;' needs to be removed. What you have done is assigned the number 27 to 'n' which does not change throughout the program execution. Since you want to change the colour every minute you use the value 'm' which you assigned earlier in the code. So the 'if' statement will be 'if (m % 2 == 0)' Also, what you want the 'if' statements to change is the fill colour of the triangle. But what you have is a print statement that prints some text to the console. So the 'if' statements will look like this: if (m % 2 == 0) { fill(10,20,30); } else { fill(50,60,100); } triangle(200, s, 180, 220, 220, 220); You only need one triangle declaration since you're only drawing one triangle. And finally if you look closely you'll notice that your rectangle is moving correctly, but it'll only move about one pixel per minute so it'll be hard to notice. You can increase the amount it moves by multiplying or adding to the 'm' variable when declaring the rectangle. e.g 'rect((m*10), 20, 60, 60);' So if the current minute is 5 the x-coordinate for the rectangle will be 50 (5*10=50), and the next minute it will jump to 60 instead of going from 5 to 6. I hope this clarifies it for you. anonymous 5 years ago Thanks again Daire, this did clarify. anonymous 5 years ago No problem, glad I could help. show full answer Looking for something else? Not the answer you are looking for? Search for more explanations. setupTrackingForm('searchOnBrainlyForm') googletag.cmd.push(function(){googletag.display('openstudy.com_subpage_mid_bottom');}); 
 os.nextTick(function(){eq.includeMathJax() eq.whenMathJaxLoaded(function(){$('.questionBody').each(function(){var content=$(this).text() if(MathJax&&content.match(hasEquationRegex))MathJax.Hub.Queue(["Typeset",MathJax.Hub,body])})})}) os.nextTick(function(){$('.update-body p.body, .brn-answer .questionBody').each(function(){var content=$(this).html() \$(this).html(os.withParsedCodeBlocks(content))})}) os.nextTick(os.renderDrawings)