g2 ⇒ g2
Additional methods for g2.
Kind: global typedef
Requires: module:g2.core.js
Author: Stefan Goessner
License: MIT License
- g2 ⇒
g2
- instance
- .nod
- .dblnod
- .pol
- .gnd
- .origin
- .hdl(args) ⇒
object
- .nodflt(args) ⇒
object
- .vec(args) ⇒
object
- .avec(args) ⇒
object
- .dim(args) ⇒
object
- .adim(args) ⇒
object
- .spline() ⇒
object
- static
- .symbol :
object
- .flatten()
- .symbol :
- instance
Kind: instance class of g2
Properties
Name | Type | Description |
---|---|---|
x | number |
x-value center. |
y | number |
y-value center. |
Node symbol.
Param | Type | Description |
---|---|---|
args | object |
symbol arguments object. |
Example
g2().nod({x:10,y:10})
Kind: instance class of g2
Properties
Name | Type | Description |
---|---|---|
x | number |
x-value center. |
y | number |
y-value center. |
Double nod symbol
Returns: object
- g2
Param | Type | Description |
---|---|---|
object |
symbol arguments object. |
Example
g2().dblnod({x:10,y:10})
Kind: instance class of g2
Properties
Name | Type | Description |
---|---|---|
x | number |
x-value center. |
y | number |
y-value center. |
Pole symbol.
Returns: object
- g2
Param | Type | Description |
---|---|---|
args | object |
symbol arguments object. |
Example
g2().pol({x:10,y:10})
Kind: instance class of g2
Properties
Name | Type | Description |
---|---|---|
x | number |
x-value center. |
y | number |
y-value center. |
Ground symbol.
Param | Type | Description |
---|---|---|
args | object |
arguments object. |
Example
g2().gnd({x:10,y:10})
Kind: instance class of g2
Properties
Name | Type | Description |
---|---|---|
x | number |
x-value center. |
y | number |
y-value center. |
w | number |
angle in radians. |
Origin symbol
Returns: object
- g2
Param | Type | Description |
---|---|---|
args | object |
symbol arguments object. |
Example
g2().view({cartesian:true})
.origin({x:10,y:10})
Draw interactive handle.
Kind: instance method of g2
Returns: object
- g2
Param | Type | Description |
---|---|---|
args | object |
handle object. |
Properties
Name | Type | Description |
---|---|---|
x | number |
x-value center. |
y | number |
y-value center. |
Example
g2().hdl({x:100,y:80}) // Draw handle.
Kind: instance method of g2
Returns: object
- g2
Param | Type | Description |
---|---|---|
args | object |
symbol arguments object. |
Properties
Name | Type | Description |
---|---|---|
x | number |
x-value center. |
y | number |
y-value center. |
Example
g2().view({cartesian:true})
.nodflt({x:10,y:10})
Draw vector arrow.
Kind: instance method of g2
Returns: object
- g2
Param | Type | Description |
---|---|---|
args | object |
vector arguments object. |
Properties
Name | Type | Description |
---|---|---|
x1 | number |
start x coordinate. |
y1 | number |
start y coordinate. |
x2 | number |
end x coordinate. |
y2 | number |
end y coordinate. |
Example
g2().vec({x1:50,y1:20,x2:250,y2:120})
Arc as Vector
Kind: instance method of g2
Returns: object
- g2
Param | Type | Description |
---|---|---|
args | object |
angular dimension arguments. |
Properties
Name | Type | Default | Description |
---|---|---|---|
x | number |
start x coordinate. | |
y | number |
start y coordinate. | |
r | number |
radius | |
[w] | number |
0 |
start angle (in radian). |
[dw] | number |
Math.PI/2 |
angular range in radian. In case of positive values it is running counterclockwise with right handed (cartesian) coordinate system. |
Example
g2().avec({x:100,y:70,r:50,w:pi/3,dw:4*pi/3})
Linear Dimension
Kind: instance method of g2
Returns: object
- g2
Param | Type | Description |
---|---|---|
args | object |
dimension arguments object. |
Properties
Name | Type | Default | Description |
---|---|---|---|
x1 | number |
start x coordinate. | |
y1 | number |
start y coordinate. | |
x2 | number |
end x coordinate. | |
y2 | number |
end y coordinate. | |
off | number |
offset. | |
[inside] | boolean |
true |
draw dimension arrows between or outside of ticks. |
Example
g2().dim({x1:60,y1:40,x2:190,y2:120})
Angular dimension
Kind: instance method of g2
Returns: object
- g2
Depricated: boolean
[inside] - draw dimension arrows between ticks.
Param | Type | Description |
---|---|---|
args | object |
angular dimension arguments. |
Properties
Name | Type | Default | Description |
---|---|---|---|
x | number |
start x coordinate. | |
y | number |
start y coordinate. | |
r | number |
radius | |
[w] | number |
0 |
start angle (in radian). |
[dw] | number |
Math.PI/2 |
angular range in radian. In case of positive values it is running counterclockwise with right handed (cartesian) coordinate system. |
[outside] | boolean |
false |
draw dimension arrows outside of ticks. |
Example
g2().adim({x:100,y:70,r:50,w:pi/3,dw:4*pi/3})
Draw spline by points. Implementing a centripetal Catmull-Rom spline (thus avoiding cusps and self-intersections). 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.
Kind: instance method of g2
Returns: object
- g2
See
Param | Type | Description |
---|---|---|
object |
spline arguments object. |
Properties
Name | Type | Default | Description |
---|---|---|---|
pts | Array.<object> | Array.<Array.<number>> | Array.<number> |
array of points. | |
[closed] | bool |
false |
closed spline. |
Example
g2().spline({pts:[100,50,50,150,150,150,100,50]})
Extended style values.
Not really meant to get overwritten. But if you actually want, proceed.
These styles can be referenced using the comfortable '@' syntax.
Kind: static namespace of g2
Properties
Name | Type | Default | Description |
---|---|---|---|
symbol | object |
g2 symbol namespace. |
|
[symbol.tick] | object |
Predefined symbol: a little tick | |
[symbol.dot] | object |
Predefined symbol: a little dot | |
[symbol.sqr] | object |
Predefined symbol: a little square | |
[symbol.nodcolor] | string |
"#333" |
node color. |
[symbol.nodfill] | string |
"#dedede" |
node fill color. |
[symbol.nodfill2] | string |
"#aeaeae" |
alternate node fill color, somewhat darker. |
[symbol.linkcolor] | string |
"#666" |
link color. |
[symbol.linkfill] | string |
"rgba(225,225,225,0.75)" |
link fill color, semi-transparent. |
[symbol.dimcolor] | string |
"darkslategray" |
dimension color. |
[symbol.solid] | array |
[] |
solid line style. |
[symbol.dash] | array |
[15,10] |
dashed line style. |
[symbol.dot] | array |
[4,4] |
dotted line style. |
[symbol.dashdot] | array |
[25,6.5,2,6.5] |
dashdotted line style. |
[symbol.labelOffset] | number |
5 |
default label offset distance. |
[symbol.labelSignificantDigits] | number |
3 |
default label's significant digits after numbering point. |
Flatten object properties (evaluate getters)
Kind: static method of g2