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

gridgy-presets

v1.0.0

Published

Premade gridgy classes for common grid styles

Downloads

6

Readme

gridgy-presets

This contains some premade instances and creators for the Tesselation and Grid classes from gridgy.

Demo

Install

With npm installed, run

npm install gridgy-presets

UMD builds made with rollup are available in the dist directory.

Example

The example on the gridgy readme shows a simple case of using gridgy-presets. A more complete example is the demo and its JS source.

Here is another example that covers the tesselation override feature:

import {Tesselation} from "gridgy";
import {tessHexagonV, hexagonVCubic} from "gridgy-presets";

// A grid of square cells where every other row is offset by the width of half
// a cell. Topologically equivalent to tessHexagonV.
const tessHexagonVSquareCells = new Tesselation({
  periodMatrix: [1, 0, 0.5, 1],
  faceVerticesTable: tessHexagonV.getProps().faceVerticesTable,
  vertexCoordinatesTable: {
    "0": [0, 0],
    "1": [0, 1],
  },
});

const grid = hexagonVCubic({
  width: 3,
  heightTL: 3,
  heightBL: 3,
  tesselation: tessHexagonVSquareCells,
  origin: [50, 10],
  scale: 20,
});

// followed by use of the grid instance

API

gridgy-presets exports two categories of things: premade Tesselation instances, and functions creating Grid instances of a certain shape given a few dimensions. All of these exports are viewable in the demo. This API documentation mostly concerns itself with the features the demo does not cover.

The exported tesselations are

  • tessSquare
  • tessOctagon
  • tessSnubSquare
  • tessCairo
  • tessTriangleH
  • tessTriangleV
  • tessHexagonH
  • tessHexagonV

These are premade instances, not functions. As the example above demonstrates, gridgy makes it easy to create altered tesselation instances based on these in case that is what you need.

The exported Grid-creating functions, which map one-to-one with the items in the main dropdown on the demo page, are

You can see the code used to construct the appropriate Grid instance at the bottom left of the demo page. The demo page shows the keys used to specify the dimensions of the grid (which depends on what grid shape is being used), the origin key, and the scale key.

In addition to the dimensions, origin, and scale, there are many other keys supported on all of these functions, many of which come directly from the Grid constructor provided by gridgy. The full list of keys is:

  • <dimension>: The only required key(s). A required integer giving a size for one of the grid's dimensions. For example, width and height are required for square, and only length is required for triangleHDown. Please refer to the demo to see what dimensions are required for each grid.
  • tesselation: Used to override the default tesselation that this function uses. You need to make sure the Tesselation you provide mimics the structure of the default one, or things will go haywire.
  • exclude: An array of faces not to include in the grid, even if they would be included by default. Specify these in your custom key format, if any.
  • include: An array of extra faces to add to the grid. This takes precedence over exclude. Specify these in your custom key format, if any.
  • origin: Same as the origin property on the Grid constructor.
  • scale: Same as the scale property on the Grid constructor.
  • fromFaceTessKey: Same as the fromFaceTessKey property on the Grid constructor.
  • fromEdgeTessKey: Same as the fromEdgeTessKey property on the Grid constructor.
  • fromVertexTessKey: Same as the fromVertexTessKey property on the Grid constructor.
  • toFaceTessKey: Same as the toFaceTessKey property on the Grid constructor.
  • toEdgeTessKey: Same as the toEdgeTessKey property on the Grid constructor.
  • toVertexTessKey: Same as the toVertexTessKey property on the Grid constructor.
  • elToString: Same as the elToString property on the Grid constructor.

License

MIT