Остання активність 1751682544

A small Nova program to draw the trans pride flag in the playground.

wryl ревизій цього gist 1751682544. До ревизії

1 file changed, 72 insertions

flag.nv(файл створено)

@@ -0,0 +1,72 @@
1 + ||
2 + :: create a 400 by 400 canvas
3 + :: draw the trans pride flag
4 +
5 + |:: draw the trans pride flag|
6 + :: clear the canvas to black
7 + :: draw a 360 by 360 lightblue rectangle at 20 20
8 + :: draw a 360 by 250 pink rectangle at 20 80
9 + :: draw a 360 by 100 white rectangle at 20 150
10 +
11 + |:: clear the canvas to $color|
12 + :@graphics: clear $color
13 +
14 + |:: draw a $width by $height $color rectangle at $x $y|
15 + :@graphics: draw rect $x $y $width $height $color
16 +
17 + |:: create a $width by $height canvas :canvas initialized:?|
18 + :: set the canvas resolution to $width by $height
19 + |:: create a $width by $height canvas|
20 + :: initialize the canvas
21 + :: set the canvas resolution to $width by $height
22 +
23 + |:: set the canvas resolution to $width by $height :canvas initialized:?|
24 + :@graphics: set resolution $width $height
25 + |:: set the canvas resolution to $width by $height|
26 + :error: you need to initialize the canvas first
27 +
28 + |:: initialize the canvas :canvas initialized:?|
29 + |:: initialize the canvas|
30 + :@graphics: canvas init canvas
31 + :canvas initialized:
32 +
33 +
34 +
35 +
36 + |------------------------------------------------------------------------|
37 + |- The code below this comment modifies the playground to add a canvas. -|
38 + |------------------------------------------------------------------------|
39 +
40 + || :@include: (
41 + lib/rpn.nv
42 + lib/nv/meta.nv
43 + lib/platforms/browser_game.nv
44 + lib/platforms/browser_dom.nv
45 + )
46 +
47 + ||:DOM: (
48 + <query canvas <style center > >
49 + <query #code <style display = none >
50 + <query #code-actions < button innerText = [Edit Code] id = reset on click reset > >
51 + )
52 +
53 + |:click: reset|
54 + :DOM: (
55 + <query #code <style display = unset > >
56 + <query #reset @remove >
57 + )
58 +
59 + |:DOM: @remove :current dom element: $el?| ⁝@js⁝ $el .remove();
60 + |:DOM: center :current dom element: $el?|
61 + :DOM: (
62 + display = block
63 + marginLeft = auto
64 + marginRight = auto
65 + )
66 +
67 + |:@graphics: draw rect $x $y $w $h $color|
68 + :@graphics.draw: rect $x $y $w $h $color
69 +
70 + |:@graphics.draw: rect $x $y $w $h $color :@@canvas context: $ctx?|
71 + ⁝@js⁝ $ctx .fillStyle = $color;
72 + $ctx .fillRect( $x, $y, $w, $h );
Новіше Пізніше