Advertisement
tomasslavicek

Drawing second hand using precalculated sin/cos Connect IQ

Nov 12th, 2018
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.65 KB | None | 0 0
  1. var secPolygon = [[0,0], [0,0], [0,0], [0,0]];
  2. var x = 120, y = 120; //dc.getWidth() / 2;
  3.  
  4.  
  5. var bigRadius = x * 0.74;
  6. var smallRadius = x * 0.19;
  7. var handWidth = x * 0.006;
  8.  
  9. var h = [coefX[clockTime.sec], coefY[clockTime.sec]];
  10.  
  11. var normal = [h[1] * handWidth , -h[0] * handWidth];
  12. var s1 = [h[0] * bigRadius + x, h[1] * bigRadius + y];
  13. var s2 = [h[0] * smallRadius + x, h[1] * smallRadius + y];
  14.  
  15. secPolygon[0] = [s1[0] + normal[0], s1[1] + normal[1]];
  16. secPolygon[1] = [s2[0] + normal[0], s2[1] + normal[1]];
  17. secPolygon[2] = [s2[0] - normal[0], s2[1] - normal[1]];
  18. secPolygon[3] = [s1[0] - normal[0], s1[1] - normal[1]];
  19.  
  20. dc.fillPolygon(secPolygon);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement