-
Notifications
You must be signed in to change notification settings - Fork 3
/
sample.js
40 lines (26 loc) · 739 Bytes
/
sample.js
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
"use strict";
const fs = require("fs");
const canvasRenderer = require("./index");
var canvas = canvasRenderer.createCanvas(100, 100);
canvas.backColor = "#00000000";
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#f00";
ctx.rotate(0.1);
ctx.beginPath();
ctx.lineTo(10, 10);
ctx.arc(50, 50, 30, -3 * Math.PI / 4, -1 * Math.PI / 4, true);
ctx.lineTo(90, 10);
ctx.closePath();
ctx.fill();
ctx.fillStyle = "#f00";
ctx.fillRect(80, 80, 20, 20);
ctx.translate(0, 5);
ctx.lineTo(90, 90);
ctx.lineTo(10, 90);
ctx.lineTo(10, 30);
ctx.fillStyle = "#0000ff";
ctx.fill();
ctx.clearRect(30, 30, 20, 20);
var testpng = fs.createWriteStream("test.png");
testpng.write(canvas.toPng({ "Software": "CanvasRenderer" }));
testpng.close();