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

pcb-trace-animation

v1.0.1

Published

A library for generating PCB-like line patterns on an HTML5 canvas.

Downloads

17

Readme

Library that allows generating random line patterns that simulate PCB traces, generating an animation from the center of an integrated circuit. Implementation example: Portafolio Jackestar

Usage

import PCBMaker from 'pcb-trace-animation';

const canvas = document.querySelector("canvas.headerCanvas");
const pcbMaker = new PCBMaker(canvas, "AutoRightBottom");
pcbMaker.generatePCB();

Constructor

constructor(canvas, location = "Center")

Parameters

  • canvas: HTMLCanvasElement - The canvas element where the PCB will be drawn.
  • location: string - The position of the object on the canvas. Possible values:
    • "Center"
    • "HalfLeft"
    • "HalfRight"
    • "HalfTop"
    • "HalfBottom"
    • "AutoRightBottom"
    • "AutoLeftTop"
    • "HalfRightBottom"
    • "HalfLeftTop"
    • "Custom"

Properties

  • canvas: HTMLCanvasElement - The canvas object.
  • location: string - The position of the object on the canvas.
  • color: string - color: string - The color of the traces. Default value: "#000".
  • autoResize: boolean - Automatic resizing when the canvas size changes. Default value: true.
  • autoFitSizes: boolean - Automatically generate sizes. Default value: true.
  • squareSize: number - Square size (when autoFitSizes is disabled). Default value: 0.
  • lineSpeed: number - Line speed. Default value: 4.
  • lineSpacing: number - Spacing between IC lines (when autoFitSizes is disabled). Default
  • minLength: number - Minimum trace length before changing direction or ending. Default
  • lineWidth: number - Line width (when autoFitSizes is disabled). Default value: 3.
  • endCoefficient: number - endCoefficient: number - End probability. Default value: 0.005.
  • CustomPosX: number - Custom X position (when location is "Custom"). Default value: 0.
  • CustomPosY: number - Custom Y position (when location is "Custom"). Default value: 0.

Position

The center where the animation is generated is defined by the location property. The initial value is "Center", which places the animation in the center of the canvas. The options "Half*" place the center on the edge of the canvas, showing half of the animation, and the "Auto**" properties place the animation according to the width or height of the canvas. "Half**" does the same as "Half*" and "Auto*" combined. The "Custom" option allows the user to adjust the animation center with the CustomPosX and CustomPosY properties.

  • "Center"
  • "HalfLeft"
  • "HalfRight"
  • "HalfTop"
  • "HalfBottom"
  • "AutoRightBottom"
  • "AutoLeftTop"
  • "HalfRightBottom"
  • "HalfLeftTop"
  • "Custom"

Methods

generatePCB() Generate animation

stopPCB() Stop animation


const canvas = document.querySelector("canvas");
const pcbMaker = new PCBMaker(canvas, "AutoRightBottom");

// Configure optional properties
pcbMaker.color = "#ff0000";
pcbMaker.lineSpeed = 5;

// Generate PCB
pcbMaker.generatePCB();

// Stop PCB when necessary
// pcbMaker.stopPCB();

TODO

  • Generate only PCB without animation
  • Fix collisions
  • Generate multiple chips on a single canvas
  • minify