Skip to content

Commit 55ee2e6

Browse files
authored
Merge pull request #267 from martinRenou/tests_multicanvas
Add a test for multicanvas
2 parents 1c9523f + dd82055 commit 55ee2e6

8 files changed

+107
-0
lines changed
123 Bytes
Loading
185 Bytes
Loading
269 Bytes
Loading
285 Bytes
Loading
285 Bytes
Loading
272 Bytes
Loading
272 Bytes
Loading
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "2b36870c-73fc-481c-a682-9a5eabab63af",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"from ipycanvas import MultiCanvas\n",
11+
"m = MultiCanvas(n_canvases=3, width=200, height=200)\n",
12+
"m"
13+
]
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": null,
18+
"id": "fb32b605-6a15-4376-bb87-d8c9333ab3ca",
19+
"metadata": {},
20+
"outputs": [],
21+
"source": [
22+
"def draw_square(canvas, pos, width, color):\n",
23+
" canvas.fill_style = color\n",
24+
" canvas.fill_rect(pos, pos, width, width)\n",
25+
"draw_square(m[0], 0, 200, \"orange\")"
26+
]
27+
},
28+
{
29+
"cell_type": "code",
30+
"execution_count": null,
31+
"id": "fde5fc41-ee9f-495c-979b-20f3b879e59c",
32+
"metadata": {},
33+
"outputs": [],
34+
"source": [
35+
"draw_square(m[1], 50, 100, \"blue\")"
36+
]
37+
},
38+
{
39+
"cell_type": "code",
40+
"execution_count": null,
41+
"id": "48f7c586-eafe-45d9-8ad7-c1ef6540dba9",
42+
"metadata": {},
43+
"outputs": [],
44+
"source": [
45+
"draw_square(m[2], 75, 50, \"green\")"
46+
]
47+
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": null,
51+
"id": "e14ee226-b078-40c1-8a48-f2b9e177bf79",
52+
"metadata": {},
53+
"outputs": [],
54+
"source": [
55+
"draw_square(m[0], 0, 200, \"red\")"
56+
]
57+
},
58+
{
59+
"cell_type": "code",
60+
"execution_count": null,
61+
"id": "6d226c33-7e41-4795-a426-54f7916c7468",
62+
"metadata": {},
63+
"outputs": [],
64+
"source": [
65+
"m[1].clear()"
66+
]
67+
},
68+
{
69+
"cell_type": "code",
70+
"execution_count": null,
71+
"id": "32a55acd-984c-4e55-8e02-a3e2717d382d",
72+
"metadata": {},
73+
"outputs": [],
74+
"source": [
75+
"draw_square(m[0], 0, 200, \"orange\")"
76+
]
77+
}
78+
],
79+
"metadata": {
80+
"kernelspec": {
81+
"display_name": "Python 3 (ipykernel)",
82+
"language": "python",
83+
"name": "python3"
84+
},
85+
"language_info": {
86+
"codemirror_mode": {
87+
"name": "ipython",
88+
"version": 3
89+
},
90+
"file_extension": ".py",
91+
"mimetype": "text/x-python",
92+
"name": "python",
93+
"nbconvert_exporter": "python",
94+
"pygments_lexer": "ipython3",
95+
"version": "3.10.4"
96+
},
97+
"widgets": {
98+
"application/vnd.jupyter.widget-state+json": {
99+
"state": {},
100+
"version_major": 2,
101+
"version_minor": 0
102+
}
103+
}
104+
},
105+
"nbformat": 4,
106+
"nbformat_minor": 5
107+
}

0 commit comments

Comments
 (0)