You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
674 B

9 years ago
var fs = require('fs')
var path = require('path')
var Canvas = require('..')
9 years ago
var canvas = new Canvas(150, 150)
var ctx = canvas.getContext('2d')
ctx.fillStyle = '#FD0'
ctx.fillRect(0, 0, 75, 75)
ctx.fillStyle = '#6C0'
ctx.fillRect(75, 0, 75, 75)
ctx.fillStyle = '#09F)'
ctx.fillRect(0, 75, 75, 75)
ctx.fillStyle = '#F30'
ctx.fillRect(75, 75, 150, 150)
ctx.fillStyle = '#FFF'
// set transparency value
9 years ago
ctx.globalAlpha = 0.2
// Draw semi transparent circles
9 years ago
for (var i = 0; i < 7; i++) {
ctx.beginPath()
ctx.arc(75, 75, 10 + 10 * i, 0, Math.PI * 2, true)
ctx.fill()
}
9 years ago
canvas.createPNGStream().pipe(fs.createWriteStream(path.join(__dirname, 'globalAlpha.png')))