Skip to content

Commit 822459c

Browse files
juliaogrisJulia Ogris
authored andcommitted
wip
1 parent 4a70c1d commit 822459c

File tree

21 files changed

+734
-61
lines changed

21 files changed

+734
-61
lines changed

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ linters:
2626
- gomnd
2727
- ifshort
2828
- interfacer
29+
- interfacebloat
2930
- ireturn
3031
- lll
3132
- maligned

frontend/courses/courses.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@
2222
{ "id": "dot", "title": "Red Dot" },
2323
{ "id": "lines", "title": "Lines" },
2424
{ "id": "squares", "title": "Squares" },
25-
{ "id": "rainbow", "title": "Rainbow" }
25+
{ "id": "rainbow", "title": "Rainbow" },
26+
{ "id": "fill", "title": "Fill, Stroke, Dash" },
27+
{ "id": "linestyle", "title": "Line Styles" },
28+
{ "id": "text", "title": "Text" },
29+
{ "id": "poly", "title": "Polygon and Polyline" },
30+
{ "id": "ellipse", "title": "Ellipse" },
31+
{ "id": "curve", "title": "Curve" }
2632
]
2733
},
2834
{
@@ -31,6 +37,7 @@
3137
"emoji": "🤹‍♀️",
3238
"units": [
3339
{ "id": "movingdot", "title": "Moving Red Dot" },
40+
{ "id": "bounce", "title": "Bounce" },
3441
{ "id": "juggle", "title": "Juggle" },
3542
{ "id": "splashtrig", "title": "Splash of Trig" },
3643
{ "id": "draw", "title": "Draw" }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
background := "hsl(0deg 0% 0% / 10%)"
2+
x := 10
3+
y := 50
4+
s := 1
5+
width 1
6+
fill background
7+
stroke "red"
8+
9+
on animate
10+
clear background
11+
move x y
12+
circle 10
13+
x = x + s
14+
if x < 10 or x > 90
15+
s = -s
16+
end
17+
end

frontend/courses/sample/animate/juggle.evy

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ func delta:num d:num n:num
4848
return -d
4949
end
5050

51-
func clear
52-
color "white"
53-
move 0 0
54-
rect 100 100
55-
end
56-
5751
func draw dot:{}num col:string
5852
color col
5953
move dot.x dot.y

frontend/courses/sample/animate/movingdot.evy

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ for i := range 0 100 0.1
55
sleep 0.01
66
end
77

8-
func clear
9-
color "white"
10-
move 0 0
11-
rect 100 100
12-
end
13-
148
func dot x:num y:num
159
color "red"
1610
move x y

frontend/courses/sample/animate/splashtrig.evy

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ for i := range (len dots)
6060
end
6161

6262
on animate
63-
clear
63+
// 2% opacity leaves trails on movement
64+
clear "hsl(0deg 100% 100% / 2%)"
6465

6566
for dot := range dots
6667
update dot
@@ -72,13 +73,6 @@ func update dot:{}num
7273
dot.phase = dot.phase + dot.s
7374
end
7475

75-
func clear
76-
// 2% opacity leaves trails on movement
77-
color "hsl(0deg 100% 100% / 2%)"
78-
move 0 0
79-
rect 100 100
80-
end
81-
8276
func draw dot:{}num col:string
8377
color col
8478
x := 50 + dot.orbit * (cos (tau * dot.phase))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print "todo"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// TODO: stop code scrolling for onkey with execution...
2+
labels := ["radiusX" "radiusY" "roation°" "start°" "end°"]
3+
vals := [5 10 45 90 360]
4+
cnt := len vals
5+
6+
fontfamily "arial"
7+
textsize 3.5
8+
cur := 1
9+
draw_table
10+
draw_ellipses
11+
12+
on key k:string
13+
if k == "ArrowLeft"
14+
cur = (cur + cnt - 1) % cnt
15+
else if k == "ArrowRight"
16+
cur = (cur + 1) % cnt
17+
else if k == "ArrowUp"
18+
vals[cur] = vals[cur] + 1
19+
else if k == "ArrowDown"
20+
vals[cur] = vals[cur] - 1
21+
end
22+
clear
23+
draw_ellipses
24+
draw_table
25+
end
26+
27+
func draw_ellipses
28+
width 0.5
29+
stroke "red"
30+
fill "black"
31+
ellipse 20 80 vals[0]
32+
ellipse 40 80 vals[0] vals[1]
33+
ellipse 60 80 vals[0] vals[1] vals[2]
34+
ellipse 80 80 vals[0] vals[1] vals[2] vals[3] vals[4]
35+
36+
end
37+
38+
func draw_table
39+
fill "none"
40+
stroke "black"
41+
width 0.2
42+
// TODO: broken: for i := range (len labels) // works with labels in local scope
43+
for i := range cnt
44+
draw_table_column i labels[i] vals[i]
45+
end
46+
stroke "red"
47+
width 0.7
48+
// TODO: broken with "" inlined; keeping this as bug report, though param passing not needed
49+
s := ""
50+
draw_table_column cur s -1
51+
end
52+
53+
func draw_table_column i:num label:string val:num
54+
x := i * 18 + 8
55+
w := 18
56+
move x-3 9
57+
rect w 16
58+
if label == ""
59+
return // rectangle only
60+
end
61+
move x-3 18
62+
line x+15 18
63+
move x 20
64+
text label
65+
move x 13
66+
text (sprintf "%2.0f" val)
67+
end
68+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
width 2
2+
3+
move 10 65
4+
color "red"
5+
circle 7
6+
move 3 40
7+
rect 14 14
8+
move 3 35
9+
line 17 35
10+
11+
move 30 65
12+
stroke "blue"
13+
circle 7
14+
move 23 40
15+
rect 14 14
16+
move 23 35
17+
line 37 35
18+
19+
move 50 65
20+
color "green"
21+
fill "orange"
22+
circle 7
23+
move 43 40
24+
rect 14 14
25+
move 43 35
26+
line 57 35
27+
28+
move 70 65
29+
stroke "deeppink"
30+
fill "cyan"
31+
circle 7
32+
move 63 40
33+
rect 14 14
34+
move 63 35
35+
line 77 35
36+
37+
move 90 65
38+
stroke "violet"
39+
fill "none"
40+
circle 7
41+
move 83 40
42+
rect 14 14
43+
move 83 35
44+
line 97 35
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
width 3
2+
linecap "round"
3+
move 5 80
4+
line 95 80
5+
6+
linecap "butt"
7+
move 5 70
8+
line 95 70
9+
10+
linecap "square"
11+
move 5 60
12+
line 95 60
13+
14+
width 1
15+
move 5 30
16+
dash 5 3 1 3
17+
line 95 30
18+
19+
dash
20+
move 5 20
21+
line 95 20
22+

0 commit comments

Comments
 (0)