You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After the setup, create a `const` variable called `ARTICLE`, and in quotes, paste your article or text. If you want some sample text you can use text from this repo [here]().
204
+
After the setup, create a `const` variable called `ARTICLE`, and in quotes, paste your article or text. If you want some sample text you can use text from this repo [here](https://raw.githubusercontent.com/codedex-io/projects/main/projects/build-a-canvas-typography-layout-with-pretext/sample-article.txt).
205
205
206
206
Now, let's connect the JavaScript to the HTML elements we have:
207
207
@@ -258,11 +258,11 @@ let y = PADDING;
258
258
constlines= [];
259
259
260
260
while (true) {
261
-
letlineWidth=TEXT_WIDTH;
262
-
letxOffset =PADDING;
261
+
letleftCut=PADDING;
262
+
letrightCut =CANVAS_WIDTH-PADDING;
263
263
```
264
264
265
-
We'll then check if each line overlaps an image.
265
+
We track the left and right edges of the available text band separately so multiple images on the same line can each tighten one side without overwriting each other. We'll then check if each line overlaps an image.
266
266
267
267
```js
268
268
for (constobsof obstacles) {
@@ -274,21 +274,21 @@ We'll then check if each line overlaps an image.
274
274
constcanvasCenter=CANVAS_WIDTH/2;
275
275
```
276
276
277
-
For the following lines of code, we're asking to detect if the image is on the right to then shrink line width, and If image is on the left to push text to the right. Depending on your desired layout or behaviour you want to execute, this could change.
277
+
For the following lines of code, we're asking to detect if the image is on the right to then tighten the right edge, and if the image is on the left to push the left edge inward. Depending on your desired layout or behaviour you want to execute, this could change.
0 commit comments