small polygon refinement
[swftools.git] / spec / imagematrix.py
1 from sys import * 
2 from pdflib_py import * 
3 from math import sin,cos
4 p = PDF_new() 
5 PDF_open_file(p, "imagematrix.pdf")
6
7 PDF_set_parameter(p, "usercoordinates", "true")
8
9 width = 612
10 height = 600
11 PDF_begin_page(p, width, height)
12
13 a=0.7
14 b=-0.7
15 matrices = [[1,0,0,1,100,200],
16             [cos(a),sin(a),-sin(a),cos(a),400,75],
17             [1,0,0,-1,100,350],
18             [-1,0,0,1,450,370],
19             [1.9,0.5,0.6,1.4,50,-200],
20             [cos(b),sin(b),sin(b),-cos(b),500,630],
21             [1.0,0,0,3,-90,-200],
22            ]
23
24 i = PDF_load_image(p, "png", "karo.png", "")
25
26 for m in matrices:
27     PDF_save(p)
28     PDF_setmatrix(p, m[0],m[1],m[2],m[3],m[4],m[5])
29
30     x,y = 100,100
31     #PDF_fit_image(p, i, x, y, "")
32     PDF_place_image(p, i, x, y, 100/4)
33     w,h = 100,100
34
35     PDF_setrgbcolor_fill(p, 0.0, 1.0, 1.0)
36     PDF_moveto(p, x,y)
37     PDF_lineto(p, x+w,y)
38     PDF_lineto(p, x+w,y+h)
39     PDF_lineto(p, x,y+h)
40     PDF_lineto(p, x,y)
41     PDF_moveto(p, x-20,y-20)
42     PDF_lineto(p, x-20,y+20+h)
43     PDF_lineto(p, x+20+w,y+20+h)
44     PDF_lineto(p, x+20+w,y-20)
45     PDF_lineto(p, x-20,y-20)
46     PDF_fill(p);
47     PDF_restore(p)
48
49 PDF_end_page(p)
50 PDF_close(p)
51 PDF_delete(p);