def drawMinorTickmarks(): for i in range(60): canvas.save_gstate() canvas.translate(centerX, centerY) canvas.rotate(-2 * pi / 60.0 * i) canvas.set_fill_color(0.4, 0.4, 0.4, 0.6) width = 1 height = 5 canvas.set_line_width(1) canvas.draw_rect(-width/2, clockWidth * 0.505, width, height) canvas.restore_gstate()
def drawNumbers2(): for i in range(12): canvas.save_gstate() canvas.translate(centerX, centerY) canvas.rotate(-2 * pi / 12.0 * i) canvas.set_fill_color(0.3, 0.3, 0.3, 0.6) fontSize = 30 fontName = 'Helvetica-Bold' number = str(12 if i == 0 else i) width, height = canvas.get_text_size(number, fontName, fontSize) canvas.draw_text(number, -width/2, 115, fontName, fontSize) canvas.restore_gstate()
x = i + 5 y = originY - 5 canvas.fill_rect(x, y, 10, 10) for i in range(40, 460, 20): x = originX - 5 y = i + 5 canvas.fill_rect(x, y, 10, 10) canvas.set_fill_color(0.5, 0, 0, 0.5) for i in range(12): canvas.save_gstate() canvas.set_fill_color(0.4, 0.4, 0.8, 0.4) canvas.translate(250, 250) canvas.rotate(-2 * pi / 12.0 * i) canvas.fill_rect(0, 0, 120, 120) canvas.restore_gstate() canvas.begin_updates() for i in range(12): canvas.save_gstate() canvas.translate(250, 250) canvas.rotate(-2 * pi / 12.0 * i) for j in range(0, 80): randomIntX = random.randrange(0, 160) randomIntY = random.randrange(0, 160) randomColor = random.random() x = randomIntX y = randomIntY canvas.set_fill_color(randomColor, randomColor, randomColor, 0.4)
finally: canvas.restore_gstate() screenHeight = 512 circleHeight = 128 colorBlue = (0, 0, 1) colorGreen = (0, 1, 0) colorRed = (1, 0, 0) def coloredCircle(inColor, inX, inY): canvas.set_fill_color(*inColor) canvas.fill_ellipse(inX, inY, circleHeight, circleHeight) canvas.clear() canvas.set_size(screenHeight * 1.42, screenHeight) with privateGstate(): # Save and then restore the canvas.gstate canvas.rotate(89) # Text on an angle. canvas.draw_text('Green on top -->', 154, 0, 'Helvetica', 36) canvas.draw_text('<-- Red and Blue on bottom', 282, 52, 'Helvetica', 36) x = 20 + circleHeight coloredCircle(colorRed, 10, 10) # Red circle appears at bottom. with flippedDisplay(): # Change origin to topLeft instead of bottomLeft. coloredCircle(colorGreen, x, 10) # Green circle appears at top. coloredCircle(colorBlue, x, 10) # Blue circle appears at bottom.
model=cv.turning(model,angle,CENTER,half_middle_axis_length,half_horizontal_axis_length,radius_of_wheel,el_length) if angle>0 : car.rrl=model[19] car.steerleft(angle) #vektor_speed=[car.speed*,car.speed*] elif angle<0 : car.rrr=model[21] car.steerright(angle) model=cv.rotate(model,CENTER,car.dir) for i in range (0, p+1): dis_yellow[i]=cal.calculate_r((car.x,car.y),(list_cone_yellow[i].x-model[7][0][0],list_cone_yellow[i].y-model[7][0][1])) draw_yellow_cone[i]=[list_cone_yellow[i].x-cam.x,list_cone_yellow[i].y-cam.y] for i in range (0, q+1): dis_blue[i]=cal.calculate_r((list_cone_blue[i].x-model[7][0][0],list_cone_blue[i].y-model[7][0][1]),(car.x,car.y)) draw_blue_cone[i]=[list_cone_blue[i].x-cam.x,list_cone_blue[i].y-cam.y] for i in range (0, j+1): draw_path[i]=[list_path_point[i].x-cam.x,list_path_point[i].y-cam.y]