Skip to content

Commit 992a432

Browse files
authored
Merge pull request #29 from martinRenou/add_fill_rule
Add fill rule
2 parents 4ffe970 + a5d6898 commit 992a432

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

examples/introduction.ipynb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,16 @@
241241
"execution_count": null,
242242
"metadata": {},
243243
"outputs": [],
244-
"source": []
244+
"source": [
245+
"c = ipycanvas.Canvas(size=(100, 100))\n",
246+
"\n",
247+
"c.begin_path() \n",
248+
"c.arc(50, 50, 30, 0, pi * 2, True)\n",
249+
"c.arc(50, 50, 15, 0, pi * 2, True)\n",
250+
"c.fill('evenodd')\n",
251+
"\n",
252+
"c"
253+
]
245254
}
246255
],
247256
"metadata": {

ipycanvas/canvas.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ def stroke(self):
135135
"""Stroke (outlines) the current path with the current ``stroke_style``."""
136136
self._send_canvas_command('stroke')
137137

138-
def fill(self):
139-
"""Fill the current or given path with the current ``fill_style``."""
140-
self._send_canvas_command('fill')
138+
def fill(self, rule='nonzero'):
139+
"""Fill the current path with the current ``fill_style`` and given the rule.
140+
141+
Possible rules are ``nonzero`` and ``evenodd``.
142+
"""
143+
self._send_canvas_command('fill', (rule, ))
141144

142145
def move_to(self, x, y):
143146
"""Move the "pen" to the given ``(x, y)`` coordinates."""

0 commit comments

Comments
 (0)