How to use the createCanvas function from bindings

Find comprehensive JavaScript bindings.createCanvas code examples handpicked from public code repositorys.

49
50
51
52
53
54
55
56
57
58

### 快速上手
``` javascript
  
const { createCanvas, Image } = require('bindings')('canvas');
const canvas = createCanvas(400, 400);
const ctx = canvas.getContext('2d')

ctx.fillRect(0, 0, 150, 150) // Draw a rectangle with default settings
ctx.save() // Save the default state
fork icon209
star icon153
watch icon5

+ 9 other calls in file

11
12
13
14
15
16
17
18
19
20
module.exports = {
    createCanvas: createCanvasInner,
    Image: Image,
}
function createCanvasInner(width, height) {
    let canvas = createCanvas(width, height);
    Object.defineProperty(canvas, 'createPNGStream', {
        value: function (options) {
            return new PNGStream(canvas, options);
        }
fork icon209
star icon153
watch icon5

220
221
222
223
224
225
226
227
228
229
##### createPNG
 ```javascript
   createPNG(name:string) => void
 ```  
  ```javascript
   let canvas = createCanvas(400, 400);
  var ctx = canvas.getContext('2d');
  ctx.fillStyle="#ff0000"
   ctx.fillRect(0, 0, 150, 150) 
   canvas.createPNG("demo1") //生成一张png的图片
fork icon209
star icon153
watch icon5

+ 17 other calls in file

Other functions in bindings

Sorted by popularity

function icon

bindings.createKey is the most popular function in bindings (8616 examples)