Skip to content

allow newline to have a parameter #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: source-3.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions content/5-shape-elements/default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -788,16 +788,18 @@ tspan.length()

`returns` __`itself`__

The `newLine()` is a convenience method for adding a new line with a `dy` attribute using the current "leading":
The `newLine()` is a convenience method for adding a new line with a `dy` attribute using the current "leading". By default
it moves to the start of the next line before rendering the `tspan`. You can pass it a factor to change this: passing `2`
moves down 2 lines, and passing `1.5` moves down by 1½ lines.

```javascript
var text = draw.text(function(add) {
add.tspan('Lorem ipsum dolor sit amet ').newLine()
add.tspan('consectetur').fill('#f06')
add.tspan('.')
add.tspan('Cras sodales imperdiet auctor.').newLine().dx(20)
add.tspan('Cras sodales imperdiet auctor.').newLine(2).dx(20)
add.tspan('Nunc ultrices lectus at erat').newLine()
add.tspan('dictum pharetra elementum ante').newLine()
add.tspan('dictum pharetra elementum ante').newLine(1.5)
})
```

Expand Down