Skip to content

Commit 89205a1

Browse files
committed
Generate guides html from md
1 parent b191473 commit 89205a1

20 files changed

Lines changed: 600 additions & 36 deletions

guide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,11 +934,11 @@ Here we add an object that conforms to the [IPlayer](https://ptsjs.org/docs/?p=T
934934
- `start` function is called when the space is ready. It includes 2 parameters: `bound` which returns the bounding box, and `space` which returns its space.
935935

936936

937-
- `animate` function is called continuously when the space plays. It includes 2 parameters: `time` which gives the current running time, and `ftime` which gives the time taken to draw the previous frame.
937+
* `animate` function is called continuously when the space plays. It includes 2 parameters: `time` which gives the current running time, and `ftime` which gives the time taken to draw the previous frame.
938938

939-
- `action` function is called when an user event is detected. It includes 4 parameters: `type` is a string that returns the action's name. ("up", "down", "move", "drag", "drop", "over", and "out"). `x` and `y` returns the position at which the action happened, and `event` returns the actual event object. See also: [`bindMouse`](https://ptsjs.org/docs.md#canvas-canvasspace)
939+
* `action` function is called when an user event is detected. It includes 4 parameters: `type` is a string that returns the action's name. ("up", "down", "move", "drag", "drop", "over", and "out"). `x` and `y` returns the position at which the action happened, and `event` returns the actual event object. See also: [`bindMouse`](https://ptsjs.org/docs.md#canvas-canvasspace)
940940

941-
- `resize` function is called when the space is resized. It includes 2 parameter: `size` which returns the new size, and event which returns the event object. You'll also need to add `{resize: true}` in [`setup`](https://ptsjs.org/docs.md#canvas-canvasspace) to enable tracking.
941+
* `resize` function is called when the space is resized. It includes 2 parameter: `size` which returns the new size, and event which returns the event object. You'll also need to add `{resize: true}` in [`setup`](https://ptsjs.org/docs.md#canvas-canvasspace) to enable tracking.
942942

943943
You may add multiple players into a space, each taking care of specific parts of a scene. Use [`add`](https://ptsjs.org/docs.md#canvas-canvasspace) and [`remove`](https://ptsjs.org/docs.md#canvas-canvasspace) to manage a space's players.
944944

@@ -1097,7 +1097,7 @@ The following demo shows 2 paragraphs with different line-height and alignments
10971097
10981098
##### You may combine `alignText` with `paragraphBox` too.
10991099

1100-
For long paragraphs, you may consider using [`fontWidthEstimate `](https://ptsjs.org/docs.md#canvas-canvasform). This will use a simple heuristic to estimate text width, which is less accurate but may be faster.
1100+
For long paragraphs, you may consider using [`fontWidthEstimate`](https://ptsjs.org/docs.md#canvas-canvasform). This will use a simple heuristic to estimate text width, which is less accurate but may be faster.
11011101

11021102
#### Considerations
11031103

guide/Animation-0700.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@ <h3>Cheat Sheet</h3>
121121
</script>
122122

123123
</body>
124-
</html>
124+
</html>

guide/Extensions-8000.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ <h3>Your Contribution</h3>
6868
</script>
6969

7070
</body>
71-
</html>
71+
</html>

guide/Get-started-0100.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,4 @@ <h3>Visibles from invisibles</h3>
178178
</script>
179179

180180
</body>
181-
</html>
181+
</html>

guide/Group-0300.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ <h3>Cheat sheet</h3>
131131
</script>
132132

133133
</body>
134-
</html>
134+
</html>

guide/Image-0900.html

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,18 @@ <h5>Applying transforms to the pattern. Hover to rotate the pattern.</h5>
9696
<p>It's now your turn to experiment!</p>
9797
<h3>Tips and Tricks</h3>
9898
<ul>
99-
<li><p>Anticipate screens with different pixel density. You can pass a CanvasSpace's <a href="https://ptsjs.org/docs/?p=Canvas_CanvasSpace#accessor_pixelScale"><code>pixelScale</code></a> when creating an Img instance. (See example in Cheatsheet below)</p></li>
100-
<li><p>You can <a href="#image-img"><code>load</code></a> an image from a base64 string or an url, or from a blob via the <a href="#image-img"><code>fromBlob</code></a> function. To export the current image, use <a href="#image-img"><code>toBase64</code></a> or <a href="#image-img"><code>toBlob</code></a> functions.</p></li>
101-
<li><p>CanvasForm's <a href="#canvas-canvasform"><code>image</code></a> drawing function can take either an Img instance or a <a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource">CanvasImageSource</a> which includes various kinds of image objects like HTML Image or Canvas.</p></li>
102-
<li><p>Typically, you can't load an image from another domain due to security concerns. But if the image server allows for it and you want to do it, you can set the <code>crossOrigin</code> parameter to <code>true</code> when creating an <code>Img</code> instance. <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image">More details here</a>.</p></li>
99+
<li>
100+
<p>Anticipate screens with different pixel density. You can pass a CanvasSpace's <a href="https://ptsjs.org/docs/?p=Canvas_CanvasSpace#accessor_pixelScale"><code>pixelScale</code></a> when creating an Img instance. (See example in Cheatsheet below)</p>
101+
</li>
102+
<li>
103+
<p>You can <a href="#image-img"><code>load</code></a> an image from a base64 string or an url, or from a blob via the <a href="#image-img"><code>fromBlob</code></a> function. To export the current image, use <a href="#image-img"><code>toBase64</code></a> or <a href="#image-img"><code>toBlob</code></a> functions.</p>
104+
</li>
105+
<li>
106+
<p>CanvasForm's <a href="#canvas-canvasform"><code>image</code></a> drawing function can take either an Img instance or a <a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource">CanvasImageSource</a> which includes various kinds of image objects like HTML Image or Canvas.</p>
107+
</li>
108+
<li>
109+
<p>Typically, you can't load an image from another domain due to security concerns. But if the image server allows for it and you want to do it, you can set the <code>crossOrigin</code> parameter to <code>true</code> when creating an <code>Img</code> instance. <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image">More details here</a>.</p>
110+
</li>
103111
</ul>
104112
<h3>Cheatsheet</h3>
105113
<p>Creating, loading, displaying</p>
@@ -174,4 +182,4 @@ <h3>Cheatsheet</h3>
174182
</script>
175183

176184
</body>
177-
</html>
185+
</html>

guide/Op-0400.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,4 @@ <h3>Cheat sheet</h3>
184184
</script>
185185

186186
</body>
187-
</html>
187+
</html>

guide/Pt-0200.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,4 @@ <h3>Cheat sheet</h3>
166166
</script>
167167

168168
</body>
169-
</html>
169+
</html>

guide/Sound-0800.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,4 @@ <h3>Cheatsheet</h3>
177177
</script>
178178

179179
</body>
180-
</html>
180+
</html>

guide/Space-0500.html

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ <h3>Players</h3>
5555
<li><code>start</code> function is called when the space is ready. It includes 2 parameters: <code>bound</code> which returns the bounding box, and <code>space</code> which returns its space.</li>
5656
</ul>
5757
<ul>
58-
<li><p><code>animate</code> function is called continuously when the space plays. It includes 2 parameters: <code>time</code> which gives the current running time, and <code>ftime</code> which gives the time taken to draw the previous frame.</p></li>
59-
<li><p><code>action</code> function is called when an user event is detected. It includes 4 parameters: <code>type</code> is a string that returns the action's name. (&quot;up&quot;, &quot;down&quot;, &quot;move&quot;, &quot;drag&quot;, &quot;drop&quot;, &quot;over&quot;, and &quot;out&quot;). <code>x</code> and <code>y</code> returns the position at which the action happened, and <code>event</code> returns the actual event object. See also: <a href="#canvas-canvasspace"><code>bindMouse</code></a></p></li>
60-
<li><p><code>resize</code> function is called when the space is resized. It includes 2 parameter: <code>size</code> which returns the new size, and event which returns the event object. You'll also need to add <code>{resize: true}</code> in <a href="#canvas-canvasspace"><code>setup</code></a> to enable tracking.</p></li>
58+
<li>
59+
<p><code>animate</code> function is called continuously when the space plays. It includes 2 parameters: <code>time</code> which gives the current running time, and <code>ftime</code> which gives the time taken to draw the previous frame.</p>
60+
</li>
61+
<li>
62+
<p><code>action</code> function is called when an user event is detected. It includes 4 parameters: <code>type</code> is a string that returns the action's name. (&quot;up&quot;, &quot;down&quot;, &quot;move&quot;, &quot;drag&quot;, &quot;drop&quot;, &quot;over&quot;, and &quot;out&quot;). <code>x</code> and <code>y</code> returns the position at which the action happened, and <code>event</code> returns the actual event object. See also: <a href="#canvas-canvasspace"><code>bindMouse</code></a></p>
63+
</li>
64+
<li>
65+
<p><code>resize</code> function is called when the space is resized. It includes 2 parameter: <code>size</code> which returns the new size, and event which returns the event object. You'll also need to add <code>{resize: true}</code> in <a href="#canvas-canvasspace"><code>setup</code></a> to enable tracking.</p>
66+
</li>
6167
</ul>
6268
<p>You may add multiple players into a space, each taking care of specific parts of a scene. Use <a href="#canvas-canvasspace"><code>add</code></a> and <a href="#canvas-canvasspace"><code>remove</code></a> to manage a space's players.</p>
6369
<h3>Animation and interaction</h3>
@@ -91,16 +97,16 @@ <h3>Form</h3>
9197
<h5>A demo of drawing different shapes</h5>
9298
<p>And since both Space and Form are javascript classes, you can extend them to override its functions and add new ones.</p>
9399
<h3>SVG Space</h3>
94-
<p>You can switch your code from <a href="#canvas-canvasspace"><code>CanvasSpace</code></a> to <a href="#svg-svgspace"><code>SVGSpace</code></a> without changing your drawing code: initiate the space as <code>SVGSpace</code> instead of <code>CanvasSpace</code>, and <code>space.getForm()</code> will return an <a href="#svg-svgform"><code>SVGForm</code></a>, which shares the complete <code>CanvasForm</code> drawing API &mdash; shapes, gradients, dashes, text and more render as svg automatically.</p>
100+
<p>You can switch your code from <a href="#canvas-canvasspace"><code>CanvasSpace</code></a> to <a href="#svg-svgspace"><code>SVGSpace</code></a> without changing your drawing code: initiate the space as <code>SVGSpace</code> instead of <code>CanvasSpace</code>, and <code>space.getForm()</code> will return an <a href="#svg-svgform"><code>SVGForm</code></a>, which shares the complete <code>CanvasForm</code> drawing API shapes, gradients, dashes, text and more render as svg automatically.</p>
95101
<pre><code>const space = new SVGSpace( &quot;#elem&quot; ).setup({ bgcolor: &quot;#123&quot;, resize: true });
96102
const form = space.getForm();
97103
// ... the same drawing code as canvas
98104
</code></pre>
99-
<p>If you use <a href="#play-quickstart"><code>quickStart</code></a>, it picks the space for you: mount on an <code>&lt;svg&gt;</code> element and you get an <code>SVGSpace</code>; mount on a <code>&lt;canvas&gt;</code> or <code>&lt;div&gt;</code> and you get a <code>CanvasSpace</code>. No other changes needed &mdash; a sketch written for canvas runs on svg as-is.</p>
100-
<p>Under the hood, consecutive shapes that share styles are merged into single svg elements per frame, so the output stays fast and compact. To export the current frame as an svg file, use <a href="#svg-svgspace"><code>SVGSpace.toSVG</code></a> &mdash; pass <code>true</code> to get one element per shape, which is easier to edit in vector graphics tools.</p>
101-
<p>(In earlier versions of Pts, SVG rendering required a <code>form.scope(this)</code> call in each animate callback. This is no longer needed &mdash; existing code that calls it will still run, as the function is kept as a harmless no-op.)</p>
105+
<p>If you use <a href="#play-quickstart"><code>quickStart</code></a>, it picks the space for you: mount on an <code>&lt;svg&gt;</code> element and you get an <code>SVGSpace</code>; mount on a <code>&lt;canvas&gt;</code> or <code>&lt;div&gt;</code> and you get a <code>CanvasSpace</code>. No other changes needed a sketch written for canvas runs on svg as-is.</p>
106+
<p>Under the hood, consecutive shapes that share styles are merged into single svg elements per frame, so the output stays fast and compact. To export the current frame as an svg file, use <a href="#svg-svgspace"><code>SVGSpace.toSVG</code></a> pass <code>true</code> to get one element per shape, which is easier to edit in vector graphics tools.</p>
107+
<p>(In earlier versions of Pts, SVG rendering required a <code>form.scope(this)</code> call in each animate callback. This is no longer needed existing code that calls it will still run, as the function is kept as a harmless no-op.)</p>
102108
<h3>HTML Space</h3>
103-
<p>There is also an <a href="#dom-htmlspace"><code>HTMLSpace</code></a> that renders forms in basic html elements. It is deprecated and will be removed in a future major version &mdash; use <a href="#svg-svgspace"><code>SVGSpace</code></a> for DOM-based output instead. Because of the limitations of HTML, it cannot draw polygon, arc, and some other shapes.</p>
109+
<p>There is also an <a href="#dom-htmlspace"><code>HTMLSpace</code></a> that renders forms in basic html elements. It is deprecated and will be removed in a future major version use <a href="#svg-svgspace"><code>SVGSpace</code></a> for DOM-based output instead. Because of the limitations of HTML, it cannot draw polygon, arc, and some other shapes.</p>
104110
<p>If you use Pts with React or other web rendering frameworks, it will be better to use the props and states of their virtual DOM implementations instead.</p>
105111
<h3>Cheat sheet</h3>
106112
<p>The quickest way to start is to use the <code>quickStart</code> function, which initiates a <a href="#canvas-canvasspace"><code>CanvasSpace</code></a> and adds <code>space</code> and <code>form</code> instances into current scope. You can create an interactive piece in 2 lines of code:</p>
@@ -144,4 +150,4 @@ <h3>Cheat sheet</h3>
144150
</script>
145151

146152
</body>
147-
</html>
153+
</html>

0 commit comments

Comments
 (0)