~ubuntu-branches/debian/sid/pyx/sid

« back to all changes in this revision

Viewing changes to examples/drawing/style.txt

  • Committer: Bazaar Package Importer
  • Author(s): Stuart Prescott
  • Date: 2011-05-20 00:13:52 UTC
  • mto: (9.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20110520001352-odcuqpdezuusbbw1
Tags: upstream-0.11.1
ImportĀ upstreamĀ versionĀ 0.11.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Stroke and fill attributes
 
2
 
 
3
The previous example anticipated a simple case of setting an attribute when
 
4
stroking paths. This example shows a few more use-cases.
 
5
 
 
6
Attributes can be passed in a list as the second optional argument of the
 
7
`stroke` or `fill` methods of a canvas instance. ... The attributes themselves are
 
8
instances of certain attribute classes. A full list is available in the manual.
 
9
 
 
10
In general, some useful attribute instances are predefined as class attributes
 
11
of the corresponding attribute class. In the given example, the
 
12
`style.linewidth.THICK`, `style.linestyle.dashed`, `style.linecap.round`,
 
13
`color.rgb.red`, `color.rgb.green`, and `color.rgb.blue` are just some examples of
 
14
this type of attribute instances. In contrast, `style.linewidth(0.2)` creates a
 
15
new style instance for the given parameters.
 
16
 
 
17
!! The linewidth instance created by `style.linewidth(0.2)` is different from the
 
18
predefined linewidth instances in PyX in its use of ''user'' units. In the example
 
19
''Adding and joining paths'' of section ''Path features'', the linewidth is
 
20
scaled independently of the ''user'' units, but if you try to double all linewidth
 
21
by
 
22
 
 
23
    unit.set(wscale=2)
 
24
 
 
25
in the beginning of the script, our self-defined linewidth will not be scaled.
 
26
To obtain the proper scaling behaviour it would be necessary to attach the
 
27
''width'' unit by using
 
28
 
 
29
    style.linewidth(0.2*unit.w_cm)