Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CLOCK_MULTIPLIER = pi / 30;
- TOTAL_COUNT = 120;
- ONE_COUNT = 36;
- ONE_THIRD = ONE_COUNT / TOTAL_COUNT;
- FACE_SIZE = 120;
- SEC_LENGTH = 370;
- MIN_LENGTH = 280;
- HOUR_LENGTH = 200;
- second = time % 60;
- second_circum = second * CLOCK_MULTIPLIER;
- minute = time / 60;
- minute_circum = minute * CLOCK_MULTIPLIER;
- hour = time / 3600;
- hour_circum = (hour / 12) * 60 * CLOCK_MULTIPLIER;
- #clockhand
- #seconds
- is_second = floor(index / ONE_COUNT) == 0;
- sin_sec = sin(second_circum);
- cos_sec = cos(second_circum);
- #set to origin (hand for seconds):
- sec_x = 0;
- sec_y = (fraction - 0.03) * is_second * SEC_LENGTH;
- sec_tx = sec_x * cos_sec + sec_y * sin_sec;
- sec_ty = sec_y * cos_sec + sec_x * sin_sec;
- #minutes
- is_minute = floor((index - ONE_COUNT) / ONE_COUNT) == 0;
- sin_min = sin(minute_circum);
- cos_min = cos(minute_circum);
- #set to origin (hands for minutes):
- min_x = 0;
- min_y = (fraction - ONE_THIRD - 0.04) * is_minute * MIN_LENGTH;
- min_tx = min_x * cos_min + min_y * sin_min;
- min_ty = min_y * cos_min + min_x * sin_min;
- #hours
- is_hour = floor((index - ONE_COUNT * 2) / ONE_COUNT) == 0;
- sin_hour = sin(hour_circum);
- cos_hour = cos(hour_circum);
- #set to origin (hands for hours):
- hour_x = 0;
- hour_y = (fraction - ONE_THIRD * 2 - 0.05) * is_hour * HOUR_LENGTH;
- hour_tx = hour_x * cos_hour + hour_y * sin_hour;
- hour_ty = hour_y * cos_hour + hour_x * sin_hour;
- #CLOCKFACE
- face_index = (index - ONE_COUNT * 3) / (TOTAL_COUNT - ONE_COUNT * 3);
- is_clockface = (floor(face_index) == 0) * FACE_SIZE;
- face_rotation = face_index * tau;
- face_x = sin(face_rotation) * is_clockface;
- face_y = cos(face_rotation) * is_clockface;
- #if its second, it will only be affected by seconds.
- #if its minute, it will only be affected by minutes
- x' = sec_tx + min_tx + hour_tx + face_x;
- y' = sec_ty + min_ty + hour_ty + face_y;
- h = 0;
- s = 0;
- v = 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement