Skip to content

Commit a6ab082

Browse files
committed
Added explanation for example 4
1 parent dde5da5 commit a6ab082

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

examples/index.html

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ <h2>Example 2 - Bottom aligned</h2>
6666
<p>
6767
In this example, the text box is aligned to the bottom of the canvas, and <b>startX</b> and
6868
<b>startY</b> properties actually refer to the bottom left point of the text box:
69-
<ul>
70-
<li><b>startX</b> being the distance from the left side of the canvas</li>
71-
<li><b>startY</b> being the distance from the bottom side of the canvas</li>
72-
</ul>
7369
</p>
70+
<ul>
71+
<li><b>startX</b> being the distance from the left side of the canvas</li>
72+
<li><b>startY</b> being the distance from the bottom side of the canvas</li>
73+
</ul>
74+
7475
<pre><code class="language-javascript">
7576
let text = 'Lorem ipsum dolor sit amet, ...';
7677

@@ -128,7 +129,38 @@ <h2>Example 3 - Background under text</h2>
128129
</div>
129130
</section>
130131
<section class="example">
131-
<canvas id="example4-canvas" class="example-canvas" width="400" height="400"></canvas>
132+
<h2>Example 4 - Background under entire text box</h2>
133+
<div class="row">
134+
<div class="column">
135+
<canvas id="example4-canvas" class="example-canvas" width="400" height="400"></canvas>
136+
</div>
137+
<div class="column">
138+
<div class="example-description example1">
139+
<p>Same as in example 3 - only background cover entire text box. </p>
140+
<p>
141+
In addition to options introduced in the previous example, <b>fullWidthBackground</b> option
142+
is added and set to <b>true</b>.
143+
</p>
144+
<pre><code class="language-javascript">
145+
let text = 'Lorem ipsum dolor sit amet, ...';
146+
147+
let canvas4 = document.getElementById("example4-canvas");
148+
let options4 = {
149+
textFillStyle: '#000000',
150+
fontSize: 22,
151+
lineHeight: 26,
152+
width: 350,
153+
startX: 26,
154+
startY: 26,
155+
bottomAligned: true,
156+
useBackground: true,
157+
fullWidthBackground: true
158+
};
159+
canvasTextBox.draw(canvas4, text, options4);
160+
</code></pre>
161+
</div>
162+
</div>
163+
</div>
132164
</section>
133165
<section class="example">
134166
<canvas id="example5-canvas" class="example-canvas" width="400" height="400"></canvas>

0 commit comments

Comments
 (0)