Using Storybook for Pixi.js graphics development

Overview

Storybook for Pixi.js

Using Storybook for Pixi.js graphics development

storybook-for-pixi

This project includes:

Background

Often conventions involve developing components in isolation and leveraging GUI frameworks such as dat.GUI for controls.

For projects of greater complexity there may be a need to classify numerous scenarios, which is the catalyst for this project.

Getting Started

Begin via any of the following:

  • Press the "Use this template" button

  • Use degit to execute:

    degit github:jasonsturges/storybook-for-pixi.js
    
  • Use GitHub CLI to execute:

    gh repo create 
         
           --template="https://github.com/jasonsturges/storybook-for-pixi.js"
    
         
  • Simply git clone, delete the existing .git folder, and then:

    git init
    git add -A
    git commit -m "Initial commit"
    

Install and run via npm (or yarn) by executing the storybook script:

npm install
npm run storybook

Usage

To create a story, add a new file under the "stories/" folder named " .stories.js "

Each story has a default export for navigation grouping and argument types:

export default {
  title: "Example/Squares",
  argTypes: {
    width: { control: "number" },
    height: { control: "number" },
    stroke: { control: "color" },
  },
};

In that story, create a template via the createScene() function and returning the canvas object:

const Template = (args) => {
  const { canvas, app, viewport } = createScene({
    width: args.width,
    height: args.height,
  });

  const graphics = new PIXI.Graphics();
  graphics.lineStyle(2, parseColor(args.stroke));
  graphics.drawRect(100, 100, 200, 200);
  viewport.addChild(graphics);

  return canvas;
};

Apply the template by passing default arguments:

export const Square1 = Template.bind({});
Square1.args = {
  width: 600,
  height: 400,
  stroke: "#ffffff",
};

export const Square2 = Template.bind({});
Square2.args = {
  width: 600,
  height: 400,
  stroke: "#ff00ff",
};

Result of this story will be:

storybook-squares

See more examples: Star, Burst, Gear

You might also like...

Dokka plugin to render Mermaid graphics, from your code comments to your Dokka documentation.

Dokka plugin to render Mermaid graphics, from your code comments to your Dokka documentation.

