You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+38-2
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# g2
1
+
# g<sup>2</sup>
2
2
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)
4
4
principle. Its main goal is to provide a simple API for users who want to generate 2D web graphics occasionally.
5
5
So the API is minimal and easy to understand. The library is tiny, fast and renderer agnostic.
6
6
@@ -42,8 +42,44 @@ So the API is minimal and easy to understand. The library is tiny, fast and rend
42
42
*[Animation](../../wiki/animation)
43
43
*[Interactivity](../../wiki/interactivity)
44
44
45
+
45
46
## API Reference
46
47
See the [API Reference](api/README.md) for details.
47
48
49
+
48
50
## Cheat Sheet
49
51
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.
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)
58
58
59
59
**Kind**: instance method of <code>[g2](#g2)</code>
60
60
**Returns**: <code>object</code> - g2
@@ -65,7 +65,7 @@ Set the view's cartesian mode flag.[Example](https://goessner.github.io/g2-svg/
65
65
66
66
<aname="g2+pan"></a>
67
67
### 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)
69
69
70
70
**Kind**: instance method of <code>[g2](#g2)</code>
71
71
**Returns**: <code>object</code> - g2
@@ -77,7 +77,7 @@ Pan the view by a relative displacement vector.[Example](https://goessner.githu
77
77
78
78
<aname="g2+zoom"></a>
79
79
### 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)
81
81
82
82
**Kind**: instance method of <code>[g2](#g2)</code>
83
83
**Returns**: <code>object</code> - g2
@@ -90,7 +90,7 @@ Zoom the view by a scaling factor with respect to center.[Example](https://goes
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)
94
94
95
95
**Kind**: instance method of <code>[g2](#g2)</code>
96
96
**Returns**: <code>object</code> - g2
@@ -103,19 +103,19 @@ Set the view by absolute origin coordinates and scaling factor in device units.
103
103
104
104
<aname="g2+del"></a>
105
105
### 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)
107
107
108
108
**Kind**: instance method of <code>[g2](#g2)</code>
109
109
**Returns**: <code>object</code> - g2
110
110
<aname="g2+p"></a>
111
111
### 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)
113
113
114
114
**Kind**: instance method of <code>[g2](#g2)</code>
115
115
**Returns**: <code>object</code> - g2
116
116
<aname="g2+m"></a>
117
117
### 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)
119
119
120
120
**Kind**: instance method of <code>[g2](#g2)</code>
121
121
**Returns**: <code>object</code> - g2
@@ -127,7 +127,7 @@ Move to point.
127
127
128
128
<aname="g2+l"></a>
129
129
### 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)
131
131
132
132
**Kind**: instance method of <code>[g2](#g2)</code>
133
133
**Returns**: <code>object</code> - g2
@@ -143,7 +143,7 @@ g2().p() // Begin path. .m(0,50) // Move to point. .l(300,
143
143
```
144
144
<aname="g2+q"></a>
145
145
### g2.q(x1, y1, x, y) ⇒ <code>object</code>
146
-
Create quadratic bezier curve segment to point.
146
+
Create quadratic bezier curve segment to point.<br>[Example](https://goessner.github.io/g2-svg/test/index.html#path)
147
147
148
148
**Kind**: instance method of <code>[g2](#g2)</code>
149
149
**Returns**: <code>object</code> - g2
@@ -161,7 +161,7 @@ g2().p() // Begin path. .m(0,0) // Move to point.
Create cubic bezier curve to point.
164
+
Create cubic bezier curve to point.<br>[Example](https://goessner.github.io/g2-svg/test/index.html#path)
165
165
166
166
**Kind**: instance method of <code>[g2](#g2)</code>
167
167
**Returns**: <code>object</code> - g2
@@ -181,7 +181,7 @@ g2().p() // Begin path. .m(0,100) /
181
181
```
182
182
<aname="g2+a"></a>
183
183
### g2.a(dw, x, y) ⇒ <code>object</code>
184
-
Draw arc with angular range to target point.
184
+
Draw arc with angular range to target point.<br>
185
185
186
186
**Kind**: instance method of <code>[g2](#g2)</code>
187
187
**Returns**: <code>object</code> - g2
@@ -198,13 +198,13 @@ var g = g2(); // Create g2 object.g2().p() // Begin path. .m(
198
198
```
199
199
<aname="g2+z"></a>
200
200
### 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)
202
202
203
203
**Kind**: instance method of <code>[g2](#g2)</code>
204
204
**Returns**: <code>object</code> - g2
205
205
<aname="g2+stroke"></a>
206
206
### 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)
208
208
209
209
**Kind**: instance method of <code>[g2](#g2)</code>
210
210
**Returns**: <code>object</code> - g2
@@ -216,7 +216,7 @@ Stroke the current path or path object.
216
216
217
217
<aname="g2+fill"></a>
218
218
### 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)
220
220
221
221
**Kind**: instance method of <code>[g2](#g2)</code>
222
222
**Returns**: <code>object</code> - g2
@@ -228,7 +228,7 @@ Fill the current path or path object.
228
228
229
229
<aname="g2+drw"></a>
230
230
### 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)
232
232
233
233
**Kind**: instance method of <code>[g2](#g2)</code>
234
234
**Returns**: <code>object</code> - g2
@@ -240,7 +240,7 @@ Shortcut for stroke and fill the current path or path object.In case of shadow,
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)
259
259
260
260
**Kind**: instance method of <code>[g2](#g2)</code>
261
261
**Returns**: <code>object</code> - g2
@@ -274,7 +274,7 @@ Draw image. The command queue will not be executed until all images have been co
### g2.arc(x, y, r, [w], [dw], [style]) ⇒ <code>object</code>
333
-
Draw arc by center point, radius, start angle and angular range.<br>
333
+
Draw arc by center point, radius, start angle and angular range.[Example](https://goessner.github.io/g2-svg/test/index.html#arc)
334
334
335
335
**Kind**: instance method of <code>[g2](#g2)</code>
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)
354
354
355
355
**Kind**: instance method of <code>[g2](#g2)</code>
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)
373
373
374
374
**Kind**: instance method of <code>[g2](#g2)</code>
375
375
**Returns**: <code>object</code> - g2
@@ -386,19 +386,19 @@ Begin subcommands. Current state is saved. Optionally apply transformation or s
386
386
387
387
<aname="g2+end"></a>
388
388
### 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)
390
390
391
391
**Kind**: instance method of <code>[g2](#g2)</code>
392
392
**Returns**: <code>object</code> - g2
393
393
<aname="g2+clr"></a>
394
394
### g2.clr() ⇒ <code>object</code>
395
-
Clear viewport.
395
+
Clear viewport command.
396
396
397
397
**Kind**: instance method of <code>[g2](#g2)</code>
**Kind**: instance method of <code>[g2](#g2)</code>
404
404
**Returns**: <code>object</code> - g2
@@ -410,7 +410,7 @@ Draw grid.
410
410
411
411
<aname="g2+use"></a>
412
412
### 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)
414
414
415
415
**Kind**: instance method of <code>[g2](#g2)</code>
416
416
**Returns**: <code>object</code> - g2
@@ -476,7 +476,7 @@ Execute g2 commands. It does so automatically and recursively with 'use'ed comma
476
476
477
477
<a name="g2+cpy"></a>
478
478
### 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.
480
480
481
481
**Kind**: instance method of <code>[g2](#g2)</code>
482
482
**Returns**: <code>object</code> - g2
@@ -538,8 +538,8 @@ Namespace for symbol objects. A symbol can be used by `use("symbolname")`.
538
538
```js
539
539
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.
540
540
```
541
-
<a name="g2.version"></a>
542
-
### g2.version : <code>string</code>
541
+
<a name="g2.transparent"></a>
542
+
### g2.transparent : <code>string</code>
543
543
Current version.Using semantic versioning 'http://semver.org/'.
544
544
545
545
**Kind**: static constant of <code>[g2](#g2)</code>
0 commit comments