Socket
Book a DemoInstallSign in
Socket

garevna-canvas

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

garevna-canvas

Images or texts are ‘assembled’ from pixels. When clicked, they are ‘scattered’ into pixels.

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
0
Created
Source

Canvas drawing

Images or texts are ‘assembled’ from pixels.

When clicked, they are ‘scattered’ into pixels.

👀 demo

Install package

yarn add garevna-package

Import package

import 'garevna-package'

Create and Config

const canvas = document.createElement('canvas-element')

If you do not configure the component, it will work with default settings.

You can set the colour of the backgound (transparent by default), for texts - font size and font family.

You can specify two texts, or two images, or one text and one image in the settings, so that when you click, one text is replaced by the other.

☕ For example, two texts:

canvas.options = {
  startWith: {
    type: 'text',
    src: '✈'
  },
  switchTo: {
    type: 'text',
    src: '❤'
  },
  fontSize: 90,
  fontFamily: 'Verdana, Geneva, Sans-Serif',
  background: 'transparent'
}

document.body.appendChild(canvas)

☕ Image and text:

const { image } = require('./configs').default

const canvas = document.createElement('canvas-element')

canvas.options = {
  startWith: {
    type: 'image',
    src: image
  },
  switchTo: {
    type: 'text',
    src: 'JS'
  },
  fontSize: 90,
  fontFamily: 'Verdana, Geneva, Sans-Serif',
  background: 'transparent'
}

document.body.appendChild(canvas)

⚠️ The image should be in base64 format (data:image/png;base64,...)

You can convert your image to base64 format online.

Keywords

canvas

FAQs

Package last updated on 12 Sep 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