Skip to content

Commit fcb4f83

Browse files
committed
add documentation of printToScreen()
1 parent b402f19 commit fcb4f83

5 files changed

Lines changed: 75 additions & 2 deletions

File tree

1.59 KB
Loading
30.6 KB
Loading

docs/reference/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ An offline version of this documentation is available for [download](https://l5l
135135
* [noCursor()](noCursor.md)
136136
* <s>[pixelDensity()](#)</s> (Not Implemented)
137137
* [print()](print.md)
138+
* [printToScreen()](printToScreen.md)
138139
* [width](width.md)
139140
* [windowResized()](windowResized.md)
140141
* [windowTitle()](windowTitle.md)

docs/reference/print.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Displays text in the command line console.
44

55
`print()` is helpful for printing values while debugging. Each call to `print()` creates a new line of text.
66

7-
Note: Call `print()` to print a blank line.
7+
To enable the output of print to display in the window, you can call `printToScreen()` in setup to turn this on.
8+
9+
Note: Call `print()` on its own to print a blank line.
810

911
## Examples
1012

@@ -32,12 +34,12 @@ print(contents)
3234

3335
## Related
3436

37+
* [printToScreen()](printToScreen.md)
3538
* [cursor()](cursor.md)
3639
* [deltaTime](deltaTime.md)
3740
* [describe()](describe.md)
3841
* [text()](text.md)
3942

40-
4143
---
4244

4345
*This reference page contains content adapted from [p5.js](https://p5js.org/) and [Processing](https://processing.org) by [p5.js Contributors](https://github.com/processing/p5.js?tab=readme-ov-file#contributors) and [Processing Foundation](https://processingfoundation.org/people), licensed under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/).*

docs/reference/printToScreen.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# printToScreen()
2+
3+
Displays `print()` text output in the running program window.
4+
5+
`printToScreen()` is a helper function to enable viewing `print()` output without requiring running L5 from the console or an IDE. This allows, for example, a program to be run simply by dragging its project folder onto the *Love application* file.
6+
7+
This works with `print()` to create values used while debugging. Each call to `print()` will produce a new line of text in the window.
8+
9+
By default the print size is 16 but a font size can optionally be specified as an argument to the function.
10+
11+
`printToScreen()` runs continuously overlaying on top of the drawn graphics. Calling `print()` within the `draw()` function will cause printed commands to scroll the text output continuously.
12+
13+
## Examples
14+
15+
![printToScreen example 1](assets/printToScreen1.webp)
16+
17+
```lua
18+
function setup()
19+
size(400, 400)
20+
21+
print('hello, world')
22+
23+
printToScreen()
24+
25+
describe("prints Hello, World to the screen and console.")
26+
end
27+
```
28+
29+
![printToScreen example 2](assets/printToScreen2.gif)
30+
31+
```lua
32+
function setup()
33+
size(400, 400)
34+
35+
printToScreen()
36+
37+
describe("prints the frameCount, increasing and scrolling the text output.")
38+
end
39+
40+
function draw()
41+
print(frameCount)
42+
end
43+
```
44+
45+
## Syntax
46+
47+
```lua
48+
printToScreen()
49+
```
50+
51+
```lua
52+
printToScreen(fontsize)
53+
```
54+
55+
## Parameters
56+
57+
| Parameter | |
58+
| - | -- |
59+
| fontsize | Number: Optional, size of font specified. |
60+
61+
62+
## Related
63+
64+
* [print()](print.md)
65+
* [frameCount](frameCount.md)
66+
* [describe()](describe.md)
67+
* [text()](text.md)
68+
69+
---
70+

0 commit comments

Comments
 (0)