Html Mermaid Dokka plugin Mermaid-Dokka MermaidJS 0.2.2 8.14.0 0.3.0 9.0.0 Step 1: install dependencies { dokkaPlugin("com.glureau:html-mermaid-dokk

Sep 16, 2022

A first person character controller for the Three.js graphics library

charactercontroller A first person character controller for the Three.js graphics library Demo Installation npm install charactercontroller Usage impo

Aug 17, 2022

BonsaiJS is a graphics library and renderer

Bonsai (previously known as bikeshedjs) The art of bonsai tells a story through living illusion. A bonsai artist searches for ways to express his pers

Dec 21, 2022

A TypeScript implementation of High-Performance Polynomial Root Finding for Graphics (Yuksel 2022)

Nomial Nomial is a TypeScript implementation of Cem Yuksel's extremely fast, robust, and simple root finding algorithm presented in the paper "High-Pe

Aug 3, 2022

Dynamic-web-development - Dynamic web development used CSS and HTML

Dynamic-web-development - Dynamic web development used CSS and HTML

Dynamic-web-development ASSISNMENT I just used CSS and HTML to make a mobile int

Feb 8, 2022

The project integrates workflow engine, report engine and organization authority management background, which can be applied to the development of OA, HR, CRM, PM and other systems. With tlv8 IDE, business system development, testing and deployment can be realized quickly.

The project integrates workflow engine, report engine and organization authority management background, which can be applied to the development of OA, HR, CRM, PM and other systems. With tlv8 IDE, business system development, testing and deployment can be realized quickly.

介绍 项目集成了工作流引擎、报表引擎和组织机构权限管理后台,可以应用于OA、HR、CRM、PM等系统开发。配合使用tlv8 ide可以快速实现业务系统开发、测试、部署。 后台采用Spring MVC架构简单方便,前端使用流行的layui界面美观大方。 采用组件开发技术,提高系统的灵活性和可扩展性;采

Dec 27, 2022

AWS Serverless Event-driven Microservices with using AWS Lambda, AWS DynamoDB, AWS API Gateway, AWS EventBridge, AWS SQS, AWS CDK stands for Cloud Development Kit for IaC — Infrastructure as Code tool and AWS CloudWatch for monitoring.

AWS Serverless Event-driven Microservices with using AWS Lambda, AWS DynamoDB, AWS API Gateway, AWS EventBridge, AWS SQS, AWS CDK stands for Cloud Development Kit for IaC — Infrastructure as Code tool and AWS CloudWatch for monitoring.

Serverless Event-driven E-commerce Microservices UDEMY COURSE WITH DISCOUNTED - Step by Step Development of this Repository - https://www.udemy.com/c

Jan 3, 2023

Learn Web 2.0 and Web 3.0 Development using Next.js, Typescript, AWS CDK, AWS Serverless, Ethereum and AWS Aurora Serverless

Learn Web 2.0 Cloud and Web 3.0 Development in Baby Steps In this course repo we will learn Web 2.0 cloud development using the latest state of the ar

Jan 3, 2023

Forked from hayes0724/shopify-packer Modern development tool for Shopify using Webpack 5. Easy to extend and customize, zero build config, compatible with Slate and existing websites.

Forked from hayes0724/shopify-packer Modern development tool for Shopify using Webpack 5. Easy to extend and customize, zero build config, compatible with Slate and existing websites.

Shopify Packer Modern development tool for Shopify using Webpack 5. Easy to extend and customize, zero build config, comes with starter themes and com

Nov 24, 2022
Comments
  • Using loaders with story decorators

    Using loaders with story decorators

    Considering changing the pattern to experimental loaders.

    In preview.js, the loaders would define the exports, and decorators would enable auto resize:

    import { app, canvas, context, createScene, viewport } from "../stories/Scene";
    
    export const loaders = [
      async () => ({
        app: app,
        canvas: canvas,
        context: context,
        viewport: viewport,
      }),
    ];
    
    export const decorators = [
      (story) => {
        createScene({ width: window.innerWidth - 32, height: window.innerHeight - 36 });
        return story();
      },
    ];
    

    Scene.js basically remains the same, only instead of returning constants from createScene() they are exported - scene creation only needs to clear the viewport.

    For window resizing, add:

    window.addEventListener("resize", () => {
      resize(window.innerWidth - 32, window.innerHeight - 36);
    });
    

    Each <name>.stories.js then uses the loaded variable passed to args:

    export const Single = (args, { loaded: { app, canvas, viewport } }) => {
    };
    

    This seems good, as it eliminates the boilerplate of calling createScene() each template or story; however, it would enforce a consist pattern across all stories, which might be a good thing.

    enhancement 
    opened by jasonsturges 1
  • Add decorators for single canvas instantiation

    Add decorators for single canvas instantiation

    Between stories or args, the scene is fully reloaded - while this is ideal for certain situations, at other times having only a single instantiation would be preferred. It would certainly be lighter.

    This requires a few things:

    • Decorators to setup the initial canvas
    • Globals to access canvas, app, and viewport.
    • Events for story change, arg change

    Decorators

    For example, the .storybook/preview.js would need a decorator such as:

    addDecorator((story) => {
      const { canvas, app, viewport } = createScene({ width: 600, height: 400 });
      return canvas;
    });
    

    These would need exported, or available as globals

    Events

    Story change would require emptying the viewport.

    Callbacks for story and argument change, handling any additional lifecycle cleanup per story.

    enhancement help wanted 
    opened by jasonsturges 0
Releases(v1.1.1)
  • v1.1.1(Mar 11, 2022)

  • v1.1.0(Mar 8, 2022)

    Release notes

    • Static assets now served
    • Scene exports vs manual scene creation
    • Scene automatically resizes
    • Decorators create scene
    • Texture loader with async await for synchronous blocking
    • Global variable configuration
    • Improved documentation and usage examples
    • Additional example stories
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Mar 2, 2022)

Owner
Jason Sturges
Avant-garde experimental artist; technologist; musician; photographer; explorer; human consciousness
Jason Sturges
A various color Matrix filters and Presets for pixi.js

Pixi Color Effects A various color Matrix filters for pixi.js with TON of presets! DEMO Install # npm npm install pixi-color-effects # yarn yarn add

null 109 Nov 24, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A simple boilerplate using NextJS, Typescript, Tailwind, Jest, Storybook and more.

This is a Next.js boilerplate using TailwindCSS and other cool stuff. Most of this is taught in this course. What is inside? This project uses lot of

React Avançado 26 Dec 4, 2022
Storybook add-on to enable SWC builds.

storybook-addon-swc Storybook addon that improves build time by building with swc. ?? Examples webpack4 webpack5 ?? Installation $ npm install -D stor

Karibash 49 Dec 20, 2022
Use macro-based Nunjucks components with Eleventy and Storybook.

eleventy-nunjucks-storybook Use macro-based Nunjucks components with Eleventy and Storybook. Links See Using Storybook with Nunjucks components in Ele

Ashur Cabrera 11 Dec 15, 2022
wagmi hooks 🤝 Storybook interaction testing

A quick demonstration of how Storybook decorators can be combined with a mocked wagmi client to facilitate automated interaction testing for web3-enab

Mike Ryan 21 Dec 13, 2022
`raaghu-mfe` is an opensource micro front end framework built on top of `raaghu-elements`, Bootstrap 5 and Storybook offering highly customizable UI components and built-in pages

`raaghu-mfe` is an opensource micro front end framework built on top of `raaghu-elements`, Bootstrap 5 and Storybook offering highly customizable UI components and built-in pages. Raaghu mfe can be used as a base to build complex components and UI layouts whilst maintaining a high level of reusability,flexibility with ease of maintenance.

Wai Technologies 160 Dec 30, 2022
Storybook Addon Root Attributes to switch html, body or some element attributes (multiple) at runtime for you story

Storybook Addon Root Attributes What is this This project was inspired by le0pard/storybook-addon-root-attribute The existing library received only on

정현수 5 Sep 6, 2022
An indexed compendium of graphics programming papers, articles, blog posts, presentations, and more

Paper Bug CONTRIBUTIONS WANTED What is this? The idea is to have an annotated and easily searchable repository of papers, presentations, articles, etc

Jeremy Ong 64 Dec 16, 2022