Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
test-gcanvas-node
Advanced tools
Dockerfile
FROM ubuntu:18.04
ADD ./sources.list /etc/apt/sources.list
RUN apt-get update && apt-get install -y libglfw3-dev libgles2-mesa-dev libboost-all-dev xvfb wget
ADD cmake.zip ./cmake/
RUN apt-get install -y zip && cd ./cmake/ && unzip cmake.zip
ENV PATH="/cmake/cmake/bin/:${PATH}"
RUN apt-get install -y curl && curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs
RUN export DISPLAY=':99.0' && Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
ADD ./freetype.tar ./freetype/
RUN cd ./freetype/freetype-2.8.1 && ./configure && make && make install
RUN npm config set registry https://registry.npm.taobao.org && npm install -g cmake-js
#install curl-dev lib
RUN apt-get install libcurl4-openssl-dev libjpeg-dev
node-canvas使用node-addon的binding的api以及使用cmake-js进行构建。
构建步骤如下
npm install cmake-js -g //安装cmake-js
local=true npm install // 安装项目所需要的依赖,local=true表示本地构建
npm run dev // 构建node-addon的binding中间键
运行步骤
case=app.js npm run test //运行example下的js文件,输出运行结果,可以从导出的png图片中看
case=app.js npm run test-headless//如果没有diplay(系统视窗)环境,可以运行这行
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
ctx.fillStyle = '#09F' // Make changes to the settings
ctx.fillRect(15, 15, 120, 120) // Draw a rectangle with new settings
ctx.save() // Save the current state
ctx.fillStyle = '#FFF' // Make changes to the settings
ctx.globalAlpha = 0.5
ctx.fillRect(30, 30, 90, 90) // Draw a rectangle with new settings
ctx.restore() // Restore previous state
ctx.fillRect(45, 45, 60, 60) // Draw a rectangle with restored settings
ctx.restore() // Restore original state
ctx.fillRect(60, 60, 30, 30) // Draw a rectangle with restored settings
canvas.createPNG("demo1")
width
height
fillStyle
font
globalAlpha
globalCompositeOperation
lineCap
lineDashOffset
lineJoin
lineWidth
miterLimit
shadowBlur
shadowColor
shadowOffsetX
shadowOffsetY
strokeStyle
textAlign
textBaseline
createCanvas(width: number, height: number) => Canvas
let canvas = createCanvas(400, 400);//
img.src: string
img.onload:Function
img.onerror:Function
const img = new Image()
img.onload = () => {
ctx.drawImage(img, 0, 0);
canvas.createPNG("demo2");
}
img.onerror = err => {
console.log(err)
}
img.src = 'https://alibaba.github.io/GCanvas/assets/logo-gcanvas.png'
const fs = require('fs')
const path = require('path')
const { createCanvas, Image } = require('bindings')('canvas');
const img = new Image()
const canvas = createCanvas(500, 500)
const ctx = canvas.getContext('2d')
img.onload = () => {
ctx.drawImage(img, 0, 0)
canvas.createPNG("local")
}
img.onerror = err => {
throw err
}
img.src = path.join(__dirname,'images', 'image.png')
createPNG(name:string) => void
let canvas = createCanvas(400, 400);
var ctx = canvas.getContext('2d');
ctx.fillStyle="#ff0000"
ctx.fillRect(0, 0, 150, 150)
canvas.createPNG("demo1") //生成一张png的图片
FAQs
gcanvas for node developer
We found that test-gcanvas-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.