Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@antv/g-canvas
Advanced tools
@antv/g-canvas is a 2D rendering engine for AntV, a suite of data visualization solutions. It provides a high-performance canvas rendering environment for creating complex visualizations and graphics.
Basic Shape Drawing
This feature allows you to draw basic shapes like circles, rectangles, and lines on the canvas.
const { Canvas } = require('@antv/g-canvas');
const canvas = new Canvas({ container: 'container', width: 600, height: 400 });
const circle = canvas.addShape('circle', { attrs: { x: 100, y: 100, r: 50, fill: 'red' } });
Event Handling
This feature enables event handling for shapes, allowing you to add interactivity to your graphics.
circle.on('click', () => { console.log('Circle clicked!'); });
Animation
This feature allows you to animate properties of shapes, making your visualizations more dynamic.
circle.animate({ r: 100 }, { duration: 1000, easing: 'easeLinear' });
Fabric.js is a powerful and simple JavaScript HTML5 canvas library. It provides an interactive object model on top of the canvas element, making it easy to create complex shapes, animations, and interactions. Compared to @antv/g-canvas, Fabric.js offers a more extensive set of features for object manipulation and interaction.
Konva is a 2D canvas library for creating desktop and mobile applications. It provides a high-level API for working with shapes, layers, and animations. Konva is similar to @antv/g-canvas in terms of performance and ease of use but offers additional features like layer management and pixel-level hit detection.
Paper.js is an open-source vector graphics scripting framework that runs on top of the HTML5 Canvas. It offers a clean Scene Graph/Document Object Model and a well-designed, consistent API. Paper.js is more focused on vector graphics and provides advanced features like boolean operations on paths, which are not available in @antv/g-canvas.
English | 简体中文
$ npm install @antv/g-canvas --save
<div id="c1"></div>
import { Canvas } from '@antv/g-canvas';
const canvas = new Canvas({
container: 'c1',
width: 500,
height: 500,
});
const group = canvas.addGroup();
group.addShape('circle', {
attrs: {
x: 100,
y: 100,
r: 50,
fill: 'red',
stroke: 'blue',
lineWidth: 5,
},
});
FAQs
A renderer implemented by Canvas 2D API
The npm package @antv/g-canvas receives a total of 165,115 weekly downloads. As such, @antv/g-canvas popularity was classified as popular.
We found that @antv/g-canvas demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 66 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.