Giter Site home page Giter Site logo

puddi_hello_world's Introduction

puddi

Puddi is a browser 2D graphics library providing a thin layer of object-oriented abstractions over HTML5 Canvas.

Live demo.

Example project using an earlier version of puddi.

Type 'make' in the scripts directory to build dist/bundle.js.

Core puddi files

scripts/puddi/puddi.js

This file contains the core graphics runtime. An instance of the runtime is represented by a Puddi object. Every Puddi object is associated with exactly one canvas element.

Puddi maintains a list of root objects (those with no parents), and is responsible for regularly invoking their update and draw methods (if available). It does so by hooking into the browser's render loop.

Some important functions:

  • The Puddi object constructor. Takes a canvas element as the only argument.
  • run() - start the update/render loop.
  • stop() - stop the loop

scripts/puddi/puddiobject.js

Base "class" prototype for all objects managed by Puddi. Every object has position, rotation, and scale fields, accessible via an assortment of getters and setters. Private fields and methods should typically not be touched.

An object may also have children objects. Updates/renders are propagated to children (the runtime only has to deal with root objects) and the childrens' transformations (position, rotation, scale) are defined relative to their parent's model coordinate system.

Use the setUpdate and setDraw methods to define the behavior and graphical appearance of an object. The update method should have a single parameter for the number of milliseconds elapsed since the last frame. The draw method should have a single parameter for the canvas context object.

*** Warning: do NOT override the update and draw methods directly.

Example files

scripts/triangle.js

A prototype pre-equipped with a draw function for equilateral triangles.

scripts/square.js

A prototype pre-equipped with a draw function for squares.

puddi_hello_world's People

Contributors

bagnalla avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.