/* Code generated by RoboBlockly v2.0 */
/* Problem Statement:
Run the code and input a value to watch a clock in action. */
#include <chplot.h>
double hour;
double minute;
CPlot plot;
// Describe this function...
void Winding_hour() {
double i;
double i_inc = 0.05;
if (0 > hour) {
i_inc = -i_inc;
}
i = 0;
while(i_inc >= 0 ? i <= hour : i >= hour) {
//plot.backgroundImage("./Background.png");
plot.strokeColor("black");
plot.line(0, 0, 0, 7.2);
plot.strokeColor("red");
plot.line(0, 0, 6 * cos(deg2rad((90 - i * 30))), 6 * sin(deg2rad((90 - i * 30))));
delaySeconds(0.01);
i += i_inc;
}
//plot.backgroundImage("./Background.png");
plot.strokeColor("black");
plot.line(0, 0, 0, 7.2);
plot.strokeColor("red");
plot.line(0, 0, round((6 * cos(deg2rad((90 - hour * 30))))), round((6 * sin(deg2rad((90 - hour * 30))))));
}
// Describe this function...
void Winding_minute() {
double angleH;
double j;
angleH = 90 - hour * 30;
double j_inc = 0.1;
if (0 > minute) {
j_inc = -j_inc;
}
j = 0;
while(j_inc >= 0 ? j <= minute : j >= minute) {
//plot.backgroundImage("./Background.png");
plot.strokeColor("red");
plot.line(0, 0, 6 * cos(deg2rad((angleH - j * 0.5))), 6 * sin(deg2rad((angleH - j * 0.5))));
plot.strokeColor("black");
plot.line(0, 0, 7.2 * cos(deg2rad((90 - j * 6))), 7.2 * sin(deg2rad((90 - j * 6))));
delaySeconds(0.001);
j += j_inc;
}
}
// Sample: It's 3:10 . Enter 3 for hour and 10 for minute
plot.strokeWidth(6);
plot.strokeColor("black");
plot.line(0, 0, 0, 7.2);
plot.strokeColor("red");
plot.line(0, 0, 0, 6);
delaySeconds(0.1);
hour = 3;
Winding_hour();
minute = 10;
Winding_minute();
plot.label(PLOT_AXIS_XY, "");
plot.grid(PLOT_OFF);
plot.tics(PLOT_AXIS_XY, PLOT_OFF);
plot.axis(PLOT_AXIS_XY, PLOT_OFF);
plot.axisRange(PLOT_AXIS_XY, -12, 12);
plot.ticsRange(PLOT_AXIS_XY, 2);
plot.sizeRatio(1);
plot.plotting();