сделать 24 часа в сутки. Что делает его 24-часовым, так это то, что циферблат будет отсчитываться с нуля до 23. Но циферблат имеет только нумерацию часов AM или нумерацию часов, показанных в любой момент времени. Нумерация AM от 0 до 11. PM от 12 до 23
Мне нужно использовать код drawNum, и я не могу заставить его работать,
это код, который у меня есть ...
float x[], y[];
float diam;
color c[];
int n; //number of balls
void setup()
{
size (500, 500);
colorMode(HSB);
background(0);
frameRate(1);
x = new float [n];
y = new float [n];
}
void draw()
{
float h, m, s;
float radius;
float cx, cy;
float clockface;
float hoursRadius, minutesRadius, hoursTick, secondsRadius, minutesTick;
radius = min(height/2.0, width/2.0);
cx = width/2.0;
cy = height/2.0;
clockface = radius * 0.9;
hoursRadius = radius * 0.5;
minutesRadius = radius * 0.65;
secondsRadius = radius * 0.72;
hoursTick = radius * 0.04;
minutesTick = hoursTick * 0.5;
// get time
s = second();
m = minute();
h = hour()%12 + m/60.0;
//draw clock face
fill(40);
noStroke();
ellipseMode(RADIUS);
ellipse(cx, cy, clockface, clockface);
//
drawHand(cx, cy, s*6.0, secondsRadius, 2);
drawHand(cx, cy, m*6.0, minutesRadius, 3);
drawHand(cx, cy, h*30.0, hoursRadius, 5);
for ( int i=0; i<60; i++) {
if (i%5==0) {
drawNum(cx, cy, i*6, secondsRadius, 10, 0);
} else {
drawNum(cx, cy, i*6, secondsRadius, 5, 23);
}
}
// draw the ticks
for ( int i=0; i<60; i++) {
if (i%5==0) {
drawTick(cx, cy, i*6, secondsRadius, 10);
} else {
drawTick(cx, cy, i*6, secondsRadius, 5);
}
}
}
void drawTick( float x, float y,
float angle, float len,
float weight) {
fill(angleToColor(angle));
noStroke();
rectMode(CENTER);
rect(x + cos(radians(angle-90))*len,
y + sin(radians(angle-90))*len,
weight, weight) ;
}
void drawHand( float x, float y,
float angle, float len,
float weight) {
strokeWeight(weight);
stroke(angleToColor(angle));
line(x, y,
x + cos(radians(angle-90))*len,
y + sin(radians(angle-90))*len);
}
color angleToColor(float angle) {
return color(map(angle, 0, 360, 0, 255), 255, 255);
}
void drawNum(float x,float y,
float angle, float len,
float tsize, int num) {
float i;
textSize(36);
fill(0);
noStroke();
for (num = 0; num < 12; num++) {
int hoursNum = (x + cos(radians(angle-90))*len,
y + sin(radians(angle-90))*len,
num, num)) ;;
}
}