Welcome to the g9 gallery! Drag all the graphics!
I've tried to organize stuff from basic to advanced, so you can scroll from the top to get an intuitive feel for g9. It's worth mentioning, of course, that intuitive feeling is no match for reading the docs.
Before you dive in, here's a brief explanation of how g9 works (scroll down to skip):
g9.js exposes a single function, g9(initialData, render[, onChange]). This represents the following flow:
var initialData = {
foo: 10
}
initialData in the docs
function render(data, ctx){
ctx.point(data.foo, 17)
}
render in the docs
For a complete treatment of the g9 API, head to the Docs.
A minimal example with only two points. Our render function always draws one point at (x, y), and the other point at (y, x), so when you drag one of the points, the other kind of mirrors it. Try adding a minus sign before the first argument of the first point. What happens?
Lets add a few more points and use a bit or trigonometry to arrange them into two circles. Just for fun, we make the inner points red. Try dragging the points!
All of the default shapes in g9 accept an affects option, which tells them what parts of the data they can change. Here are three lines with different values of affects.
Here's an interactive version of the quadratic bézier curve animation on the bézier curve wikipedia page.
Try dragging the hands!
Try uncommenting the animation block for extra fun!