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

@damsenviet/acpatterns

v1.0.0

Published

A JavaScript library for interacting with Animal Crossing pattern data structures and files.

Downloads

5

Readme

acpatterns-js

A JavaScript programming library to edit and preview Animal Crossing pattern files.

Based on our internal library at https://github.com/Thulinma/ACNLPatternTool/.

Table of Contents

Installation

To install and use the library please choose one of the installation methods listed below. Please note that babylonjs, the rendering engine is required to use the modeler.

  1. NPM
# core library
npm install @damsenviet/acpatterns
# if you need the modeler
npm install babylonjs@">=4.1.0" babylonjs-loaders@">=4.1.0"
  1. YARN
# core library
yarn add @damsenviet/acpatterns
# if you need the modeler
yarn add babylonjs@">=4.1.0" babylonjs-loaders@">=4.1.0"
  1. CDN
<!-- if you need the modeler -->
<script src="https://unpkg.com/babylonjs@^4.1.0/babylon.js"></script>
<script src="https://unpkg.com/babylonjs-loaders@^4.1.0/babylonjs.loaders.min.js"></script>
<!-- core library -->
<script src="https://unpkg.com/@damsenviet/acpatterns"></script>

Quick Start

To manipulate the pattern via UI, initiate a pattern instance and link it to a Drawer. Make the drawer draw the tool indicators and the grid, and then set the drawer's tool. The following will render the content of the patterns as their texture representation and allow you to draw on the canvas.

<!-- canvas width and height must be equal and a multiple of 128 -->
<!-- width and height attribute sets up coordinate space -->
<canvas class="drawer" width="640" height="640"></canvas>
<style>
    /* make the browser scale the canvas width and height instead */
    /* maintain same width/height ratio to prevent stretching */
    .drawer {
        width: 300px;
        height: 300px;
    }
</style>

Assuming you have the following HTML content, you can link a pattern to a Drawer in this quick start guide like so:

ES Modules

import {
  formats,
  Drawer,
  tools,
} from "@damsenviet/acpatterns";

// need reference to the canvas
const drawerCanvas = document.querySelector(".drawer");

// make last color in palette black
const acnl = new formats.Acnl();
acnl.palette[acnl.palette.length - 1] = acnl.constructor.nearestColorInColorSpace("black");

// make pen use last color in the palette
const pen = new tools.Pen({ size: 1 });
pen.paletteIndex = acnl.palette.length - 1;

// make the drawer draw the texture representation of the pattern
const drawer = new Drawer({
  canvas: drawerCanvas,
  pattern: acnl,
});
drawer.source = acnl.sections.texture;
drawer.grid = true;
drawer.indicator = true;
drawer.tool = pen;

Script

<script>
  const drawerCanvas = document.querySelector(".drawer");

  // make last color in palette black
  const acnl = new acpatterns.formats.Acnl();
  acnl.palette[acnl.palette.length - 1] = acnl.constructor.nearestColorInColorSpace("black");

  // make pen use last color in the palette
  const pen = new acpatterns.tools.Pen({ size: 1 });
  pen.paletteIndex = acnl.palette.length - 1;

  // make the drawer draw the texture representation of the pattern
  const drawer = new acpatterns.Drawer({
    canvas: drawerCanvas,
    pattern: acnl,
  });
  drawer.source = acnl.sections.texture;
  drawer.grid = true;
  drawer.indicator = true;
  drawer.tool = pen;
</script>

Documentation

To view documentation, examples, or a playground demo, visit the documentation site.

Contributors

Thanks goes out to my acpatterns team for contributing solutions to this library.