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

semtonotes-utils

v0.2.2

Published

Utility methods around SemToNotes

Downloads

24

Readme

SemToNotes Utils

Installation

Browser

webpack -p

Then include the built library in ./dist and semtonotes as window.xrx, either with the official release or a suitable version of semtonotes-client:

Versions compatibility table

| s…-utils | s…-client | |------------------ |---------------------- | | 0.2.1 to current | ^0.2.3 | | 0.0.1 — 0.2.0 | see peerDependencies |

Node.JS / CommonJS

npm install semtonotes-utils

Load in Browser

<!-- semtonotes must be loaded before, e.g.
<script src="https://unpkg.com/[email protected]"></script>
-->
<script src="path/to/xrx-utils.js"></script>

Or via unpkg's cdn:

<script src="https://unpkg.com/[email protected]"></script>
<script src="https://unpkg.com/[email protected]"></script>

Debugging

Set window.XRX_DEBUG = true before loading the library to see debug messages.

API

XrxUtils

applyStyle(shapes, styleDef)

Apply a set of styles to one or more stylable elements.

  • @param {Array|Shape-Like} shapes Stylable SemToNotes elements (shapes, groups...)
  • @param {object} styleDef is an object of key-value pairs which map to xrx.shape.Style methods
Example
xrxUtils.applyStyle(rect1, {fillColor: '#aa9900'})

createDrawing(elem, width, height)

Create a drawing in DOMElement elem. Overrides goog.style.getSize with width/height for non-visible elements.

createShape(shapeType, drawing, options)

Options:

  • @param string shapeType Shape Type, one of
    • Rectangle
    • Polygon
    • Circle
    • Ellipse
    • Line
    • Polyline
  • @param xrx.drawing.Drawing drawing the SemToNotes canvas to create the shape in
  • @param Object options Options that are interpreted as setter calls, c.f. applyStyle

drawFromSvg(svgString, drawing, options)

Translate svgString, a string containing SVG, to shapes and draw them in drawing.

  • @param string svgString SVG as a string
  • @param xrx.drawing.Drawing drawing the drawing to create the group in
  • @param Object options All options from shapesFromSvg.

svgFromShapes(shapes, options)

Generate SVG from a list of shapes or a shapeGroup.

  • @param {Shape|Array<Shape>|ShapeGroup} shapes
  • @param Object options
    • @param Object options.absolute Assume SVG coordinates to be equal to image dimensions. Default: false
    • @param Boolean options.scaleX Fixed scale factor to scale x-coordinates by. Calculated unless provided. Falls back to 1 if not possible (i.e. absolute coords)
    • @param Boolean options.scaleY Fixed scale factor to scale y-coordinates by. Falls back to scaleX.
    • @param Boolean options.svgWidth Provide the width of the SVG context to scale coordinates by.
    • @param Boolean options.svgWidth ditto height
    • @param Boolean options.imgWidth Override the width determined by the background image of the canvas.
    • @param Boolean options.imgWidth ditto height
    • @param Boolean options.skipHeight Whether height should not be stored in SVG

shapesFromSvg(svg, drawing, options)

Create a ShapeGroup from the rect/polygon of an SVG.

  • @param string svgString SVG as a string
  • @param xrx.drawing.Drawing drawing the drawing to create the group in
  • @param Object options
    • @param Boolean options.grouped Create a new ShapeGroup with the shapes. Default true
    • @param Boolean options.absolute Force absolute coordinates. Default: false
    • @param Boolean options.scaleX Fixed scale factor to scale x-coordinates by. Calculated unless provided. Falls back to 1 if not possible (i.e. absolute coords)
    • @param Boolean options.scaleY Fixed scale factor to scale y-coordinates by. Falls back to scaleX.
    • @param Boolean options.svgWidth Provide the width of the SVG context to scale coordinates by.
    • @param Boolean options.svgWidth ditto height
    • @param Boolean options.imgWidth Override the width determined by the background image of the canvas.
    • @param Boolean options.imgWidth ditto height
    • @returns xrx.shape.ShapeGroup

svgFromDrawing(drawing, options)

Generate SVG from all shapes in a drawing.

  • @param {Shape|Array<Shape>|ShapeGroup} shapes
  • @param Object options See svgFromShapes

navigationThumb(thumb, image, style={})

Show the viewbox of image as a rectangle in thumb

angleFromMatrix(m00, m01)

Calculate the angle between two matrices.

boundingBox(drawingOrGroupOrShape)

TODO groups

abs2rel(coords, absval)

coords is a list of float tuples. Multiply every float with 1000 and divide by absval

rel2abs(coords, val)

coords is a list of float tuples. Multiply every float with val and divide by 1000

isRectangle(c)

Determine whether an array of coordinates is a rectangle.

Authors