Exemple #1
0
def draw(state):
    qs.clear(WHITE)

    # draw the frame
    qs.circ([400, 300], 203, color=BLACK)
    qs.circ([400, 300], 200, color=WHITE)
    # draw the hour markers
    for i in range(1, 13):
        angle = 360. * ((i + 9.) * 2. / 24.)
        rad = angle * 3.14 / 180
        pos = [math.sin(rad) * 200. + 400., math.cos(rad) * 200. + 300.]
        qs.line([[400, 300], pos], thickness=5, color=BLACK)
    qs.circ([400, 300], 180, color=WHITE)

    hour_angle = 360. * ((state["hours"] + 9.) * 2. / 24.) * 3.14 / 180
    minute_angle = 360. * ((state["minutes"] + 45.) / 60.) * 3.14 / 180
    second_angle = 360. * ((state["seconds"] + 45.) / 60.) * 3.14 / 180

    hour_pos = [
        math.cos(hour_angle) * 150. + 400,
        math.sin(hour_angle) * 150 + 300
    ]
    min_pos = [
        math.cos(minute_angle) * 180. + 400,
        math.sin(minute_angle) * 180 + 300
    ]
    second_pos = [
        math.cos(second_angle) * 180. + 400,
        math.sin(second_angle) * 180. + 300
    ]

    qs.line([[400, 300], hour_pos], thickness=10, color=BLACK)
    qs.line([[400, 300], min_pos], thickness=5, color=BLUE)
    qs.line([[400, 300], second_pos], thickness=3, color=RED)
Exemple #2
0
def draw(_state):
    # Remove any artifacts from the previous frame
    qs.clear(WHITE)
    # Draw a blue rectangle with a top-left corner at (100, 100) and a width and height of 32
    qs.rect([[100, 100], [32, 32]], color=BLUE)
    # Draw a green circle with its center at (400, 300) and a radius of 100
    qs.circ([400, 300], 100., color=GREEN)
    # Draw a red line with thickness of 2 pixels and z-height of 5
    qs.line([[50, 80], [600, 450]], thickness=2., color=RED)
    # Draw a red triangle rotated by 45 degrees, and scaled down to half
    qs.triangle([[500, 50], [450, 100], [650, 150]],
                color=RED,
                transform=matmul(rotate(45), scale(0.5, 0.5)))
    # Draw a blue rectangle, rotated by 45 degrees, with a z-height of 10
    qs.rect([[400, 300], [32, 32]], color=BLUE, transform=rotate(45))
Exemple #3
0
def draw(_):
    qs.clear(WHITE)
    qs.text("hello world", font="precious", p0=[0, 0], color=RED)