-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f6cdc3
commit b76d66d
Showing
6 changed files
with
147 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { createSandbox } from "/js/createSandbox.js"; | ||
|
||
createSandbox( "path-basic-example", ( scene, stepEmitter, display ) => { | ||
const box = ( () => { | ||
/*START*/ | ||
const content = new HBox( { | ||
spacing: 10, | ||
children: [ | ||
// Rectangles are specified with x, y, width, height | ||
new Rectangle( 0, 0, 50, 50, { | ||
// fill is the "internal" color | ||
fill: 'red', | ||
|
||
// stroke color is applied on top, on the border of the shape | ||
stroke: 'black', | ||
|
||
// the width of the stroke can be controlled | ||
lineWidth: 3 | ||
} ), | ||
// Circles have a radius specified | ||
new Circle( 25, { fill: 'green' } ), | ||
// Lines are specified with x1, y1, x2, y2 (connecting two points) | ||
new Line( 0, 0, 50, 50, { | ||
stroke: 'blue', | ||
lineWidth: 5, | ||
|
||
// lineCap can be used to control the appearance of the | ||
// ends of the line similarly, lineJoin can be used to | ||
// control the appearance of any corners | ||
lineCap: 'round' | ||
} ) | ||
] | ||
} ); | ||
/*END*/ | ||
return content; | ||
} )(); | ||
scene.addChild( box ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { createSandbox } from "/js/createSandbox.js"; | ||
|
||
createSandbox( "path-shape-example", ( scene, stepEmitter, display ) => { | ||
const box = ( () => { | ||
/*START*/ | ||
// Method calls on the Shape can be chained for convenience | ||
const shape = new Shape() | ||
.moveTo( 0, 0 ) // start at 0,0 | ||
.lineTo( 40, 40 ) // line from 0.0 to 40,40 | ||
.quadraticCurveTo( 80, 0, 40, -40 ) // cubic to 40,-40 | ||
.lineTo( 40, 0 ) // line from 40,-40 to 40,0 | ||
.close(); // close with a line from 40,0 to 0,0 | ||
|
||
const content = new Path( shape, { | ||
fill: 'red', | ||
stroke: 'black', | ||
lineWidth: 2 | ||
} ); | ||
/*END*/ | ||
return content; | ||
} )(); | ||
scene.addChild( box ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createSandbox } from "/js/createSandbox.js"; | ||
|
||
createSandbox( "path-svg-example", ( scene, stepEmitter, display ) => { | ||
const box = ( () => { | ||
/*START*/ | ||
const shape = new Shape( 'M 0 0 L 40 40 Q 80 0 40 -40 L 40 0 L 0 0 Z' ); | ||
const content = new Path( shape, { | ||
fill: 'cyan', | ||
stroke: 'black', | ||
lineWidth: 2 | ||
} ); | ||
/*END*/ | ||
return content; | ||
} )(); | ||
scene.addChild( box ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createSandbox } from "/js/createSandbox.js"; | ||
|
||
createSandbox( "text-basic-example", ( scene, stepEmitter, display ) => { | ||
const box = ( () => { | ||
/*START*/ | ||
const content = new Text( 'Lauren Ipsum, daughter of Dolor Sit Amet', { | ||
fill: 'purple', | ||
font: 'bold 20px Arial' // any CSS font property is valid | ||
} ); | ||
/*END*/ | ||
return content; | ||
} )(); | ||
scene.addChild( box ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { createSandbox } from "/js/createSandbox.js"; | ||
|
||
createSandbox( "text-property-example", ( scene, stepEmitter, display ) => { | ||
const box = ( () => { | ||
/*START*/ | ||
const property = new StringProperty( 'Initial Text' ); | ||
const content = new Text( property, { | ||
fill: 'purple', | ||
|
||
// font properties can be specified independently | ||
fontFamily: 'serif', | ||
fontSize: 26, | ||
fontStyle: 'italic' | ||
} ); | ||
|
||
// change the text property | ||
property.value = 'Different, serif text'; | ||
/*END*/ | ||
return content; | ||
} )(); | ||
scene.addChild( box ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters