-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathsimple_fbdev.js
More file actions
40 lines (26 loc) · 948 Bytes
/
simple_fbdev.js
File metadata and controls
40 lines (26 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env node
/**
* Module dependencies.
*/
const fs = require('fs')
const { join } = require('path')
const { backends: { FBDevBackend }, Canvas } = require('..')
const squareSize = 100
var device = process.argv[2]
var backend = new FBDevBackend(device)
var canvas = new Canvas(backend)
var ctx = canvas.getContext('2d')
var offsetX = canvas.width - squareSize
var offsetY = canvas.height - squareSize
ctx.fillStyle = '#FF0000'
ctx.fillRect(0, 0, squareSize, squareSize)
ctx.fillStyle = '#00FF00'
ctx.fillRect(offsetX, 0, squareSize, squareSize)
ctx.fillStyle = '#0000FF'
ctx.fillRect(0, offsetY, squareSize, squareSize)
ctx.fillStyle = '#FFFFFF'
ctx.fillRect(offsetX, offsetY, squareSize, squareSize)
console.log('Width: ' + canvas.width + ', Height: ' + canvas.height +
'Pixel format: ' + ctx.pixelFormat)
var outPath = join(__dirname, 'rectangle.png')
canvas.createPNGStream().pipe(fs.createWriteStream(outPath))