0.0.98 • Published 2 months ago

@shopify/klint v0.0.98

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Klint

A modern creative coding library for React applications that provides an intuitive interface to HTML Canvas 2D rendering. Klint simplifies the process of creating interactive graphics, animations, and visualizations.

Features

  • React integration with hooks and components
  • Intuitive drawing API inspired by Processing and P5.js
  • Responsive canvas that automatically resizes
  • Support for animations, static renderings, and interactive content
  • Built-in utilities for managing state, input, and resources

Example

import { Klint, useKlint, type KlintContext } from "klint";

function AnimatedCircle() {
  const { context } = useKlint();

  const draw = (K: KlintContext) => {
    K.background("#222");
    K.fillColor("red");
    
    // Draw a pulsing circle at the center of the canvas
    const size = 50 + Math.sin(K.frame * 0.05) * 25;
    K.circle(K.width/2, K.height/2, size);
  };
  
  return <Klint context={context} draw={draw} />;
}

Release Process

This package uses GitHub Actions for automated releases. Here's how to create a new release:

Development and tests

Important: The Klint library isn't public yet, so you'll need to link it manually if you want to edit it.

  1. Clone the repository

    git clone https://github.com/Shopify/klint.git
    cd klint
  2. Go to the lib folder and link it locally

    cd lib
    npm link
  3. In your working directory, link to the local Klint

    cd your-project
    npm link klint
  4. Run the dev server:

    npm run dev
  5. When finished, unlink both in your project and the local repo

    # In your project
    npm unlink klint
    
    # In the Klint lib folder
    npm unlink
  6. If you change anything in the library, you will need to rebuild

    # In the Klint lib folder
    npm build
    npm link
  7. I use Vitest for testing

    npm test
  8. Push your commit

Made with love at Shopify, 2025

0.0.98

2 months ago

0.0.97

2 months ago

0.0.96

2 months ago

0.0.93

2 months ago

0.0.92

2 months ago

0.0.91

3 months ago

0.0.9

3 months ago

0.0.8

3 months ago

0.0.7

3 months ago

0.0.6

3 months ago

0.0.4

3 months ago