import { Text } from 'modern-text'
const text = new Text({
style: {
width: 100,
height: 200,
fontSize: 22,
textDecoration: 'underline',
},
// content: 'paragraph'
// content: [
// 'paragraph1',
// ['paragraph1', 'paragraph2'],
// { content: 'paragraph2', fontSize: 20 },
// [
// { content: 'fragment1', fontSize: 12 },
// { content: 'fragment2', fontSize: 30 },
// ],
// {
// backgroundColor: 'blue',
// fragments: [
// { content: 'fragment3', color: 'red', fontSize: 12 },
// { content: 'fragment4', color: 'black' },
// ],
// },
// ]
content: [
{
letterSpacing: 3,
fragments: [
{ content: 'He', color: 'red', fontSize: 12 },
{ content: 'llo', color: 'black' },
],
},
{ content: ', ', color: 'grey' },
{ content: 'World!', color: 'black' },
],
})
const view = document.createElement('canvas')
text.render({ view })
document.body.append(view) // canvas 2d
console.log(text.measure()) // boundingBox with computed paragraphs
generated from qq15725/starter-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
đ A text renderer. supports measureăspecial effectsădeformationăhighlight etc.
License
qq15725/modern-text
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
 |  | |||
Repository files navigation
About
đ A text renderer. supports measureăspecial effectsădeformationăhighlight etc.
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published