Skip to content

Commit 140a629

Browse files
authored
Merge pull request #78 from oaustegard/patch-1
Fixed issue with missing canvas.size property
2 parents 5dc2429 + 99a4dea commit 140a629

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

content/pyolite/ipycanvas.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
{
6464
"cell_type": "code",
65-
"source": "def draw(x, canvas, color='black'):\n with hold_canvas(canvas):\n canvas.clear()\n canvas.fill_style = '#FFF0C9'\n canvas.rough_fill_style = 'solid'\n canvas.fill_rect(-10, -10, canvas.size[0] + 10, canvas.size[1] + 10)\n canvas.rough_fill_style = 'cross-hatch'\n\n canvas.fill_style = color\n canvas.stroke_style = color\n\n living_cells = np.where(x)\n \n rects_x = living_cells[1] * n_pixels\n rects_y = living_cells[0] * n_pixels\n\n canvas.fill_rects(rects_x, rects_y, n_pixels)\n canvas.stroke_rects(rects_x, rects_y, n_pixels)",
65+
"source": "def draw(x, canvas, color='black'):\n with hold_canvas(canvas):\n canvas.clear()\n canvas.fill_style = '#FFF0C9'\n canvas.rough_fill_style = 'solid'\n canvas.fill_rect(-10, -10, canvas.width + 10, canvas.height + 10)\n canvas.rough_fill_style = 'cross-hatch'\n\n canvas.fill_style = color\n canvas.stroke_style = color\n\n living_cells = np.where(x)\n \n rects_x = living_cells[1] * n_pixels\n rects_y = living_cells[0] * n_pixels\n\n canvas.fill_rects(rects_x, rects_y, n_pixels)\n canvas.stroke_rects(rects_x, rects_y, n_pixels)",
6666
"metadata": {
6767
"trusted": true
6868
},
@@ -80,7 +80,7 @@
8080
},
8181
{
8282
"cell_type": "code",
83-
"source": "n_pixels = 15\n\ncanvas = RoughCanvas(width=x.shape[1]*n_pixels, height=x.shape[0]*n_pixels)\ncanvas.fill_style = '#FFF0C9'\ncanvas.rough_fill_style = 'solid'\ncanvas.fill_rect(0, 0, canvas.size[0], canvas.size[1])\n\ncanvas",
83+
"source": "n_pixels = 15\n\ncanvas = RoughCanvas(width=x.shape[1]*n_pixels, height=x.shape[0]*n_pixels)\ncanvas.fill_style = '#FFF0C9'\ncanvas.rough_fill_style = 'solid'\ncanvas.fill_rect(0, 0, canvas.width, canvas.height)\n\ncanvas",
8484
"metadata": {
8585
"trusted": true
8686
},
@@ -106,4 +106,4 @@
106106
"outputs": []
107107
}
108108
]
109-
}
109+
}

0 commit comments

Comments
 (0)