GithubHelp home page GithubHelp logo

g2-1's Introduction

License npm npm no dependencies

g2

g2 is a 2D graphics javascript library based on the command pattern principle. Its main goal is to provide a simple API for users who want to generate 2D web graphics occasionally. So the API is minimal and easy to understand. The library is tiny, fast and renderer agnostic.

Main features

  • Fast and lightweight graphics command queue builder.
  • Adressing HTML canvas 2D context as the default renderer.
  • Generating SVG output using an addon library.
  • Method chaining.
  • Support of cartesian coordinates.
  • Viewport pan and zoom transformations.
  • Low level path commands with short names adopted from SVG.
  • Higher level element commands.
  • Maintaining a state stack for styling and transformations.
  • Easy way to build custom symbol libraries.
  • Tiny footprint by 5kB compressed (gzip).
  • No dependency.

Minimal Example

<canvas id="c" width="200", height="100"></canvas>
<script src="g2.js"></script>
<script>
    g2().rec(40,30,120,40,{ls:"green",fs:"orange",lw:3})  // create g2 object and add rectangle with style.
        .exe(document.getElementById("c").getContext("2d"));  // draw to canvas.
</script>

first

Documentation

API Reference

See the API Reference for details.

GitCDN

Use the link https://gitcdn.xyz/repo/goessner/g2/master/g2.min.js for getting the latest commit as a raw file.

In HTML use ...

<script src="https://gitcdn.xyz/repo/goessner/g2/master/g2.min.js"></script>

Cheat Sheet

Check out the single page Cheat Sheet.

License

g2 is licensed under the terms of the MIT License.

#Change Log

2.2.5 - 2016-08-04

Added

  • earc elliptical arc command added.

2.2.4 - 2016-07-01

Modified

  • use command execution simplified.
  • styling bug with g2.prototype.use removed.
  • internal g2.prototype.addCmd simplified.

2.2.0 - 2016-06-20

Added

  • g2.spline performing 'centripetal Catmull-Rom' interpolation.

Modified

  • experimental g2.State.hatch fill style removed.
  • g2.prototype.ply.iteratordefault iterators modified for improved efficiency and working also with splines.

2.1.1 - 2016-05-15

Modified

  • g2.cor.js + g2.c2d.js => g2.js (reunited).
  • g2.context namespace introduced.

2.1.0 - 2016-01-17

Added

  • style argument for elements lin,rec,cir,arc,ply.
  • style as first argument for stroke,fill and drw, optionally followed by a svg path definition string.

Changed

  • State stack reimplemented.

1.1.0 - 2016-01-08

Added

CHANGELOG.md @goessner.

g2-1's People

Contributors

cd avatar goessner 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.