File: test.py

package info (click to toggle)
ipe-tools 1%3A7.2.29.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 880 kB
  • sloc: cpp: 2,719; python: 2,122; ansic: 1,052; sh: 224; makefile: 94; xml: 39
file content (47 lines) | stat: -rw-r--r-- 1,157 bytes parent folder | download | duplicates (4)
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
#
# Access Ipe document from Python
#

import sys, os
import math

assert sys.hexversion >= 0x3060000

import ipe

print("Ipe configuration: ", ipe.config.latexdir, ipe.config.version)

print("Testing ipe.Vector and ipe.Matrix:")
v1 = ipe.Vector()
v2 = ipe.Vector(3, 2)
v3 = ipe.Direction(math.pi/4.0)
print(v1, v2, v3)
print(v1 + v2, v2 + v3, v3 - v2)
print(v2.len(), v3.len(), v2.angle(), v3.angle())
print(v2 == v1 + v2, v2 == v2 + v3)
print("Dot products: ", v1 ^ v2, v2 ^ v3)
print(3 * v2, v3 * 7)
print(-v2, -v3)

m1 = ipe.Matrix(1.0, 0, 0, 2.0, 5, 8)
m2 = ipe.Matrix(1.0, 2, 3, -1.0, 0, 0)
print(m1, m2)
print(m1 * m2)
print(m1 * v2, m1 * v3, m2 * v3)

if len(sys.argv) == 2:
  ipename = sys.argv[1]
else:
  ipename = "../poweripe/demo-presentation.ipe"
  
doc = ipe.Document(ipename)
print("Document has ", len(doc), "pages and ", doc.countTotalViews(), "views")

props = doc.properties()
print("Some document properties: ", props.title, props.created, props.creator)
print("All document properties:")
for k in props:
  print(" -", k, props[k])
  
for pageNo in range(1, len(doc) + 1):
  print("Page %d has %d objects" % (pageNo, len(doc[pageNo])))