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

projection-layer

v0.1.0

Published

This vue component provides a layer that projects any coordinates into the real rendeirng viewbox of the canvas. It also provides a straight forward integration of panzoom.

Downloads

37

Readme

Projection Layer

This vue component provides a layer that projects any coordinates into the real rendeirng viewbox of the canvas. It also provides a straight forward integration of panzoom.

Example

<projection-layer :x="0" :y="0" :width="600" :height="400" panzoom>
  <template #canvas>
    <img src="this/image/is/400/with/and/600/height.png" style="height: 100%; width: 100%;" />
  </template>
  <template #matrix="{ compose, normalizeMatrixCoordinates }">
    <svg xmlns="http://www.w3.org/2000/svg">
      <!--
        This projects a rectangle at 10,10 width 100,100 size over the image.
      -->
      <rect :x="compose.x(10)" :y="compose.y(10)" :width="compose.size(100)" :height="compose.size(100)"/>
    </svg>
  </template>
</projection-layer>

Properties

  • width & height: Width & height of the projecting matrix. Shold be the same as the image you are projecting
  • x & y: X and Y offset of the projecting matrix (should be 0 in mos of the cases)
  • panzoom: Wether to init panzoom wheel events

Slots

Canvas

The canvas. The wrapping container of this slot will always have the aspect ratio of width / height, so the graphic within fill up 100% and 100% of it without offsets, otherwise the contenst within #matrix it will not be projedcted correctly.

Matrix

THis wraps the matrix projection and directly give access to compose and normalizeMatrixCoordinates

Variables

  • compose: x: Function that converts a x coordinate within the matrix to the "real" coordinate within the layer y: Function that converts a y coordinate within the matrix to the "real" coordinate within the layer size: Function that converts a size within the matrix to the "real" size within the layer
  • normalizeMatrixCoordinates: Accepts clientX and clientY coordinates and returns their matrix coordinates
    • Example: normalizeMatrixCoordinates(event.clientX, event.clientY)

Exposed

  • compose: x: Function that converts a x coordinate within the matrix to the "real" coordinate within the layer y: Function that converts a y coordinate within the matrix to the "real" coordinate within the layer size: Function that converts a size within the matrix to the "real" size within the layer

normalizeMatrixCoordinates():

Accepts clientX and clientY coordinates and returns their matrix coordinates

Example: normalizeMatrixCoordinates(event.clientX, event.clientY)

applyTransform()

Accepts x, y, scale, origin and anchor which scales and pans the canvas and the matrix. The origin is the origin within the main container while the anchor is the internal anchor point of the canvas.

Center the canvas at scale 2: applyTransform(0, 0, 2, [0.5, 0.5], [0.5, 0.5])

compose

Object that contains the compose functions.

  • x: Function that converts a x coordinate within the matrix to the "real" coordinate within the layer
  • y: Function that converts a y coordinate within the matrix to the "real" coordinate within the layer
  • size: Function that converts a size within the matrix to the "real" size within the layer