restart; with(plots): with(plottools): # Letter M makeM:=proc(x0,y0,h,b,w) local Hm,opts,LiaM,nframes: Hm:=h/3: opts:= scaling=constrained,linestyle=1, thickness=1: display(polygon([[x0,y0], [x0,y0+h], [x0+w,y0+h],[x0+w, y0]]),color=red,opts, polygon([[x0+b/2, y0+Hm], [x0+w, y0+3*h/4],[x0+w,y0+h],[x0+b/2, y0+Hm+2*w*(h-Hm)/b]]),color=white,opts, polygon([[x0+b/2, y0+Hm+2*w*(h-Hm)/b], [x0+b-w,y0+ h],[x0+b-w,y0+3*h/4],[x0+b/2, y0+Hm]]),color=blue,opts, polygon([ [x0+b-w,y0+ h], [x0+b,y0+h], [x0+b,y0], [x0+b-w, y0]]),color=turquoise,opts): end proc: #makeM makeM(0,0,12,7.8,1.2); #print(`Letter M - with animation`); nframes:=48: LiaM:=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]: x0:=0:y0:=0:b:=7.8:w:=1.2:Hm:=4:h:=12: #printf("y0=%5.3f w=%5.3f b=%5.3f Hm=%5.3f h=%5.3f \n", y0,w,b,Hm,h); opts:= linestyle=1, thickness=1, scaling=constrained: for i from 1 to nframes do #was 0 to nframes? h:=12-0.37*i*(nframes-i)/nframes:Hm:=h/3: lM[i]:= polygon([[x0,y0], [x0,y0+h], [x0+w,y0+h],[x0+w, y0]]),color=red,opts, polygon([[x0+b/2, y0+Hm], [x0+w, y0+3*h/4],[x0+w,y0+h],[x0+b/2, y0+Hm+2*w*(h-Hm)/b]]),color=white,opts, polygon([[x0+b/2, y0+Hm+2*w*(h-Hm)/b], [x0+b-w,y0+ h],[x0+b-w,y0+3*h/4],[x0+b/2, y0+Hm]]),color=blue,opts, polygon([ [x0+b-w,y0+ h], [x0+b,y0+h], [x0+b,y0], [x0+b-w, y0]]),color=turquoise,opts: end do: print(`for loop lM[i]:=lM[Liam[i]]: - Expecting error message: i= 0 to nframes ? ?`); for i from 0 to nframes-1 do lM[i]:=lM[LiaM[i]]: end do: print(`Animated plot of letter M - seq(lM[i], i=1..nframes )`); plots[display](seq(lM[i],i=1..nframes), scaling=constrained, insequence=true);