summaryrefslogtreecommitdiff
path: root/spec/imagematrix.py
blob: 6819b873d33109c08681191b1c89b46403332797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from sys import * 
from pdflib_py import * 
from math import sin,cos
p = PDF_new() 
PDF_open_file(p, "imagematrix.pdf")

PDF_set_parameter(p, "usercoordinates", "true")

width = 612
height = 600
PDF_begin_page(p, width, height)

a=0.7
b=-0.7
matrices = [[1,0,0,1,100,200],
            [cos(a),sin(a),-sin(a),cos(a),400,75],
            [1,0,0,-1,100,350],
            [-1,0,0,1,450,370],
            [1.9,0.5,0.6,1.4,50,-200],
            [cos(b),sin(b),sin(b),-cos(b),500,630],
            [1.0,0,0,3,-90,-200],
           ]

i = PDF_load_image(p, "png", "karo.png", "")

for m in matrices:
    PDF_save(p)
    PDF_setmatrix(p, m[0],m[1],m[2],m[3],m[4],m[5])

    x,y = 100,100
    #PDF_fit_image(p, i, x, y, "")
    PDF_place_image(p, i, x, y, 100/4)
    w,h = 100,100

    PDF_setrgbcolor_fill(p, 0.0, 1.0, 1.0)
    PDF_moveto(p, x,y)
    PDF_lineto(p, x+w,y)
    PDF_lineto(p, x+w,y+h)
    PDF_lineto(p, x,y+h)
    PDF_lineto(p, x,y)
    PDF_moveto(p, x-20,y-20)
    PDF_lineto(p, x-20,y+20+h)
    PDF_lineto(p, x+20+w,y+20+h)
    PDF_lineto(p, x+20+w,y-20)
    PDF_lineto(p, x-20,y-20)
    PDF_fill(p);
    PDF_restore(p)

PDF_end_page(p)
PDF_close(p)
PDF_delete(p);