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

pretty-grid

v0.0.16

Published

Grid creation and manipulation made pretty.

Downloads

25

Readme

Pretty Grid

intro

Create and manipulate grids using javascript.

Documentation

Setup and documentation at the prety-grid docsite

Quick install

Browser

<script src="https://cdn.jsdelivr.net/npm/pretty-grid"></script>

Node

npm install pretty-grid

Introduction

Creating and manipulating a grid layout on an x-y-z plane requires repetative code involving nested for loops and n-d arrays. pretty-grid makes this process more straight-forward, readable and versatile.

Using pretty-grid, this simplifies to:

import { createGrid } from "pretty-grid";

const grid = createGrid({cols: 5, rows: 8, width: 1920, height: 1080});

for 3-Dimensional grid, use the createGrid3d method

import { createGrid3D } from "pretty-grid";

const grid = createGrid3D({cols: 3, rows: 5, layers: 8, width: 300, height: 500, depth: 800});

Using a couple of pretty-grid's helper methods you can already create a complex looking grid layout in only a few lines of code:

import {Grid, and, oddRows, oddCols, evenRows} from 'pretty-grid'
// Grid (cols, rows, width, height)
const grid = new Grid(20, 10, 500, 500);
grid.every(point => whiteDot(point.x, point.y));
grid.every(point => orangeCircle(point.x, point.y), and(oddRows(), oddCols()));
grid.translate(10,10)
    .every(point => blueDot(point.x, point.y), evenRows());
...

.

This results in:

intro

To make this example unopinionated, we illustrate this example using the whiteDot, orangeCircle and blueDot pseudo methods to draw a grid on an html canvas. You as the developer, implement your own functions to draw to your target of choice. I use the amazing p5.js library for most of my examples.

The full documentation can be found here

Examples

These editable code examples are created using p5.js editor. Feel free to use pretty-grid in combination with other js (drawing) libraries. The full p5.js editor collection can be found here.

Contributing

The goal of pretty-grid is to make grid drawing easier for everybody. If you have a suggestion about the docs, API, tutorials or somethıng else, please post it in one of the folowing ways:

  • Open an issue on GitHub and tag it with the green "Suggestion" label