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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tscircuit/rectdiff

v0.0.6

Published

This is a 3D rectangle diffing algorithm made to quickly break apart a circuit board into capacity nodes for the purpose of global routing.

Readme

@tscircuit/rectdiff

This is a 3D rectangle diffing algorithm made to quickly break apart a circuit board into capacity nodes for the purpose of global routing.

Online Demo

Usage

Basic Usage

import { RectDiffSolver } from "@tscircuit/rectdiff"
import type { SimpleRouteJson } from "@tscircuit/rectdiff"

// Define your circuit board layout
const simpleRouteJson: SimpleRouteJson = {
  bounds: {
    minX: 0,
    maxX: 10,
    minY: 0,
    maxY: 10,
  },
  obstacles: [
    {
      type: "rect",
      layers: ["top"],
      center: { x: 2.5, y: 2.5 },
      width: 2,
      height: 2,
      connectedTo: [],
    },
  ],
  connections: [],
  layerCount: 2,
  minTraceWidth: 0.15,
}

// Create and run the solver
const solver = new RectDiffSolver({
  simpleRouteJson,
  mode: "grid",
})

solver.solve()

// Get the capacity mesh nodes
const output = solver.getOutput()
console.log(`Generated ${output.meshNodes.length} capacity mesh nodes`)

// Each mesh node contains:
// - center: { x, y } - center point of the node
// - width, height - dimensions
// - availableZ - array of available z-layers (e.g., [0, 1, 2])

Advanced Configuration with Grid Options

const solver = new RectDiffSolver({
  simpleRouteJson,
  mode: "grid",
  gridOptions: {
    minSingle: { width: 0.4, height: 0.4 },
    minMulti: { width: 1.0, height: 1.0, minLayers: 2 },
    preferMultiLayer: true,
  },
})

solver.solve()

Incremental Solving with Visualization

The solver supports incremental solving for visualization and progress tracking:

const solver = new RectDiffSolver({ simpleRouteJson })

solver.setup()

// Step through the algorithm incrementally
while (!solver.solved) {
  solver.step()

  // Get current progress
  const progress = solver.computeProgress()
  console.log(`Progress: ${(progress * 100).toFixed(1)}%`)

  // Visualize current state
  const graphicsObject = solver.visualize()
  // Use graphicsObject with graphics-debug package
}

const output = solver.getOutput()

Working with Results

const output = solver.getOutput()

// Iterate through mesh nodes
for (const node of output.meshNodes) {
  console.log(`Node at (${node.center.x}, ${node.center.y})`)
  console.log(`  Size: ${node.width} x ${node.height}`)
  console.log(`  Available layers: ${node.availableZ?.join(", ") || "none"}`)

  // Use node for routing decisions
  if (node.availableZ && node.availableZ.length >= 2) {
    console.log("  This node spans multiple layers!")
  }
}

API Reference

Constructor Options

  • simpleRouteJson (required): The circuit board layout definition

    • bounds: Board boundaries (minX, maxX, minY, maxY)
    • obstacles: Array of rectangular obstacles on the board
    • connections: Connection requirements between points
    • layerCount: Number of layers in the board
    • minTraceWidth: Minimum trace width for routing
  • mode: "grid" | "exact" (default: "grid")

    • Currently only "grid" mode is implemented
  • gridOptions: Fine-tune the grid-based expansion algorithm

    • minSingle: Minimum dimensions for single-layer nodes
    • minMulti: Minimum dimensions and layer count for multi-layer nodes
    • preferMultiLayer: Whether to prefer multi-layer spanning nodes

Methods

  • setup(): Initialize the solver
  • step(): Execute one iteration step
  • solve(): Run solver to completion
  • computeProgress(): Get current progress (0.0 to 1.0)
  • getOutput(): Get the capacity mesh nodes result
  • visualize(): Get GraphicsObject for visualization with graphics-debug