Skip to content

Commit ebbffb6

Browse files
committed
doc
1 parent 4a5a0f1 commit ebbffb6

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Here in the repository is a folder called `scripts` containing some sample scrip
5151
## Graphical programmming
5252
**_EasyCoder_** is currently being extended to include a graphical programming environment. A single demo script `graphics-demo.ecs` is included in the `scripts` directory. To run it, first install the Python graphics library if it's not already present on your system. On Linux this is done with `sudo apt install python3-tk`. On Windows it's `pip install tk`. Then give the command `easycoder -g scripts/graphics-demo.ecs`.
5353

54-
As development progresses this demo program will be extended to include new features.
54+
As development progresses this demo script will be extended to include new features as they are added. **_EasyCoder_** graphics are handled by a library module, `ec_renderer` that can be used outside of the **EasyCoder_** environment, in other Python programs.
5555

5656
## EasyCoder programming reference
5757

scripts/graphics-demo.ecs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
! Graphics test
1+
! Graphics demo
22

3-
script GTest
3+
script Graphics-Demo
44

5-
! debug step
65
rectangle BlueRect
7-
rectangle RedRect
6+
ellipse RedEllipse
7+
ellipse GreenCircle
88
variable Spec
99
variable Widget
10+
variable Widget2
1011
variable N
1112
variable M
1213

14+
! debug step
15+
1316
create screen at 300 300 size 640 480 fill color yellow
1417
put json `{}` into Spec
15-
set property `#` of Spec to json `["BlueRect","RedRect"]`
18+
set property `#` of Spec to json `["BlueRect","RedEllipse"]`
1619

1720
! Blue rectangle
1821
put json `{}` into Widget
@@ -23,26 +26,42 @@
2326
set property `height` of Widget to 100
2427
set property `fill` of Widget to `blue`
2528
set property `id` of Widget to `bluerect`
29+
30+
! Green circle
31+
put json `{}` into Widget2
32+
set property `type` of Widget2 to `ellipse`
33+
set property `left` of Widget2 to 20
34+
set property `top` of Widget2 to 20
35+
set property `width` of Widget2 to 60
36+
set property `height` of Widget2 to 60
37+
set property `fill` of Widget2 to `green`
38+
set property `id` of Widget2 to `greencircle`
39+
set property `#` of Widget to json `["GreenCircle"]`
40+
set property `GreenCircle` of Widget to Widget2
2641
set property `BlueRect` of Spec to Widget
2742

28-
! Red rectangle
43+
! Red ellipse
2944
put json `{}` into Widget
30-
set property `type` of Widget to `rect`
45+
set property `type` of Widget to `ellipse`
3146
set property `left` of Widget to 400
3247
set property `top` of Widget to 200
33-
set property `width` of Widget to 100
48+
set property `width` of Widget to 200
3449
set property `height` of Widget to 100
3550
set property `fill` of Widget to `red`
36-
set property `id` of Widget to `redrect`
37-
set property `RedRect` of Spec to Widget
51+
set property `id` of Widget to `redellipse`
52+
set property `RedEllipse` of Spec to Widget
3853

3954
! print stringify Spec
4055
render stringify Spec
4156

4257
attach BlueRect to `bluerect`
4358
on click BlueRect print `Click Blue`
44-
attach RedRect to `redrect`
45-
on click RedRect print `Click Red`
59+
attach RedEllipse to `redellipse`
60+
on click RedEllipse print `Click Red`
61+
attach GreenCircle to `greencircle`
62+
on click GreenCircle print `Click Green`
63+
64+
debug stop
4665

4766
put 0 into N
4867
on tick

0 commit comments

Comments
 (0)