## demonstrate rotation and alpha blending import PyArt c = PyArt.Canvas(356, 256, bg=0x7f7f7f) c.gstate.fill = 0xFFFFFF c.gstate.font_size = 48 def rotate_alpha_blend_text(can,off_x, text, dw, n, end_alpha): "decrease alpha linearly over the range of n points" dalpha = end_alpha/n for ii in range(n): can.gsave() can.rotate(dw*ii) # print dw*ii can.gstate.fill_opacity = end_alpha-ii*dalpha # print "alpha = ", can.gstate.fill_opacity can.drawString(off_x,0, text) can.grestore() c.translate(85,220) # controls centering of the figure n = 8.0 dw = 90.0/n off_x = 5 text = "Pingo Art" c.gsave() c.rotate(-dw*n) c.gstate.fill = 0xFFFFFF rotate_alpha_blend_text(c, off_x, text, dw, n, end_alpha=.9) c.grestore() c.gstate.fill = 0x000000 c.drawString(off_x,0, text) c.save("demo_rotate_alpha_text.png") # here's a rotation example without alpha blending c = PyArt.Canvas(256, 256, bg=0x7f7f7f) c.gstate.fill = 0xFFFFFF c.gstate.font_size = 18 c.translate(128,128) def rotate_text(can,off_x, text, dw, n): for ii in range(n): can.gsave() can.rotate(dw*ii) can.drawString(off_x,0, text) can.grestore() rotate_text(c, 15, "rotated text", 30, 12) c.save("demo_rotate_text.png")