BonsaiJS is a graphics library and renderer

Overview

Bonsai

(previously known as bikeshedjs)

The art of bonsai tells a story through living illusion. A bonsai artist searches for ways to express his personal creativity by mixing form and thought in a miniature world. [source]

Introduction

Bonsai is a JavaScript graphics library. For the finer details, see the documentation (currently in construction).

Bonsai's main features include:

  • Architecturally separated runner and renderer
  • iFrame, Worker and Node running contexts
  • Shapes
  • Paths
  • Assets (Videos, Images, Fonts, SubMovies)
  • Keyframe and regular animation (easing functions too)
  • Shape/path morphing
  • and much more...

An example

Draw a 100x200 rectangle to the stage at {0,0}:

var r = new Rect(0, 0, 100, 200).addTo(stage);

Fill it:

r.fill('red');

Change your mind... make it darker:

r.fill( color('red').darker() );

Animate it:

r.animate('400ms', {
  x: 50,
  y: 50,
  width: 200
});

See more here: Bonsai Documentation/Overviews or join the IRC channel #bonsaijs on freenode and ask for help.

Comments
  • Alternative method signature for `new Matrix()`

    Alternative method signature for `new Matrix()`

    I am reading attributes from an SVG string and passing it to the Bonsai runner.

    With the relevant attribute for a Matrix from an svg node being transform='matrix(0,1,0,0,1,1)' I thought it may be useful to others to have this alternative method signature.

    var matrix = new Matrix('matrix(0,1,0,0,1,1)'
    

    Thoughts?

    opened by iamdustan 22
  • Making callbacks consistent

    Making callbacks consistent

    These commits fix the callback ambiguity we had across the project. All callbacks are now using the single-callback pattern used in node.js:

    foo(function(err, data) {
      if (err) // error
      else // success
    });
    

    In addition the argument patterns used in Movie, Video, Bitmap and FontFamily have now been aligned. A convenience callback argument can be used (with the above pattern) or you can simply bind to the load and success events:

    new Bitmap(url).on('load', function(){ ... });
    

    Before, this might not have worked if the bitmap loaded immediately from cache. The load event would be fired before instantiation completed, meaning that listening for it after that would be pointless.

    But now, using a new asyncEmit method on the EventEmitter, we now trigger these events asynchronously. I'm not sure if we want there to be a method especially for this or if we should inline the setTimeout in relevant places. Up for discussion on that.

    opened by padolsey 21
  • Run jasmine tests in the console.

    Run jasmine tests in the console.

    Add phantomjs+jasmine console test runner with a new make command make test-local to run tests quickly in the browser without the need for uxebu's CI integration.

    This would solve the issue of #77 with allowing any commiter to run tests locally.

    opened by iamdustan 17
  • stroke-dasharray attribute on paths

    stroke-dasharray attribute on paths

    I’ve started work on #134 to implement the stroke-dasharray attribute. (docs: https://developer.mozilla.org/en-US/docs/SVG/Attribute/stroke-dasharray)

    I believe everything should be set on the runner side of things, but I’m looking for some pointers on where to go in the renderer/svg/ files to implement the receiving side of things and what the easiest way to visually and jasmine-y test it.

    opened by iamdustan 16
  • getComputed() wrong with negative values

    getComputed() wrong with negative values

    The following

    var rect = new Rect(100, 100, -100, -100)
      .attr({fillColor: 'red'})
      .addTo(stage);
    
    console.log(rect.attr('x'));
    console.log(rect.attr('y'));
    console.log(rect.getComputed('width'));
    console.log(rect.getComputed('height'));
    

    prints four times, 100, though x+y should be 0

    bug 
    opened by wolframkriesing 16
  • getComputed

    getComputed

    I was missing a method to get the bounding box of a DisplayObject. I saw that we're supporting getComputed instead, which has a even richer API and can return e.g. the "right" or "bottom" offset. But it still doesn't return the bounding box, which is supposed to return an object like {x, y, width, height}. @davidaurelio proposed a new paramater box that can be passed to getComputed. I would love to field 2 other parameter names. See the list. Would do you like best?

    • getComputed('box')
    • getComputed('bbox')
    • getComputed('boundingbox')
    opened by basecode 15
  • tools.parseUnitString and tools.parseAngle

    tools.parseUnitString and tools.parseAngle

    Building upon these previous conversations, here are some converting methods to start accepting angles in any format throughout the project.

    https://github.com/uxebu/bonsai/pull/142#issuecomment-9942288 https://github.com/uxebu/bonsai/pull/165#issuecomment-10999392

    +@basecode

    opened by iamdustan 12
  • Pass Node ID string to run().

    Pass Node ID string to run().

    Thought this would be an easy one to tackle and start looking into some more of the code.

    The tests with funcSetup are definitely a lot harder to follow. I had to change the check to a string from an !(node instanceof Node) since the tests createMockNode function returns a simple object.

    opened by iamdustan 10
  • getScaleX/getScaleY return 1 if scale is applied through a matrix

    getScaleX/getScaleY return 1 if scale is applied through a matrix

    First issue, assigning a scale via the matrix attribute, then getting the scale doesn’t return the applied scale.

    myDisplayObject.attr('matrix', new Matrix(0.5, 0, 0, 0.5, 0 0));
    `myDisplayObject.attr('scaleX')` // returns 1. Expects 0.5
    

    Additionally

    myDisplayObject.attr('scaleX', 0.5); // if applying a scale without using the matrix setters causes all future calls to setMatrix do nothing
    myDisplayObject.attr('matrix', new Matrix(1, 0, 0, 1, 0, 0));
    

    Is this expected?

    bug 
    opened by iamdustan 8
  • getBoundingBox improvements

    getBoundingBox improvements

    What was previously the getComputed method is now getBoundingBox.

    It takes on optional argument, a Matrix instance which will be used to apply transforms to the calculated bounding-box.

    var shape = new Rect(50, 50, 100, 100);
    
    // No transform applied, -- it'll return the bounding-box
    // within shape's own coordinate system:
    shape.getBoundingBox(); // ~ 0,0,100,100
    
    // Apply shape's own matrix to the calculation
    // (gives position in outer coordinate system):
    shape.getBoundingBox( shape.attr('matrix') ); // ~ 50,50,100,100
    

    getBoundingBox always returns an object in the form:

    {
      top: n,
      left: n,
      width: n,
      height: n,
      bottom: n,
      right: n
    }
    

    Included in this pull request is also an algorithm to determine the correct extrema of cubic bezier curves. Checkout the branch and open the bounding-box.js example to see a demonstration of the new getBoundingBox calculation.

    opened by padolsey 6
  • Cleanup KeyframeAnimation class

    Cleanup KeyframeAnimation class

    • options.delay is not supported
    • setSubjects/setSubject could be removed
    • keyframes in seconds seems a little bit confusing
    var rect = new Rect(0, 0, 200, 200).fill('green').addTo(stage);
    var anim = new KeyframeAnimation('1s', {
      '5s': { x: 500 }
    });
    rect.animate(anim);
    
    opened by basecode 6
  • all demos fail

    all demos fail

    I went to your demo page: https://demos.bonsaijs.org/demos/rainbow/index.html and none of those demos would be loading.

    I found out that you're loading from the wrong URL: https://cloud.github.com/downloads/uxebu/bonsai/bonsai-0.4.0.min.js

    Cheers, Janos

    opened by jvinceller 1
  • Renders wrong after `clone()`, with a `rotation` attr

    Renders wrong after `clone()`, with a `rotation` attr

    The following example should render the same shape in both pieces of code. Unfortunately the second one screws up the matrix.

    var rect = new Rect(100, 100, 100, 100).attr({fillColor: 'red', rotation: 0.78, scaleY: 2});
    rect
      .addTo(stage);
    
    // renders different to
    
    var rect = new Rect(100, 100, 100, 100).attr({fillColor: 'red', rotation: 0.78, scaleY: 2});
    rect
      .clone({attributes: true})
      .addTo(stage);
    

    A workaround (as long as there is no fix) is to duplicate the matrix too. Like so:

    var rect = new Rect(100, 100, 100, 100).attr({fillColor: 'red', rotation: 0.78, scaleY: 2});
    rect
      .clone({attributes: true})
      .attr({matrix: rect.attr().matrix}) // this is the workaround, remove it and it renders wrong
      .addTo(stage);
    
    bug workaround provided 
    opened by wolframkriesing 0
  • Layering Tests No. 2 and 3 fail

    Layering Tests No. 2 and 3 fail

    The layering test on orbit.bonsaijs.org contains three tests, of which the last two fail:

    Test no. 2 expects that the orange box should appear below the red and blue box but the orange box appears on top of the blue and the red box.

    Test no. 3 expects that the blue square appears below the red one after one second but the blue square appears immediately on top of the red square.

    Tested in Chrome (48.0) and Firefox (44.0).

    opened by SuzanaK 1
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

Malted 10 Aug 17, 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
Using Storybook for Pixi.js graphics development

Storybook for Pixi.js Using Storybook for Pixi.js graphics development This project includes: Storybook Pixi.js Pixi Viiewport Background Often conven

Jason Sturges 5 Mar 9, 2022
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

Grégory Lureau 23 Sep 16, 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

Peter Boyer 10 Aug 3, 2022
AweSome Book App displays the book details entered by user and saves the information in Local storage. User can add and remove a book title/author to the library and from the library.

Awesome Book App with ES6 Used npm init -y command to create package.json file. Created the entry point for the JavaScript code called index.js Create

Krishna Prasad Acharya 8 Aug 15, 2022
this project is an online library application that enables users to keep track of books in their library by adding to and removing books from a list. Built with JavaScript ES6 syntax, HTML, and CSS

Awesome-Book1 The aim of this project is to restructure the Awesome books app code by using ES6 syntax and organising the workspace using modules. The

Afolabi Akorede 7 Jul 17, 2022
A JavaScript library built on top of the Faker.JS library. It generates massive amounts of fake data in the browser and node.js.

Blaver - generate massive amounts of fake data in the browser and node.js Blaver is a JavaScript library built on top of the Faker.JS library. It gene

Priyansh 113 Dec 30, 2022
LiveTabs is a Javascript library that allows you to create and manage tabs on the fly. This library gives the ability to your application to act like browser tabs, making dynamic tabs.

LiveTabs Table of content Description Goals Technologies Setup Description LiveTabs is a Javascript library that allows you to create and manage tabs

Hossein Khalili 3 May 3, 2022
It's an alert library build with JavaScript. You can replace your traditional JavaScript alert, confirm and toast with the library.

asteroid-alert It's an alert library build with JavaScript. You can replace your traditional JavaScript alert, confirm with the library. It has also e

Khan Md Sagar 4 Mar 12, 2021
Reference for How to Write an Open Source JavaScript Library - https://egghead.io/series/how-to-write-an-open-source-javascript-library

Reference for How to Write an Open Source JavaScript Library The purpose of this document is to serve as a reference for: How to Write an Open Source

Sarbbottam Bandyopadhyay 175 Dec 24, 2022
A small javascript DOM manipulation library based on Jquery's syntax. Acts as a small utility library with the most common functions.

Quantdom JS Quantdom is a very small (about 600 bytes when ran through terser & gzipped) dom danipulation library that uuses a Jquery like syntax and

Sean McQuaid 7 Aug 16, 2022
This package will help parse OData strings (only the Microsoft Dataverse subset). It can be used as a validator, or you can build some javascript library which consumes the output of this library.

@albanian-xrm/dataverse-odata This package will help parse OData strings (only the Microsoft Dataverse subset). It can be used as a validator, or you

AlbanianXrm 3 Oct 22, 2022
Tiny JavaScript library (1kB) by CurrencyRate.today, providing simple way and advanced number, money and currency formatting and removes all formatting/cruft and returns the raw float value.

Zero dependency tiny JavaScript library (1kB bytes) by CurrencyRate.today, providing simple way and advanced number, money and currency formatting and removes all formatting/cruft and returns the raw float value.

Yurii De 11 Nov 8, 2022
AppRun is a JavaScript library for developing high-performance and reliable web applications using the elm inspired architecture, events and components.

AppRun AppRun is a JavaScript library for building reliable, high-performance web applications using the Elm-inspired architecture, events, and compon

Yiyi Sun 1.1k Dec 20, 2022
A free e-library for developer to read and upload ebooks they would like to share with the community and help other developers grow.

Techlib ?? Techlib A free e-library for developer to read and upload ebooks they would like to share with the community and help other developers grow

Paschal 20 Dec 15, 2022
Lucid is a library, which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript and Node.js.

Lucid is a library, which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript and Node.js.

Berry 243 Jan 8, 2023
Yet another library for generating NFT artwork, uploading NFT assets and metadata to IPFS, deploying NFT smart contracts, and minting NFT collections

eznft Yet another library for generating NFT artwork, uploading NFT assets and metadata to IPFS, deploying NFT smart contracts, and minting NFT collec

null 3 Sep 21, 2022
A library management system that built with JavaScript, HTML, and CSS. Allows the user to add new books and delete books.

Awesome books: with ES6 in this project: Set up the linters for html, css, and JavaScript. Create a popup window for desktop and mobile. Built With Ht

IBRAHIM AHMAT 7 Dec 18, 2022