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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aiwizo/image-annotation-canvas

v0.8.4

Published

**NOTE! v0.x.x-beta. Not production ready. Still needs testing and improvements.**

Downloads

36

Readme

Image Annotation Canvas

NOTE! v0.x.x-beta. Not production ready. Still needs testing and improvements.

React canvas component for image annotation.

Installation

npm install @aiwizo/image-annotation-canvas

Basic usage

import { useReducer } from 'react';
import ImageAnnotationCanvas, { reducer, initialState, actions } from '@aiwizo/image-annotation-canvas';

const [state, dispatch] = useReducer(reducer(initialState));

const canvasActions = actions(state,dispatch)

canvasActions.annotations.set([{coordinates: [{x: 0.1, y: 0.15}]}])

<ImageAnnotationCanvas
  imageSource="/some/url"
  state={state}
  dispatch={dispatch}
  completeAnnotationOn={(state) => { /* return a bool calculated from the state */ }}
  config={{
    minCoordinates: 3, // polygons have a minimum of 3 coordinates
    bbox: {
      display: true,
      lineDash: [], // html canvas line dash
      lineWidth: 3, // html canvas line width
    },
    polygon: {
      display: false,
      lineDash: [10], // html canvas line dash
      lineWidth: 10, // html canvas line width
    },
  }}
/>

Annotations

{
  // uuid
  id: '7772FF32-052F-4255-9210-E29C99AC3BA6',

  // Ordered array of coordinates {x,y}
  // Where x and y should be the relative
  // coordinates 0 < x, y < 1 of the image dimensions
  coordinates: [
    { x: 0.1, y: 0.3 },
    { x: 0.2, y: 0.35 },
  ];

  // Determines if the annotation should
  // be shown on the canvas
  // ture | false
  visible: true,
}

Coordinates

const coordinate = {
  // Relative x, between 0 and 1
  x: 0.2,
  // Relative y, between 0 and 1
  y: 0.3,
  // Some uuid
  id: "2DDA14BD-5394-4315-BC09-1AF2F64F88E3",
};

Canvas Actions

// Set the list of annotations in the
// canvas state
actions.annotations.set([
  {
    /* Annotation */
  },
]);
// Edit single annotation
actions.annotation.update({
  // Required for the update to work
  id,
  ...otherFields,
});
// Select one annotation for editing
actions.annotation.select(id);
// Delete one annotation
actions.annotation.delete(id);

Development

Run

npm run start

from root folder to start the storybook interface with the canvas component.

Storybook issues

Its not possible to run

npm install

from scratch due to some issue with storybook and React 17. A workaround is

npx sb@latest upgrade && npm i

Contribution

Please let us know if you have any issues. Put an issue here on github and we'll do our best to solve it.