# rotateLine1 ``` # ch31_24_2.py #python from turtle import * import random from time import process_time as pt, strftime, localtime print(strftime("%H:%M:%S %Y%m%d", localtime())) def rotateLine(n,n2,y,w,scale,angle,length,a0=-1): n1 = n*(1 + (n<5)) #n個頂點 #a0 = (-1,1)[n>10] a = 360//n-1 #if n < 11 #a = 360/n+a0 #(11,1) (12,1/2) if n >= 11 hideturtle() speed(0) bgcolor('black') colors = ['red','cyan','violet','yellow','blue','white', 'orange','purple','cyan','green','red','blue','Magenta', 'white',(0.46, 0.96, 0.438),'orange',(0.62, 0.56, 0.9),'cyan', (0.72, 0.93, 0.064),'white',(0.094, 0.68, 0.57)] a1 = len(colors) if n < a1+1: x=[] else: x = [(random.random(),random.random(),random.random()) for i in range(n-a1)] colors.extend(x) setpos(0,y) a2 = (100,200,300)[(n>10)+(n>20)] for i in range(n2): color(colors[i%n1]) width(i/a2+w) forward(i*scale) #(7,2.7) left(a) color(colors[n2%n1]) width(n2/a2+w) [left(-angle),right(angle)][angle > 0] forward(length) #(7,70) #fn = f'{n}rotateLine.eps' #getscreen().getcanvas().postscript(file=fn) print(strftime("%H:%M:%S %Y%m%d", localtime())) done() print(x) #rotateLine(3,40,0,2.5,20,1.5,45) #rotateLine(4,60,-5,2.5,10,-3,45) #rotateLine(5,90,-5,2.5,5.5,-0.75,43) #rotateLine(6,129,12,1,3.4,1.5,50) #rotateLine(7,120,0,1,2.7,0,70) #rotateLine(8,190,5,1,1.6,0,60) #rotateLine(9,215,5,1,1.25,0,65) #rotateLine(10,275,5,1,0.85,0,70) #rotateLine(10,240,5,1,1,-0.5,70) #rotateLine(11,500,5,0.8,0.45,-0.5,200) #rotateLine(12,495,5,0.8,0.43,-0.5,170,1/2) #rotateLine(13,495,5,0.8,0.4,-0.5,160,1/3) #rotateLine(14,525,5,0.8,0.34,-1,150,1/4) #rotateLine(15,525,5,0.8,0.31,-1,126,1/3) #rotateLine(16,760,5,0.5,0.19,-1,100,1/4) #rotateLine(17,880,5,0.5,0.15,-1,90,1/4) #rotateLine(17,940,5,0,0.14,-1,90,1/4) #rotateLine(18,1000,5,0,0.13,-0.5,90,1/4) #rotateLine(19,1060,5,0,0.12,-0.5,90,1/4) #rotateLine(20,1120,5,0,0.11,-0.5,95,1/5) ##rotateLine(21,1420,5,0,0.05,-0.5,95,1/10) ##rotateLine(17,880,5,0.5,0.15,-1.5,55,-1/2) rotateLine(17,580,5,0.5,0.25,-2.5,85,-0.6) """Convert image to WebP. Args: source (pathlib.Path): Path to source image Returns: pathlib.Path: path to new image """ '''from pathlib import Path from PIL import Image def convert_to_webp(source): destination = source.with_suffix(".webp") # replaces the current suffix with a new suffix image = Image.open(source) # Open image image.save(destination, format="webp") return destination convert_to_webp(Path('4rotateLine.jpg'))''' ``` ![](https://i.imgur.com/FhGHYFw.jpg)