Skip to content

Commit e9744f5

Browse files
committed
Readme: add instructions for writing text to canvas
1 parent 1a5bbbb commit e9744f5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,20 @@ Sample music configuration:
247247

248248
For details on how this section is processed further you can check out `nin/dasBoot/BEATBEAN.js`.
249249

250+
### Text
251+
252+
How to write text, or letters in general, to your 2D canvas.
253+
254+
Out of the box you can write text to your canvas like this:
255+
256+
```js
257+
this.canvas.getContext('2d').fillStyle = '#ffffff'; // The color of the text you are going to be displaying
258+
this.canvas.getContext('2d').font = 'bold ' + (24) + 'pt Arial'; // Pattern: weight [size]size_unit font_name
259+
this.canvas.getContext('2d').textAlign = 'center';
260+
this.canvas.getContext('2d').textBaseline = 'middle';
261+
this.canvas.getContext('2d').fillText('Hello Nin!', x_position_on_canvas, y_position_on_canvas);
262+
```
263+
250264
## Linting
251265

252266
The frontend part of this project uses ESLint for linting.

0 commit comments

Comments
 (0)