progress-pride-flag.nv
· 2.7 KiB · Text
Sin formato
Playground
||
:: create a 400 by 400 canvas
:: draw the trans pride flag
|:: draw the trans pride flag|
:: clear the canvas to black
:: draw a 360 by 360 lightblue rectangle at 20 20
:: draw a 360 by 250 pink rectangle at 20 80
:: draw a 360 by 100 white rectangle at 20 150
:: draw a black triangle at 20 20 20 380 200 200
|:: clear the canvas to $color|
:@graphics: clear $color
|:: draw a $width by $height $color rectangle at $x $y|
:@graphics: draw rect $x $y $width $height $color
|:: draw a $color triangle at $x1 $y1 $x2 $y2 $x3 $y3 |
:@graphics: draw triangle $x1 $y1 $x2 $y2 $x3 $y3 $color
|:: create a $width by $height canvas :canvas initialized:?|
:: set the canvas resolution to $width by $height
|:: create a $width by $height canvas|
:: initialize the canvas
:: set the canvas resolution to $width by $height
|:: set the canvas resolution to $width by $height :canvas initialized:?|
:@graphics: set-resolution _ $width $height
|:: set the canvas resolution to $width by $height|
:error: you need to initialize the canvas first
|:: initialize the canvas :canvas initialized:?|
|:: initialize the canvas|
:@graphics: canvas init canvas
:canvas initialized:
|------------------------------------------------------------------------|
|- The code below this comment modifies the playground to add a canvas. -|
|------------------------------------------------------------------------|
|| :@include: (
lib/rpn.nv
lib/nv/meta.nv
lib/platforms/browser_game.nv
lib/platforms/browser_dom.nv
)
||:DOM: (
<query canvas <style center > >
<query #code <style display = none >
<query #code-actions < button innerText = [Edit Code] id = reset on click reset > >
)
|:click: reset|
:DOM: (
<query #code <style display = unset > >
<query #reset @remove >
)
|:DOM: @remove :current dom element: $el?| ⁝@js⁝ $el .remove();
|:DOM: center :current dom element: $el?|
:DOM: (
display = block
marginLeft = auto
marginRight = auto
)
|:@graphics: draw rect $x $y $w $h $color|
:@graphics.draw: rect $x $y $w $h $color
|:@graphics: draw triangle $x1 $y1 $x2 $y2 $x3 $y3 $color|
:@graphics.draw: triangle $x1 $y1 $x2 $y2 $x3 $y3 $color
|:@graphics.draw: rect $x $y $w $h $color :@@canvas context: $ctx?|
⁝@js⁝ $ctx .fillStyle = $color;
$ctx .fillRect( $x, $y, $w, $h );
|:@graphics.draw: triangle $x1 $y1 $x2 $y2 $x3 $y3 $color :@@canvas context: $ctx? |
⁝@js⁝ $ctx .fillStyle = $color;
$ctx .beginPath();
$ctx .moveTo($x1 , $y1 );
$ctx .lineTo($x2 , $y2 );
$ctx .lineTo($x3 , $y3 );
$ctx .fill();
| 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 | :: draw a black triangle at 20 20 20 380 200 200 |
| 11 | |
| 12 | |:: clear the canvas to $color| |
| 13 | :@graphics: clear $color |
| 14 | |
| 15 | |:: draw a $width by $height $color rectangle at $x $y| |
| 16 | :@graphics: draw rect $x $y $width $height $color |
| 17 | |
| 18 | |:: draw a $color triangle at $x1 $y1 $x2 $y2 $x3 $y3 | |
| 19 | :@graphics: draw triangle $x1 $y1 $x2 $y2 $x3 $y3 $color |
| 20 | |
| 21 | |:: create a $width by $height canvas :canvas initialized:?| |
| 22 | :: set the canvas resolution to $width by $height |
| 23 | |:: create a $width by $height canvas| |
| 24 | :: initialize the canvas |
| 25 | :: set the canvas resolution to $width by $height |
| 26 | |
| 27 | |:: set the canvas resolution to $width by $height :canvas initialized:?| |
| 28 | :@graphics: set-resolution _ $width $height |
| 29 | |:: set the canvas resolution to $width by $height| |
| 30 | :error: you need to initialize the canvas first |
| 31 | |
| 32 | |:: initialize the canvas :canvas initialized:?| |
| 33 | |:: initialize the canvas| |
| 34 | :@graphics: canvas init canvas |
| 35 | :canvas initialized: |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |------------------------------------------------------------------------| |
| 41 | |- The code below this comment modifies the playground to add a canvas. -| |
| 42 | |------------------------------------------------------------------------| |
| 43 | |
| 44 | || :@include: ( |
| 45 | lib/rpn.nv |
| 46 | lib/nv/meta.nv |
| 47 | lib/platforms/browser_game.nv |
| 48 | lib/platforms/browser_dom.nv |
| 49 | ) |
| 50 | |
| 51 | ||:DOM: ( |
| 52 | <query canvas <style center > > |
| 53 | <query #code <style display = none > |
| 54 | <query #code-actions < button innerText = [Edit Code] id = reset on click reset > > |
| 55 | ) |
| 56 | |
| 57 | |:click: reset| |
| 58 | :DOM: ( |
| 59 | <query #code <style display = unset > > |
| 60 | <query #reset @remove > |
| 61 | ) |
| 62 | |
| 63 | |:DOM: @remove :current dom element: $el?| ⁝@js⁝ $el .remove(); |
| 64 | |:DOM: center :current dom element: $el?| |
| 65 | :DOM: ( |
| 66 | display = block |
| 67 | marginLeft = auto |
| 68 | marginRight = auto |
| 69 | ) |
| 70 | |
| 71 | |:@graphics: draw rect $x $y $w $h $color| |
| 72 | :@graphics.draw: rect $x $y $w $h $color |
| 73 | |:@graphics: draw triangle $x1 $y1 $x2 $y2 $x3 $y3 $color| |
| 74 | :@graphics.draw: triangle $x1 $y1 $x2 $y2 $x3 $y3 $color |
| 75 | |
| 76 | |:@graphics.draw: rect $x $y $w $h $color :@@canvas context: $ctx?| |
| 77 | ⁝@js⁝ $ctx .fillStyle = $color; |
| 78 | $ctx .fillRect( $x, $y, $w, $h ); |
| 79 | |
| 80 | |:@graphics.draw: triangle $x1 $y1 $x2 $y2 $x3 $y3 $color :@@canvas context: $ctx? | |
| 81 | ⁝@js⁝ $ctx .fillStyle = $color; |
| 82 | $ctx .beginPath(); |
| 83 | $ctx .moveTo($x1 , $y1 ); |
| 84 | $ctx .lineTo($x2 , $y2 ); |
| 85 | $ctx .lineTo($x3 , $y3 ); |
| 86 | $ctx .fill(); |
| 87 |