Commit 2a8cf420 authored by Øyvind Kolås's avatar Øyvind Kolås
Browse files

(preload:feat) use ctx for drawing analog clock

parent 40a4d417
Pipeline #4939 passed with stages
in 2 minutes and 14 seconds
......@@ -189,7 +189,7 @@ class Clock:
def updateClock(self, disp, localtime):
disp.clear(self.background_col)
disp.pixel(self.center[0] + self.offsetx, self.center[1], col=self.center_col)
#disp.pixel(self.center[0] + self.offsetx, self.center[1], col=self.center_col)
hour_coords = self.circlePoint(
math.radians(
(((localtime[3] % 12) / 12.0) if localtime[3] else 0) * 360
......@@ -198,7 +198,7 @@ class Clock:
)
)
minute_coords = self.circlePoint(math.radians(localtime[4] * 6 + 270))
second_coords = self.circlePoint(math.radians(localtime[5] * 6 + 270))
second_coords = self.circlePoint((math.radians(time.time_ms()%60000)/1000.0 * 6 + 270))
for i in range(60):
degree = i * 6 + 90
......@@ -305,14 +305,11 @@ class Clock:
vector = self.normVector(vector)
destination = self.addVector(source, self.multiplyVector(vector, length))
disp.line(
round(source[0]) + self.offsetx,
round(source[1]),
round(destination[0]) + self.offsetx,
round(destination[1]),
col=col,
size=thickness,
)
disp.rgba(col[0]/255.0, col[1]/255.0, col[2]/255.0, 1.0)
disp.move_to(source[0] + self.offsetx, source[1])
disp.line_to(destination[0] + self.offsetx, destination[1])
disp.line_width(thickness)
disp.stroke()
def normVector(self, v):
length = math.sqrt(sum([i ** 2 for i in v]))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment