~openobject-training/+junk/extra_base_for_scan

« back to all changes in this revision

Viewing changes to training_exam_processing/checkboxes.py

  • Committer: Xavier ALT
  • Date: 2010-01-20 10:27:43 UTC
  • mfrom: (4877.2.11 extra)
  • Revision ID: x.alt@ajm.lu-20100120102743-08z3f2smcaa5nj2d
[MERGE] merge scanning correction from Julien's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Checkbox border has 36 black dots (at reportlab's native 72 dpi)
 
2
 
 
3
def translate(l, vec):
 
4
    return [l[0] + vec[0], l[1] + vec[1], l[2] + vec[0], l[3] + vec[1]]
 
5
 
 
6
def enlarge(l, percent):
 
7
    size = l[2] - l[0]
 
8
    ds = percent * size
 
9
    return [l[0] - 2*ds, l[1] - ds, l[2] + 2*ds, l[3] + ds]
 
10
 
 
11
def scale(l, c):
 
12
    return map(lambda x: c * x, l)
 
13
 
 
14
def transform(ll, translate_vector, scale_factor, enlarge_factor):
 
15
    for l in ll:
 
16
        l[:] = translate(l, translate_vector)
 
17
        l[:] = scale(l, scale_factor)
 
18
        l[:] = enlarge(l, enlarge_factor)
 
19
        l[:] = map(int, map(round, l))
 
20