npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

garea.js

v1.0.3

Published

A simple selection of area in JavaScript

Readme

A simple selection of area in JavaScript

Version Project Size Dependencies Licence

Table of contents

Main


dist/
├── garea.min.js    (UMD)
├── garea.common.js (CommonJS, default)
└── garea.esm.js    (ES Module)

Getting started


Installation

npm install garea.js

or

yarn add garea.js

In browser:

<script src="garea.min.js"></script>

Usage

Syntax

new Core(idCanvas);

Example

<div style="position: relative">
    <img id="image" src="image.jpg" alt="image">
    <canvas id="crop" width="600" height="400"></canvas>
</div>
#image {
    width: 600px;
    height: 400px;
    user-select: none;
    position: absolute;
}

#crop {
    z-index: 9;
    position: absolute;
}

With js example:

import { Core as Manager } from 'garea.js';

const manager = new Manager('crop');
manager.addDraw('area');
const area = manager.getDraw('area');
area.onListener('onchange', points => {
    console.log(points);
});
manager.setEdit('area');
manager.create();

Options


You may set garea options with crop.addDraw(name, config). If you want to change the global default options, You may use draw.config = config.

Exemple:

const crop = new Core('crop');
crop.addDraw('area', {
    radius: 6,
    margin: 20,
    stroke: 5,
    type: 'area'
});

radius

  • Type: Number
  • Default: 5

Description: Size of the points that will be created.

margin

  • Type: Number
  • Default: 30

Description: Starting margin of points if not entered.

stroke

  • Type: Number
  • Default: 30

Description: Size of the connecting line between the points.

type

  • Type: String
  • Default: area
  • Options:
    • 'area'
    • 'line'

Methods


Methods for core

addDraw(name, config): void

Add a new draw

  • name
    • Type: String
  • config
    • Type: Object
const crop = new Core('crop');
crop.addDraw('area', {});

getDraw(name): Draw

Get draw by name.

  • name
    • Type: String
const crop = new Core('crop');
crop.addDraw('area', {});
const area = crop.getDraw('area');

removeDraw(name): void

Remove draw by name.

  • name
    • Type: String
const crop = new Core('crop');
crop.addDraw('area', {});
crop.removeDraw('area');

setEdit(name): void

Set area for edit layer

  • name
    • Type: String
const crop = new Core('crop');
crop.addDraw('area', {});
crop.setEdit('area');

Methods for draw

getName(): string

Return name for area.

const area = crop.getDraw('area');
area.getName(); // return 'area'

setColor(key, value): Draw

Change color

  • key:
    • Type: String'
    • Options:
      • 'area'
      • 'points'
      • 'stroke'
      • 'background'
  • value
    • Type: String
const area = crop.getDraw('area');
area.setColor('area', 'rgba(47, 175, 255, .5)');

setConfig(key, value): Draw

Set config for area.

  • key
    • Type: Object
    • Options:
      • 'radius'
      • 'margin'
      • 'stroke'
  • value
    • Type: Number
const area = crop.getDraw('area');
area.setConfig('radius', 6);

setDisable(state): Draw

Set disable draggable area.

  • state
    • Type: Boolean
const area = crop.getDraw('area');
area.setDisable(true);

isDisabled(): boolean

Return state draggable of area.

const area = crop.getDraw('area');
area.isDisable(); // default false

getPoints(): Array

Return points for area.

const area = crop.getDraw('area');
area.getPoints(); // return [{ x, y }]

setPoints(points): Draw

Set points for area;

  • points
    • Type: Array
const area = crop.getDraw('area');
area.setPoints([{ x, y }]);

Events


onListener(event, callback)

Listen to the actions of the area.

const area = crop.getDraw('area');
area.onListener('onchange', () => {});
  • events:
    • Type: String'
    • Options:
      • 'onchange': when the value of some of the points changes
      • 'onmousedown': when you click on one of the points
      • 'onmouseup': when you release the clicked point

Development

License


MIT © Giovane Santos