Skip to content

Commit 5e04594

Browse files
committed
Merge pull request #15 from goessner/g2-2
G2 2
2 parents 4f959c2 + 15c2c1e commit 5e04594

24 files changed

+279
-1506
lines changed

CHANGELOG.md

-23
This file was deleted.

README.md

+38-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# g2
1+
# g<sup>2</sup>
22

3-
_g2_ is a 2D graphics javascript library based on the [command pattern](http://addyosmani.com/resources/essentialjsdesignpatterns/book/#commandpatternjavascript)
3+
g<sup>2</sup> is a 2D graphics javascript library based on the [command pattern](http://addyosmani.com/resources/essentialjsdesignpatterns/book/#commandpatternjavascript)
44
principle. Its main goal is to provide a simple API for users who want to generate 2D web graphics occasionally.
55
So the API is minimal and easy to understand. The library is tiny, fast and renderer agnostic.
66

@@ -42,8 +42,44 @@ So the API is minimal and easy to understand. The library is tiny, fast and rend
4242
* [Animation](../../wiki/animation)
4343
* [Interactivity](../../wiki/interactivity)
4444

45+
4546
## API Reference
4647
See the [API Reference](api/README.md) for details.
4748

49+
4850
## Cheat Sheet
4951
Check out the single page [Cheat Sheet](api/sheet.pdf).
52+
53+
54+
# License
55+
g<sup>2</sup> is licensed under the terms of the MIT License.
56+
57+
58+
#Change Log
59+
60+
## 2.1.1 - 2016-05-15
61+
62+
### Modified
63+
64+
* `g2.cor.js` + `g2.c2d.js` => `g2.js` (reunited).
65+
* `g2.context` namespace introduced.
66+
67+
## 2.1.0 - 2016-01-17
68+
69+
### Added
70+
71+
* `style` argument for elements `lin`,`rec`,`cir`,`arc`,`ply`.
72+
* `style` as first argument for `stroke`,`fill` and `drw`, optionally followed by a svg path definition string.
73+
74+
### Changed
75+
76+
* State stack reimplemented.
77+
78+
79+
## 1.1.0 - 2016-01-08
80+
81+
### Added
82+
83+
CHANGELOG.md @goessner.
84+
85+

api/README.md

+31-31
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ Create a queue of 2D graphics commands.
5050
* [.dump([space])](#g2+dump) ⇒ <code>string</code>
5151
* _static_
5252
* [.symbol](#g2.symbol) : <code>object</code>
53-
* [.version](#g2.version) : <code>string</code>
53+
* [.transparent](#g2.transparent) : <code>string</code>
5454

5555
<a name="g2+cartesian"></a>
5656
### g2.cartesian([on]) ⇒ <code>object</code>
57-
Set the view's cartesian mode flag.[Example](https://goessner.github.io/g2-svg/test/index.html#cartesian)
57+
Set the view's cartesian mode flag (immediate state modifier - no command).<br>[Example](https://goessner.github.io/g2-svg/test/index.html#cartesian)
5858

5959
**Kind**: instance method of <code>[g2](#g2)</code>
6060
**Returns**: <code>object</code> - g2
@@ -65,7 +65,7 @@ Set the view's cartesian mode flag.[Example](https://goessner.github.io/g2-svg/
6565

6666
<a name="g2+pan"></a>
6767
### g2.pan(dx, dy) ⇒ <code>object</code>
68-
Pan the view by a relative displacement vector.[Example](https://goessner.github.io/g2-svg/test/index.html#pan)
68+
Pan the view by a relative displacement vector (immediate state modifier - no command).<br>[Example](https://goessner.github.io/g2-svg/test/index.html#pan)
6969

7070
**Kind**: instance method of <code>[g2](#g2)</code>
7171
**Returns**: <code>object</code> - g2
@@ -77,7 +77,7 @@ Pan the view by a relative displacement vector.[Example](https://goessner.githu
7777

7878
<a name="g2+zoom"></a>
7979
### g2.zoom(scl, [x], [y]) ⇒ <code>object</code>
80-
Zoom the view by a scaling factor with respect to center.[Example](https://goessner.github.io/g2-svg/test/index.html#zoom)Scaling is performed relative to current scale.
80+
Zoom the view by a scaling factor with respect to center (immediate state modifier - no command).<br>Scaling is performed relative to current scale.<br>[Example](https://goessner.github.io/g2-svg/test/index.html#zoom)
8181

8282
**Kind**: instance method of <code>[g2](#g2)</code>
8383
**Returns**: <code>object</code> - g2
@@ -90,7 +90,7 @@ Zoom the view by a scaling factor with respect to center.[Example](https://goes
9090

9191
<a name="g2+view"></a>
9292
### g2.view([x], [y], [scl]) ⇒ <code>object</code>
93-
Set the view by absolute origin coordinates and scaling factor in device units.[Example](https://goessner.github.io/g2-svg/test/index.html#view)Cartesian flag is not affected.
93+
Set the view by placing origin coordinates and scaling factor in device units. Cartesian flag is not affected (immediate state modifier - no command).<br>[Example](https://goessner.github.io/g2-svg/test/index.html#view)
9494

9595
**Kind**: instance method of <code>[g2](#g2)</code>
9696
**Returns**: <code>object</code> - g2
@@ -103,19 +103,19 @@ Set the view by absolute origin coordinates and scaling factor in device units.
103103

104104
<a name="g2+del"></a>
105105
### g2.del() ⇒ <code>object</code>
106-
Delete all commands. Does not modify view state.
106+
Delete all commands. Does not modify view state. (no command)<br>[Example](https://goessner.github.io/g2-svg/test/index.html#del)
107107

108108
**Kind**: instance method of <code>[g2](#g2)</code>
109109
**Returns**: <code>object</code> - g2
110110
<a name="g2+p"></a>
111111
### g2.p() ⇒ <code>object</code>
112-
Begin new path.
112+
Begin new path.<br>[Example](https://goessner.github.io/g2-svg/test/index.html#path)
113113

114114
**Kind**: instance method of <code>[g2](#g2)</code>
115115
**Returns**: <code>object</code> - g2
116116
<a name="g2+m"></a>
117117
### g2.m(x, y) ⇒ <code>object</code>
118-
Move to point.
118+
Move to point.<br>[Example](https://goessner.github.io/g2-svg/test/index.html#path)
119119

120120
**Kind**: instance method of <code>[g2](#g2)</code>
121121
**Returns**: <code>object</code> - g2
@@ -127,7 +127,7 @@ Move to point.
127127

128128
<a name="g2+l"></a>
129129
### g2.l(x, y) ⇒ <code>object</code>
130-
Create line segment to point.
130+
Create line segment to point.<br>[Example](https://goessner.github.io/g2-svg/test/index.html#path)
131131

132132
**Kind**: instance method of <code>[g2](#g2)</code>
133133
**Returns**: <code>object</code> - g2
@@ -143,7 +143,7 @@ g2().p() // Begin path. .m(0,50) // Move to point. .l(300,
143143
```
144144
<a name="g2+q"></a>
145145
### g2.q(x1, y1, x, y) ⇒ <code>object</code>
146-
Create quadratic bezier curve segment to point. ![Example](img/quadratic.png "Example")
146+
Create quadratic bezier curve segment to point.<br>[Example](https://goessner.github.io/g2-svg/test/index.html#path)
147147

148148
**Kind**: instance method of <code>[g2](#g2)</code>
149149
**Returns**: <code>object</code> - g2
@@ -161,7 +161,7 @@ g2().p() // Begin path. .m(0,0) // Move to point.
161161
```
162162
<a name="g2+c"></a>
163163
### g2.c(x1, y1, x2, y2, x, y) ⇒ <code>object</code>
164-
Create cubic bezier curve to point. ![Example](img/curve.png "Example")
164+
Create cubic bezier curve to point.<br>[Example](https://goessner.github.io/g2-svg/test/index.html#path)
165165

166166
**Kind**: instance method of <code>[g2](#g2)</code>
167167
**Returns**: <code>object</code> - g2
@@ -181,7 +181,7 @@ g2().p() // Begin path. .m(0,100) /
181181
```
182182
<a name="g2+a"></a>
183183
### g2.a(dw, x, y) ⇒ <code>object</code>
184-
Draw arc with angular range to target point. ![Example](img/a.png "Example")
184+
Draw arc with angular range to target point.<br>![Example](img/a.png "Example")
185185

186186
**Kind**: instance method of <code>[g2](#g2)</code>
187187
**Returns**: <code>object</code> - g2
@@ -198,13 +198,13 @@ var g = g2(); // Create g2 object.g2().p() // Begin path. .m(
198198
```
199199
<a name="g2+z"></a>
200200
### g2.z() ⇒ <code>object</code>
201-
Close current path by straight line.
201+
Close current path by straight line. [Example](https://goessner.github.io/g2-svg/test/index.html#path)
202202

203203
**Kind**: instance method of <code>[g2](#g2)</code>
204204
**Returns**: <code>object</code> - g2
205205
<a name="g2+stroke"></a>
206206
### g2.stroke([style], [d]) ⇒ <code>object</code>
207-
Stroke the current path or path object.
207+
Stroke the current path or path object. [Example](https://goessner.github.io/g2-svg/test/index.html#path)
208208

209209
**Kind**: instance method of <code>[g2](#g2)</code>
210210
**Returns**: <code>object</code> - g2
@@ -216,7 +216,7 @@ Stroke the current path or path object.
216216

217217
<a name="g2+fill"></a>
218218
### g2.fill([style], [d]) ⇒ <code>object</code>
219-
Fill the current path or path object.
219+
Fill the current path or path object. [Example](https://goessner.github.io/g2-svg/test/index.html#path)
220220

221221
**Kind**: instance method of <code>[g2](#g2)</code>
222222
**Returns**: <code>object</code> - g2
@@ -228,7 +228,7 @@ Fill the current path or path object.
228228

229229
<a name="g2+drw"></a>
230230
### g2.drw([style], [d]) ⇒ <code>object</code>
231-
Shortcut for stroke and fill the current path or path object.In case of shadow, only the path interior creates shadow, not also the path contour.
231+
Shortcut for stroke and fill the current path or path object.In case of shadow style, only the path interior creates shadow, not also the path contour. [Example](https://goessner.github.io/g2-svg/test/index.html#path)
232232

233233
**Kind**: instance method of <code>[g2](#g2)</code>
234234
**Returns**: <code>object</code> - g2
@@ -240,7 +240,7 @@ Shortcut for stroke and fill the current path or path object.In case of shadow,
240240

241241
<a name="g2+txt"></a>
242242
### g2.txt(s, [x], [y], [w], [style]) ⇒ <code>object</code>
243-
Draw text string at anchor point.
243+
Draw text string at anchor point. [Example](https://goessner.github.io/g2-svg/test/index.html#txt)
244244

245245
**Kind**: instance method of <code>[g2](#g2)</code>
246246
**Returns**: <code>object</code> - g2
@@ -255,7 +255,7 @@ Draw text string at anchor point.
255255

256256
<a name="g2+img"></a>
257257
### g2.img(uri, [x], [y], [b], [h], [xoff], [yoff], [dx], [dy]) ⇒ <code>object</code>
258-
Draw image. The command queue will not be executed until all images have been completely loaded.This also applies to images of reused g2 objects. If an image can not be loaded, it will be replaced by a broken-image symbol.
258+
Draw image. The command queue will not be executed until all images have been completely loaded.This also applies to images of reused g2 objects. If an image can not be loaded, it will be replaced by a broken-image symbol. [Example](https://goessner.github.io/g2-svg/test/index.html#img)
259259

260260
**Kind**: instance method of <code>[g2](#g2)</code>
261261
**Returns**: <code>object</code> - g2
@@ -274,7 +274,7 @@ Draw image. The command queue will not be executed until all images have been co
274274

275275
<a name="g2+lin"></a>
276276
### g2.lin(x1, y1, x2, y2, [style]) ⇒ <code>object</code>
277-
Draw line by start point and end point.![Example](https://goessner.github.io/g2-svg/test/index.html#lin "Example")
277+
Draw line by start point and end point. [Example](https://goessner.github.io/g2-svg/test/index.html#lin)
278278

279279
**Kind**: instance method of <code>[g2](#g2)</code>
280280
**Returns**: <code>object</code> - g2
@@ -293,7 +293,7 @@ g2().lin(10,10,190,10) // Draw line. .exe(ctx); // Render to conte
293293
```
294294
<a name="g2+rec"></a>
295295
### g2.rec(x, y, b, h, [style]) ⇒ <code>object</code>
296-
Draw rectangle by anchor point and dimensions.![Example](https://goessner.github.io/g2-svg/test/index.html#rec "Example")
296+
Draw rectangle by anchor point and dimensions. [Example](https://goessner.github.io/g2-svg/test/index.html#rec)
297297

298298
**Kind**: instance method of <code>[g2](#g2)</code>
299299
**Returns**: <code>object</code> - g2
@@ -312,7 +312,7 @@ g2().rec(100,80,40,30) // Draw rectangle. .exe(ctx); // Render to
312312
```
313313
<a name="g2+cir"></a>
314314
### g2.cir(x, y, r, [style]) ⇒ <code>object</code>
315-
Draw circle by center and radius.
315+
Draw circle by center and radius. [Example](https://goessner.github.io/g2-svg/test/index.html#cir)
316316

317317
**Kind**: instance method of <code>[g2](#g2)</code>
318318
**Returns**: <code>object</code> - g2
@@ -330,7 +330,7 @@ g2().cir(100,80,20) // Draw circle. .exe(ctx); // Render to context.
330330
```
331331
<a name="g2+arc"></a>
332332
### g2.arc(x, y, r, [w], [dw], [style]) ⇒ <code>object</code>
333-
Draw arc by center point, radius, start angle and angular range.<br>![Example](../img/arc.png "Example")
333+
Draw arc by center point, radius, start angle and angular range. [Example](https://goessner.github.io/g2-svg/test/index.html#arc) ![Example](../img/arc.png "Example")
334334

335335
**Kind**: instance method of <code>[g2](#g2)</code>
336336
**Returns**: <code>object</code> - g2
@@ -350,7 +350,7 @@ g2().arc(300,400,390,-Math.PI/4,-Math.PI/2) .exe(ctx);
350350
```
351351
<a name="g2+ply"></a>
352352
### g2.ply(parr, [mode], args) ⇒ <code>object</code>
353-
Draw polygon by points.Using iterator function for getting points from array by index.It must return current point object {x,y} or object {done:true}.Default iterator expects sequence of x/y-coordinates as a flat array [x,y,...],array of [[x,y],...] arrays or array of [{x,y},...] objects.
353+
Draw polygon by points.Using iterator function for getting points from array by index.It must return current point object {x,y} or object {done:true}.Default iterator expects sequence of x/y-coordinates as a flat array [x,y,...],array of [[x,y],...] arrays or array of [{x,y},...] objects. [Example](https://goessner.github.io/g2-svg/test/index.html#ply)
354354

355355
**Kind**: instance method of <code>[g2](#g2)</code>
356356
**Returns**: <code>object</code> - this
@@ -369,7 +369,7 @@ g2().ply([100,50,120,60,80,70]), .ply([150,60],[170,70],[130,80]],true),
369369
```
370370
<a name="g2+beg"></a>
371371
### g2.beg(args) ⇒ <code>object</code>
372-
Begin subcommands. Current state is saved. Optionally apply transformation or style properties.
372+
Begin subcommands. Current state is saved. Optionally apply transformation or style properties. [Example](https://goessner.github.io/g2-svg/test/index.html#beg-end)
373373

374374
**Kind**: instance method of <code>[g2](#g2)</code>
375375
**Returns**: <code>object</code> - g2
@@ -386,19 +386,19 @@ Begin subcommands. Current state is saved. Optionally apply transformation or s
386386

387387
<a name="g2+end"></a>
388388
### g2.end() ⇒ <code>object</code>
389-
End subcommands. Previous state is restored.
389+
End subcommands. Previous state is restored. [Example](https://goessner.github.io/g2-svg/test/index.html#beg-end)
390390

391391
**Kind**: instance method of <code>[g2](#g2)</code>
392392
**Returns**: <code>object</code> - g2
393393
<a name="g2+clr"></a>
394394
### g2.clr() ⇒ <code>object</code>
395-
Clear viewport.
395+
Clear viewport command.
396396

397397
**Kind**: instance method of <code>[g2](#g2)</code>
398398
**Returns**: <code>object</code> - g2
399399
<a name="g2+grid"></a>
400400
### g2.grid([color], [size]) ⇒ <code>object</code>
401-
Draw grid.
401+
Draw grid. [Example](https://goessner.github.io/g2-svg/test/index.html#grid)
402402

403403
**Kind**: instance method of <code>[g2](#g2)</code>
404404
**Returns**: <code>object</code> - g2
@@ -410,7 +410,7 @@ Draw grid.
410410

411411
<a name="g2+use"></a>
412412
### g2.use(g, args) ⇒ <code>object</code>
413-
Reference g2 graphics commands from another g2 object.With this command you can reuse instances of grouped graphics commandswhile applying a similarity transformation and style properties on them.In fact you might want to build custom graphics libraries on top of that feature.
413+
Reference g2 graphics commands from another g2 object.With this command you can reuse instances of grouped graphics commandswhile applying a similarity transformation and style properties on them.In fact you might want to build custom graphics libraries on top of that feature. [Example](https://goessner.github.io/g2-svg/test/index.html#rec)
414414

415415
**Kind**: instance method of <code>[g2](#g2)</code>
416416
**Returns**: <code>object</code> - g2
@@ -476,7 +476,7 @@ Execute g2 commands. It does so automatically and recursively with 'use'ed comma
476476
477477
<a name="g2+cpy"></a>
478478
### g2.cpy(g) ⇒ <code>object</code>
479-
Copy all g2 graphics commands from a g2 object.If the source object is 'this', nothing is done.
479+
Copy all g2 graphics commands from a g2 object (no command).<br>If the source object is 'this', nothing is done.
480480
481481
**Kind**: instance method of <code>[g2](#g2)</code>
482482
**Returns**: <code>object</code> - g2
@@ -538,8 +538,8 @@ Namespace for symbol objects. A symbol can be used by `use("symbolname")`.
538538
```js
539539
g2.symbol.cross = g2().lin(5,5,-5,-5).lin(5,-5,-5,5); // Define symbol.g2().use("cross",{x:100,y:100}) // Draw cross at position 100,100. .exe(ctx); // Render to context.
540540
```
541-
<a name="g2.version"></a>
542-
### g2.version : <code>string</code>
541+
<a name="g2.transparent"></a>
542+
### g2.transparent : <code>string</code>
543543
Current version.Using semantic versioning 'http://semver.org/'.
544544
545545
**Kind**: static constant of <code>[g2](#g2)</code>

0 commit comments

Comments
 (0)