extend-canvas

1.0.4 • Public • Published

NPM

ExtendCanvas

Add some useful methods on CanvasRenderingContext2D.prototype

features

  • toLines: make long text to lines
  • wrapText: this method extend fillText,when fixed width it’ll automatic wrap text

example

warpText

import extCanvas from 'extend-canvas'
extCanvas()
 
let longText = 'this is long long long long long text'
let canvas = document.createElement('canvas')
canvas.width = 750
canvas.height = 1334
let context = canvas.getContext('2d')
context.fillStyle = '#000'
context.font = '48px PingFang SC'
context.textBaseline = 'hanging'
context.wrapText(longText, 79, 264, 592, 72)

Readme

Keywords

Package Sidebar

Install

npm i extend-canvas

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

4.07 kB

Total Files

3

Last publish

Collaborators

  • calvinlee