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

@forresto/svg-to-cnc

v0.0.2

Published

Compiles SVG shapes and transforms for CNC software down to basic paths. Each combination of stroke and fill becomes one path element. This makes it easier to attach them in CAM software (like Cricut Designer), and then set the tool for each layer.

Downloads

102

Readme

svg-to-cnc

Compiles SVG shapes and transforms for CNC software down to basic paths. Each combination of stroke and fill becomes one path element. This makes it easier to attach them in CAM software (like Cricut Designer), and then set the tool for each layer.

Demo, with SVG file input: https://observablehq.com/@forresto/svg-to-cnc

Features

  • Converts all shapes to paths
  • Bakes all nested transformations into the path
  • Removes grouping
  • Combines all paths with the same stroke/stroke-width/fill into one path

Why

Cricut's software chokes with some indeterminate combination of element count, groups, and transforms. Issues that I've noticed:

  • With ~100 groups of elements: "attach" action makes the app freeze
  • With many cut and draw elements: there is no way to maintain those on import(?), so it's a pain to select each one to set the pen color / tool
  • `transform="translate(-10, 0)"` switches x and y, moving elements up instead of left 😶
  • Some combination of `translate` and `scale` gets... lost... in translation 😏

Cricut's software and file format are closed-source, so I was losing hope that I could work with my generative designs. Then, I got this idea. It seems like it can handle small numbers of big paths. What if I brute-force the design down to one path per tool?

~~File size is much larger.~~ (Edit: fixed that with smarter flattening.) Cricut doesn't choke. Success! (Seems like they could make this an option when importing. 🤔)

Tested with a moderately complex SVG, and it's much easier to work with.

Cricut/SVG Tips

1 inch = 72px, so you can design with a function like this:

function inch (n) { return n * 72 };

inch(8.5); // 612
inch(2); // 144
inch(1/2); // 36
inch(1/4); // 18

If designing for a specific size paper, make registration marks in a color that you won't use. Make them 1/4 inch from each corner. This should make the output centered as you expect. When Cricut asks you to insert that color pen, press "Go" without a pen in the holder.

Set SVG width and height to inches, and viewBox to pixels:

<svg width="8.5in" height="11in" viewBox="0 0 612 792">

Todo

  • [x] Close circle, rect
  • [x] Support more shapes
  • [x] UI
  • [x] Be smarter about how to compile the paths 🤷‍♀️
  • [x] Fix `viewBox` breaks measuring
  • [ ] Fix unneeded penup / pendown (`M`)
  • [x] Option to not consolidate paths (only group by "tool")
  • [ ] Nix fills?