9
"cell_type": "heading",
13
"Stroke and fill attributes"
20
"from pyx import *\n",
22
"c = canvas.canvas()\n",
23
"c.stroke(path.line(0, 0, 4, 0),\n",
24
" [style.linewidth.THICK, style.linestyle.dashed, color.rgb.red])\n",
25
"c.stroke(path.line(0, -1, 4, -1),\n",
26
" [style.linewidth(0.2), style.linecap.round, color.rgb.green])\n",
27
"c.fill(path.rect(0, -3, 4, 1), [color.rgb.blue])\n",
35
"output_type": "pyout",
36
"png": "iVBORw0KGgoAAAANSUhEUgAAAKUAAAB7CAYAAAAVH0CFAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI\nWXMAAA9hAAAPYQGoP6dpAAAAHXRFWHRTb2Z0d2FyZQBHUEwgR2hvc3RzY3JpcHQgOS4wNx2hPKMA\nAAJ6SURBVHic7d3LTRxBGIXRWxYJkAIpOIWJBafgEOwQPCkQAoQAKUwKE8LvBX7wkrzwNHMtnyP1\nokGqKZU+qVW96Fozk1/WukpynW3sM3M4+ahrXSe5Ovm4ySEz+5OPuuUaz3zeZNzt1vguM3ev/joz\nv69kN8lsdO2e/dapruR2o/nebjTf7dZ4i/luu8Zf3vq9DxvUD39FlNQRJXVESZ2LF/fHJK93Q6dx\n3Gjch39s3C3XeCtbrcWbb2PWs1dCUMDjmzqipI4oqSNK6oiSOqKkjiipI0rqiJI6oqSOKKkjSuqI\nkjqipI4oqSNK6oiSOqKkjiipI0rqiJI6oqSOKKkjSuqIkjqipI4oqSNK6oiSOqKkzrPvU66syyQf\nzzQX/l+Hye+TQy6SZGXtknzLNsdSwB+trGOS/WQ+r0x2SW7PPSn44evK5D4e2RRZmfi+NFXsvqnz\nIcnNuScBTxxXJldJ7pNcnns2kOTTmpmf7ye/5HHDY9PDezvk8aye/WTunKNDHRsd6oiSOqKkjiip\nI0rqiJI6oqSOKKkjSuqIkjqipI4oqSNK6oiSOqKkjiipI0rqiJI6oqSOKKkjSuqIkjqipI4oqSNK\n6oiSOqKkjiipI0rqiJI6oqSOKKkjSuqIkjrPz2Zc+ZjHb5/De7qZyf7nzcWLf14m2b3vfCAPT288\nvqkjSuqIkjqipI4oqSNK6oiSOqKkjiipI0rqiJI6oqSOKKkjSuqIkjqipI4oqSNK6oiSOqKkjiip\nI0rqiJI6oqSOKKkjSuqIkjqipI4oqSNK6oiSOqKkjiipI0rqiJI6oqSOKKnz8nSIY5K7c0yE/9rh\n6c2amXNNBN70HRdp1KuC0k96AAAAAElFTkSuQmCC\n"
41
"cell_type": "markdown",
44
"The previous example anticipated a simple case of setting an attribute when\n",
45
"stroking paths. This example shows a few more use-cases.\n",
47
"Attributes can be passed in a list as the second optional argument of the\n",
48
"`stroke` or `fill` methods of a canvas instance. The attributes themselves are\n",
49
"instances of certain attribute classes. A full list is available in the manual.\n",
51
"In general, some useful attribute instances are predefined as class attributes\n",
52
"of the corresponding attribute class. In the given example, the\n",
53
"`style.linewidth.THICK`, `style.linestyle.dashed`, `style.linecap.round`,\n",
54
"`color.rgb.red`, `color.rgb.green`, and `color.rgb.blue` are just some examples of\n",
55
"this type of attribute instances. In contrast, `style.linewidth(0.2)` creates a\n",
56
"new style instance for the given parameters.\n",
58
"![bend](http://pyx.sourceforge.net/bend.png)![bend](http://pyx.sourceforge.net/bend.png) The linewidth instance created by `style.linewidth(0.2)` is different from the\n",
59
"predefined linewidth instances in PyX in its use of *user* units. In the example\n",
60
"*Adding and joining paths* of section *Path features*, the linewidth is\n",
61
"scaled independently of the *user* units, but if you try to double all linewidth\n",
64
" unit.set(wscale=2)\n",
66
"in the beginning of the script, our self-defined linewidth will not be scaled.\n",
67
"To obtain the proper scaling behaviour it would be necessary to attach the\n",
68
"*width* unit by using\n",
70
" style.linewidth(0.2*unit.w_cm)"
4
"cell_type": "markdown",
7
"# Stroke and fill attributes"
17
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAKUAAAB7CAYAAAAVH0CFAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI\nWXMAAA9hAAAPYQGoP6dpAAAAHXRFWHRTb2Z0d2FyZQBHUEwgR2hvc3RzY3JpcHQgOS4xNeq0bM4A\nAAJ6SURBVHic7d3LTRxBGIXRWxYJkAIpOIWJBafgEOwQPCkQAoQAKUwKE8LvBX7wkrzwNHMtnyP1\nokGqKZU+qVW96Fozk1/WukpynW3sM3M4+ahrXSe5Ovm4ySEz+5OPuuUaz3zeZNzt1vguM3ev/joz\nv69kN8lsdO2e/dapruR2o/nebjTf7dZ4i/luu8Zf3vq9DxvUD39FlNQRJXVESZ2LF/fHJK93Q6dx\n3Gjch39s3C3XeCtbrcWbb2PWs1dCUMDjmzqipI4oqSNK6oiSOqKkjiipI0rqiJI6oqSOKKkjSuqI\nkjqipI4oqSNK6oiSOqKkjiipI0rqiJI6oqSOKKkjSuqIkjqipI4oqSNK6oiSOqKkzrPvU66syyQf\nzzQX/l+Hye+TQy6SZGXtknzLNsdSwB+trGOS/WQ+r0x2SW7PPSn44evK5D4e2RRZmfi+NFXsvqnz\nIcnNuScBTxxXJldJ7pNcnns2kOTTmpmf7ye/5HHDY9PDezvk8aye/WTunKNDHRsd6oiSOqKkjiip\nI0rqiJI6oqSOKKkjSuqIkjqipI4oqSNK6oiSOqKkjiipI0rqiJI6oqSOKKkjSuqIkjqipI4oqSNK\n6oiSOqKkjiipI0rqiJI6oqSOKKkjSuqIkjrPz2Zc+ZjHb5/De7qZyf7nzcWLf14m2b3vfCAPT288\nvqkjSuqIkjqipI4oqSNK6oiSOqKkjiipI0rqiJI6oqSOKKkjSuqIkjqipI4oqSNK6oiSOqKkjiip\nI0rqiJI6oqSOKKkjSuqIkjqipI4oqSNK6oiSOqKkjiipI0rqiJI6oqSOKKnz8nSIY5K7c0yE/9rh\n6c2amXNNBN70HRdp1KuC0k96AAAAAElFTkSuQmCC\n",
19
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
20
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"88.3071pt\" fill=\"none\" stroke-miterlimit=\"10.000000\" y=\"-2.26772pt\" x=\"-2.83465pt\" version=\"1.1\" width=\"119.055pt\" stroke-width=\"0.566929\" viewBox=\"-2.83465 -2.26772 119.055 88.3071\">\n",
21
" <g stroke-linecap=\"butt\" stroke-dasharray=\"16.000000\" stroke-width=\"4.535433\" stroke-dashoffset=\"0.000000\">\n",
22
" <path stroke=\"#f00\" d=\"M0 -0L113.386 -0\"/>\n",
24
" <g stroke-linecap=\"round\" stroke-width=\"5.669291\">\n",
25
" <path stroke=\"#0f0\" d=\"M0 28.3465L113.386 28.3465\"/>\n",
28
" <path fill=\"#00f\" d=\"M0 85.0394L113.386 85.0394L113.386 56.6929L0 56.6929Z\"/>\n",
35
"output_type": "execute_result"
39
"from pyx import *\n",
41
"c = canvas.canvas()\n",
42
"c.stroke(path.line(0, 0, 4, 0),\n",
43
" [style.linewidth.THICK, style.linestyle.dashed, color.rgb.red])\n",
44
"c.stroke(path.line(0, -1, 4, -1),\n",
45
" [style.linewidth(0.2), style.linecap.round, color.rgb.green])\n",
46
"c.fill(path.rect(0, -3, 4, 1), [color.rgb.blue])\n",
51
"cell_type": "markdown",
54
"The previous example anticipated a simple case of setting an attribute when\n",
55
"stroking paths. This example shows a few more use-cases.\n",
57
"Attributes can be passed in a list as the second optional argument of the\n",
58
"`stroke` or `fill` methods of a canvas instance. The attributes themselves are\n",
59
"instances of certain attribute classes. A full list is available in the manual.\n",
61
"In general, some useful attribute instances are predefined as class attributes\n",
62
"of the corresponding attribute class. In the given example, the\n",
63
"`style.linewidth.THICK`, `style.linestyle.dashed`, `style.linecap.round`,\n",
64
"`color.rgb.red`, `color.rgb.green`, and `color.rgb.blue` are just some examples of\n",
65
"this type of attribute instances. In contrast, `style.linewidth(0.2)` creates a\n",
66
"new style instance for the given parameters.\n",
68
"<img src=\"http://pyx.sourceforge.net/bend.png\" align=\"left\"><img src=\"http://pyx.sourceforge.net/bend.png\" align=\"left\"> The linewidth instance created by `style.linewidth(0.2)` is different from the\n",
69
"predefined linewidth instances in PyX in its use of *user* units. In the example\n",
70
"*Adding and joining paths* of section *Path features*, the linewidth is\n",
71
"scaled independently of the *user* units, but if you try to double all linewidth\n",
74
" unit.set(wscale=2)\n",
76
"in the beginning of the script, our self-defined linewidth will not be scaled.\n",
77
"To obtain the proper scaling behaviour it would be necessary to attach the\n",
78
"*width* unit by using\n",
80
" style.linewidth(0.2*unit.w_cm)\n"
b'\\ No newline at end of file'