Skip to content

Commit

Permalink
Fixed issue with missing canvas.size property
Browse files Browse the repository at this point in the history
The original code references a missing size property of RoughCanvas. Instead use the width and height properties
  • Loading branch information
oaustegard authored May 12, 2022
1 parent 5dc2429 commit 99a4dea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions content/pyolite/ipycanvas.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
{
"cell_type": "code",
"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)",
"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)",
"metadata": {
"trusted": true
},
Expand All @@ -80,7 +80,7 @@
},
{
"cell_type": "code",
"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",
"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",
"metadata": {
"trusted": true
},
Expand All @@ -106,4 +106,4 @@
"outputs": []
}
]
}
}

0 comments on commit 99a4dea

Please sign in to comment.