🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@armniko/canvas

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@armniko/canvas

Simplified and object-based drawing on HTML canvas!

npmnpm
Version
1.2.0
Version published
Weekly downloads
32
-39.62%
Maintainers
1
Weekly downloads
 
Created
Source

Canvas

Latest Release pipeline status coverage report

Simplified and object-based drawing on HTML canvas!

Installation

npm install @armniko/canvas

Usage

Create canvas with existing HTMLCanvasElement:

import { Canvas } from '@armniko/canvas';

// assuming that there is <canvas id="canvas"></canvas> in dom
const canvas: Canvas = new Canvas(document.getElementById('canvas'));

Create canvas without existing HTMLCanvasElement:

import { Canvas } from '@armniko/canvas';

const canvas: Canvas = new Canvas();
canvas.setSize({ width: 200, height: 100 });

// append canvas element to dom
document.body.appendChild(canvas.nativeElement());

Draw elements on canvas:

import { TextElement, PositionPoint } from '@armniko/canvas';

canvas.draw(
    new TextElement()
        .setText('Hello world!')
        .setFillColor('#ff0000')
        .setFontSize(20)
        .setPosition({ x: 100, y: 50 }, PositionPoint.Center)
);

Changelog

v1.2.0 Precompile UMD and ESM
v1.1.1 Bugfixes:
- missing ImageSource type
- no shadow for image element with border radius
v1.1.0 Features:
- added line element
- added gradient colors for usage as fill and border color for all elements
v1.0.0 - Initial version

Keywords

canvas

FAQs

Package last updated on 27 Apr 2024

Did you know?

Socket

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.

Install

Related posts