8000 pt/docs/json/core/all.json at master · jakedahm/pt · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
3451 lines (3451 loc) · 161 KB

all.json

File metadata and controls

3451 lines (3451 loc) · 161 KB
{
"CanvasSpace": {
"cls": "CanvasSpace",
"description": "<h3>CanvasSpace is a space that represents a html canvas. It creates a new canvas or get an existing one in DOM by its <code>id</code> attribute. It also provide methods specific to html canvas, such as tracking resize and mouse position.</h3>",
"extend": "Space",
"file": "CanvasSpace.coffee",
"funcs": [
{
"description": "<h2>Create a CanvasSpace which represents a HTML Canvas Space</h2>",
"name": "CanvasSpace",
"param": [
"<p><code>id</code> an id property which refers to the \"id\" attribute of the canvas element in DOM. If no canvas element with this id is found, a new canvas element will be created.</p>",
"<p><code>bgcolor</code> a background color string to specify the canvas background. Default is <code>false</code> which shows a transparent background.</p>",
"<p><code>context</code> a string of canvas context type, such as \"2d\" or \"webgl\". Default is \"2d\"</p>"
],
"pname": "id='pt_space', bgcolor=false, context='2d'"
},
{
"description": "<h2>Place a new canvas element into a container dom element. When canvas is ready, a \"ready\" event will be fired. Track this event with <code>space.canvas.addEventListener(\"ready\")</code></h2>",
"name": "display",
"param": [
"<p><code>parent_id</code> the DOM element into which the canvas element should be appended</p>",
"<p><code>readyCallback</code> a callback function with parameters <code>width</code>, <code>height</code>, and <code>canvas_element</code>, which will get called when canvas is appended and ready.</p>",
"<p><code>devicePixelSupport</code> a boolean to set if device pixel scaling should be checked. This may make drawings on retina displays look sharper but 10BC8 may reduce performance slightly. Default is <code>true</code>.</p>"
],
"pname": "parent_id=\"#pt\", readyCallback, devicePixelSupport=true",
"return": "<p>this CanvasSpace</p>"
},
{
"description": "<h2>Set whether the canvas element should resize when its container is resized. Default will auto size</h2>",
"name": "autoResize",
"param": [
"<p><code>auto</code> a boolean value indicating if auto size is set. Default is <code>true</code>.</p>"
],
"pname": "auto=true",
"return": "<p>this CanvasSpace</p>"
},
{
"demo": "canvasspace.resize",
"description": "<h2>This overrides Space's <code>resize</code> function. It's a callback function for window's resize event. Keep track of this with <code>onSpaceResize(w,h,evt)</code> callback in your added objects.</h2>",
"name": "resize",
"param": [],
"pname": "w, h, evt",
"return": "<p>this CanvasSpace</p>"
},
{
"description": "<h2>Clear the canvas with its background color. Overrides Space's <code>clear</code> function.</h2>",
"name": "clear",
"param": [
"<p><code>bg</code> Optionally specify a custom background color. If evaluated to false, it will use its <code>bgcolor</code> property as background color.</p>"
],
"pname": "bg",
"return": "<p>this CanvasSpace</p>"
},
{
"description": "<h2>Overrides Space's <code>animate</code> function for canvas</h2>",
"name": "animate",
"param": [
"<p><code>time</code> current time</p>"
],
"pname": "time",
"return": "<p>this CanvasSpace</p>"
}
],
"props": [
{
"description": "<h2>A property to store canvas DOM element</h2>",
"name": "space",
"param": []
},
{
"description": "<h2>A boolean property to track if the canvas element is added to dom or not</h2>",
"name": "appended",
"param": []
}
],
"statics": []
},
"Circle": {
"cls": "Circle",
"description": "<h3>Imagine this shape: find a point in space, and draw a curve around it so that the distance between the point you picked and any points on that curve is the same. So by remembering how a circle can be constructed, and by considering PI not as a number but as a ratio, we can start to recognize all the expressive potentials of a circle.</h3>",
"extend": "Vector",
"file": "Circle.coffee",
"funcs": [
{
"description": "<h2>Create a new Circle. A Circle is a Vector which defines its center position, with a <code>radius</code> property to define its radius.</h2>",
"eg": "<p><code>new Circle()</code> <code>new Circle(1,2,3)</code> <code>new Circle(1,2,3,100)</code></p>",
"name": "Circle",
"param": [
"<p><code>args</code> Similar to Point constructor, use comma-separated values, an array, or a Point object as parameters to specify the center of circle. Optionally include a 4th parameter to set the radius directly, or use <code>setRadius()</code> afterwards.</p>"
],
"pname": "",
"return": "<p>a new Circle object</p>"
},
{
"description": "<h2>set radius of the circle</h2>",
"name": "setRadius",
"param": [
"<p><code>r</code> radius value</p>"
],
"pname": "r",
"return": "<p>this Circle</p>"
},
{
"demo": "circle.intersectPoint",
"description": "<h2>Check if a point is on this Circle on xy axis.</h2>",
"eg": "<p><code>circle.intersectPoint(1,2,3)</code> <code>circle.intersectPoint(pt)</code></p>",
"name": "intersectPoint",
"param": [
"<p><code>args</code> comma-separated values, or an array, or a Point object</p>"
],
"pname": "args",
"return": "<p>a boolean value to indicate if there is an intersection</p>"
},
{
"demo": "circle.intersectPath",
"description": "<h2>Check intersections between this Circle and an infinite Line on xy axis. Based on <a href=\"http://stackoverflow.com/questions/13053061/circle-line-intersection-points\">this algorithm</a>.</h2><p>@get_pts <code>get_pts</code> a boolean value to specify whether the results should include the intersection points. If <code>false</code>, then only the intersection state (true or false) will be returned.</p>",
"name": "intersectPath",
"param": [
"<p><code>path</code> a Pair or Line object to specify an infinite line</p>"
],
"pname": "path, get_pts=true",
"return": "<p>s an Array of intersection points (zero, one, or two points), or a boolean value. (Based on <code>get_pts</code> parameter)</p>"
},
{
"description": "<h2>Check intersections between this Circle and a Line segment on xy axis.</h2><p>@get_pts <code>get_pts</code> a boolean value to specify whether the results should include the intersection points. If <code>false</code>, then only the intersection state (true or false) will be returned.</p>",
"name": "intersectLine",
"param": [
"<p><code>line</code> a Pair or Line object to specify a line segment</p>"
],
"pname": "line, get_pts=true",
"return": "<p>s an Array of intersection points (zero, one, or two points), or a boolean value. (Based on <code>get_pts</code> parameter)</p>"
},
{
"description": "<h2>Check if this cirlce intersects with a set of lines ( useful for polygon or polyline such as <code>rectangle.sides()</code> ) on xy axis.</h2><p>@get_pts <code>get_pts</code> a boolean value to specify whether the results should include the intersection points. If <code>false</code>, then only the intersection state (true or false) will be returned.</p>",
"eg": "<p><code>circle.intersectLines( rect.sides() )</code> <code>circle.intersectLines( pointset.sides(), true )</code></p>",
"name": "intersectLines",
"param": [
"<p><code>lines</code> an array of Line</p>"
],
"pname": "lines, get_pts=true",
"return": "<p>s an Array of intersection points, or a boolean value. (Based on <code>get_pts</code> parameter)</p>"
},
{
"demo": "circle.intersectCircle",
"description": "<h2>Check if this circle intersects with another circle</h2><p>@get_pts <code>get_pts</code> a boolean value to specify whether the results should include the intersection points. If <code>false</code>, then only the intersection state (true or false) will be returned.</p>",
"name": "intersectCircle",
"param": [
"<p><code>circle</code> another Circle</p>"
],
"pname": "circle, get_pts=true",
"return": "<p>s an Array of intersection points (zero or two points) or a boolean value, based on <code>get_pts</code> parameter.</p>"
},
{
"description": "<h2>Check if this cirlce intersect with another element on xy axis</h2>",
"eg": "<p><code>circle.hasIntersect( another_circle )</code> <code>circle.hasIntersect(line)</code> <code>circle.hasIntersect(rect)</code></p>",
"name": "hasIntersect",
"param": [
"<p><code>item</code> any object that is based on Point. (Vector, Line, Rectangle, Circle, etc)</p>"
],
"pname": "item, get_pts=false",
"return": "<p>s an Array of intersection points or a boolean value. (Based on <code>get_pts</code> parameter)</p>"
},
{
"description": "<h2>Describe this point as a text string</h2>",
"name": "toString",
"param": [],
"pname": "",
"return": "<p>\"Vector x, y, z\" text</p>"
}
],
"props": [
{
"description": "<h2>the radius property</h2>",
"name": "radius",
"param": []
}
],
"statics": []
},
"Color": {
"cls": "Color",
"description": "<h3>Color is a sensation of electromagnetic radiation, but your mind interprets it with such obstinate attitude that your favorite color may be, god forbids, pink. Or perhaps color is more like music, whose harmony and rhythm evoke emotions, and can be organized in different sequences to create meaningful narratives.</h3>",
"extend": "Vector",
"file": "Color.coffee",
"funcs": [
{
"description": "<h2>Create a new Color. Color lets you define a color in a specific mode. <a href=\"https://software.intel.com/en-us/node/503873\">This article</a> from Intel has a good overview of different color models.</h2>",
"eg": "<p><code>new Color()</code> <code>new Color(255,100,20)</code> <code>new Color([2,4])</code> <code>new Color({x:3, y:6, z:9})</code> <code>new Color(360,1,1,0.5)</code>, <code>new Color(100,50,-50,1,'lab')</code></p>",
"name": "Color",
"param": [
"<p><code>args</code> Set the three values of a color as comma-separated values, as an array, or as an object with <code>{x, y, z}</code> properties. Optionally set <code>alpha</code> in a 4th parameter, and color mode string in 5th parameter.</p>"
],
"pname": "args",
"return": "<p>a new Color object</p>"
},
{
"description": "<h2>set a color mode and convert current color to new color mode</h2>",
"eg": "<p><code>color.setMode('lab')</code></p>",
"name": "setMode",
"param": [
"<p><code>m</code> a string to specify color mode: 'hsl', 'hsb', 'rgb', 'lab', 'lch', 'xyz'</p>"
],
"pname": "m",
"return": "<p>this Color object with new color mode</p>"
},
{
"description": "<h2>Get rgb value as hex string such as '#123456'</h2>",
"name": "hex",
"param": [],
"pname": ""
},
{
"description": "<h2>Get rgb string such as 'rgb(12,34,56)'</h2>",
"name": "rgb",
"param": [],
"pname": ""
},
{
"description": "<h2>Get rgba string such as 'rgba(12,34,56, 0.2)'</h2>",
"name": "rgba",
"param": [],
"pname": ""
},
{
"description": "<h2>Get color values (based on current color mode) as an array</h2>",
"name": "values",
"param": [
"<p><code>toRGB</code> Optional boolean value to convert to rgb value if set to <code>true</code>. Default is false.</p>"
],
"pname": "toRGB=false",
"return": "<p>an array of colro values</p>"
},
{
"description": "<h2>override clone</h2>",
"name": "clone",
"param": [],
"pname": ""
}
],
"props": [
{
"description": "<h2>alpha value from 0 to 1, where 0 is fully transparent, and 1 is fully opaque</h2>",
"name": "alpha",
"param": []
},
{
"description": "<h2>color mode id such as \"lab\" or \"rgb\"</h2>",
"name": "mode",
"param": []
},
{
"description": "<h2>A property to adject XYZ for Standard Observer 2deg, Daylight/sRGB illuminant D65</h2>",
"name": "XYZ",
"param": []
}
],
"statics": [
{
"description": "<h2>A static function <code>Color.RGBtoHSL</code> to convert RGB to HSL</h2>",
"eg": "<p><code>Color.RGBtoHSL(255,70,0)</code> <code>Color.RGBtoHSL(1,0.3 10BC8 ,0, true)</code></p>",
"name": "RGBtoHSL",
"param": [
"<p><code>r, g, b</code> red, green, blue values from 0 to 255</p>",
"<p><code>normalizedInput, normalizedOutput</code> Optional boolean values to indicate if input parameters are normalized (0 to 1), and if return value should be normalized</p>"
],
"pname": "r, g, b, normalizedInput, normalizedOutput",
"return": "<p>an array of [h, s, l] where h is from 0 to 360, s is from 0 to 1, and l is from 0 to 1.</p>"
},
{
"demo": "color.HSLtoRGB",
"description": "<h2>A static function <code>Color.HSLtoRGB</code> to convert HSL to RGB</h2>",
"eg": "<p><code>Color.HSLtoRGB(360,0.7,0.9)</code> <code>Color.HSLtoRGB(1,0.3,0, true)</code></p>",
"name": "HSLtoRGB",
"param": [
"<p><code>h, s, l</code> hue, saturation, and lightness. hue value from 0 to 360, saturation and lightness values from 0 to 1</p>",
"<p><code>normalizedInput, normalizedOutput</code> Optional boolean values to indicate if input parameters are normalized (0 to 1), and if return value should be normalized</p>"
],
"pname": "h, s, l, normalizedInput, normalizedOutput",
"return": "<p>an array of [r, g, b] where each value is from 0 to 255</p>"
},
{
"description": "<h2>A static function <code>Color.RGBtoHSB</code> to convert RGB to HSB</h2>",
"eg": "<p><code>Color.RGBtoHSB(255,70,0)</code> <code>Color.RGBtoHSB(1,0.3,0, true)</code></p>",
"name": "RGBtoHSB",
"param": [
"<p><code>r, g, b</code> red, green, blue values from 0 to 255</p>",
"<p><code>normalizedInput, normalizedOutput</code> Optional boolean values to indicate if input parameters are normalized (0 to 1), and if return value should be normalized</p>"
],
"pname": "r, g, b, normalizedInput, normalizedOutput",
"return": "<p>an array of [h, s, b] where h is from 0 to 360, s is from 0 to 1, and b is from 0 to 1.</p>"
},
{
"demo": "color.HSBtoRGB",
"description": "<h2>A static function <code>Color.HSBtoRGB</code> to convert HSB to RGB</h2>",
"eg": "<p><code>Color.HSBtoRGB(360,0.7,0.9)</code> <code>Color.HSBtoRGB(1,0.3,0, true)</code></p>",
"name": "HSBtoRGB",
"param": [
"<p><code>h, s, b</code> hue, saturation, and brightness. hue value from 0 to 360, saturation and brightness values from 0 to 1</p>",
"<p><code>normalizedInput, normalizedOutput</code> Optional boolean values to indicate if input parameters are normalized (0 to 1), and if return value should be normalized</p>"
],
"pname": "h, s, v, normalizedInput, normalizedOutput",
"return": "<p>an array of [r, g, b] where each value is from 0 to 255</p>"
},
{
"description": "<h2>Static function <code>Color.RGBtoLAB</code> transforms RGB to LAB</h2>",
"name": "RGBtoLAB",
"param": [
"<p><code>r, g, b</code> red, green, and blue values from 0 to 255</p>",
"<p><code>normalizedInput, normalizedOutput</code> Optional boolean values to indicate if input parameters are normalized (0 to 1), and if return value should be normalized</p>"
],
"pname": "r, g, b, normalizedInput, normalizedOutput",
"return": "<p>an array of [L, a, b] where lightness (L) is from 0 to 100, a and b component values are from -128 to 127. red/green colors are represented in a, and yellow/blue colors are represented in b.</p>"
},
{
"demo": "color.LABtoRGB",
"description": "<h2>Static function <code>Color.LABtoRGB</code> transforms LAB to RGB</h2>",
"name": "LABtoRGB",
"param": [
"<p><code>L, a, b</code> lightness (L) is from 0 to 100, a and b component values are from -128 to 127. red/green colors are represented in a, and yellow/blue colors are represented in b.</p>",
"<p><code>normalizedInput, normalizedOutput</code> Optional boolean values to indicate if input parameters are normalized (0 to 1), and if return value should be normalized</p>"
],
"pname": "L, a, b, normalizedInput, normalizedOutput",
"return": "<p>an array of [r, g, b] where each value is from 0 to 255</p>"
},
{
"description": "<h2>Static function <code>Color.RGBtoLCH</code> transforms RGB to LCH (Cylindrical Lab)</h2>",
"name": "RGBtoLCH",
"param": [
"<p><code>r, g, b</code> red, green, and blue values from 0 to 255</p>",
"<p><code>normalizedInput, normalizedOutput</code> Optional boolean values to indicate if input parameters are normalized (0 to 1), and if return value should be normalized</p>"
],
"pname": "r, g, b, normalizedInput, normalizedOutput",
"return": "<p>an array of [L, c, h] where lightness (l) and chroma (c) is from 0 to 100, and hue (h) is from 0 to 360</p>"
},
{
"description": "<h2>Static function <code>Color.LCHtoRGB</code> transforms LCH to RGB</h2>",
"name": "LCHtoRGB",
"param": [
"<p><code>L, c, h</code> lightness (l) and chroma (c) is from 0 to 100, and hue (h) is from 0 to 360</p>"
],
"pname": "L, c, h, normalizedInput, normalizedOutput",
"return": "<p>an array of [r, g, b] where each value is from 0 to 255</p>"
},
{
"description": "<h2>Static function <code>Color.XYZtoRGB</code> to convert XYZ to RGB. This is usually used when converting between LAB and RGB.</h2>",
"name": "XYZtoRGB",
"param": [
"<p><code>x, y, z</code> x, y, z values from 0 to 100</p>",
"<p><code>normalizedInput, normalizedOutput</code> Optional boolean values to indicate if input parameters are normalized (0 to 1), and if return value should be normalized</p>"
],
"pname": "x, y, z, normalizedInput, normalizedOutput",
"return": "<p>an array of [r, g, b] where each value is from 0 to 255</p>"
},
{
"description": "<h2>A static function <code>Color.RGBtoXYZ</code> to convert RGB to XYZ. This is usually used when converting between LAB and RGB.</h2>",
"name": "RGBtoXYZ",
"param": [
"<p><code>r, g, b</code> red, green, blue values from 0 to 255</p>",
"<p><code>normalizedInput, normalizedOutput</code> Optional boolean values to indicate if input parameters are normalized (0 to 1), and if return value should be normalized</p>"
],
"pname": "r, g, b, normalizedInput, normalizedOutput",
"return": "<p>an array of [x, y, z] where each value is from 0 to 100</p>"
},
{
"description": "<h2>Static function <code>Color.XYZtoLAB</code> to convert XYZ to LAB.</h2>",
"name": "XYZtoLAB",
"param": [
"<p><code>x, y, z</code> x, y, z values from 0 to 100</p>"
],
"pname": "x, y, z",
"return": "<p>an array of [l, a, b] where lightness (L) is from 0 to 100, a and b values are from -128 to 127</p>"
},
{
"description": "<h2>Static function <code>Color.LABtoXYZ</code> to convert LAB to XYZ.</h2>",
"name": "LABtoXYZ",
"param": [
"<p><code>L, a, b</code> lightness (L) is from 0 to 100, a and b component values are from -128 to 127</p>"
],
"pname": "L, a, b",
"return": "<p>an array of [x, y, z] where each value is from 0 to 100</p>"
},
{
"description": "<h2>Static function <code>Color.XYZtoLUV</code> to convert XYZ to LUV.</h2>",
"name": "XYZtoLUV",
"param": [
"<p><code>x, y, z</code> x, y, z values from 0 to 100</p>"
],
"pname": "x, y, z",
"return": "<p>an array of [l, u, v] where lightness is from 0 to 100, u is from -134 to 220, and v is from -140 o 122</p>"
},
{
"description": "<h2>Static function <code>Color.LUVtoXYZ</code> to convert LUV to XYZ.</h2>",
"name": "LUVtoXYZ",
"param": [
"<p><code>L, u, v</code> lightness (L) is from 0 to 100, u is from -134 to 220, and v is from -140 o 122</p>"
],
"pname": "L, u, v",
"return": "<p>an array of [x, y, z] where each value is from 0 to 100</p>"
},
{
"description": "<h2>Static function <code>Color.LABtoLCH</code> transforms LAB to Cylindrical LCH</h2>",
"name": "LABtoLCH",
"param": [
"<p><code>L, a, b</code> lightness (L) is from 0 to 100, a and b component values are from -128 to 127</p>"
],
"pname": "L, a, b",
"return": "<p>an array of [l, c, h] where lightness (l) and chroma (c) is from 0 to 100, and hue (h) is from 0 to 360</p>"
},
{
"description": "<h2>Static function <code>Color.LCHtoLAB</code> transforms Cylindrical LCH to LAB</h2>",
"name": "LCHtoLAB",
"param": [
"<p><code>L, c, h</code> lightness (L) and chroma (c) is from 0 to 100, and hue (h) is from 0 to 360</p>"
],
"pname": "L, c, h",
"return": "<p>an array of [l, a, b] where lightness (L) is from 0 to 100, a and b values are from -128 to 127</p>"
},
{
"description": "<h2>Static function <code>Color.LUVtoLCH</code> to convert LUV to LCH.</h2>",
"name": "LUVtoLCH",
"param": [
"<p><code>L, u, v</code> lightness (L) is from 0 to 100, u is from -134 to 220, and v is from -140 o 122</p>"
],
"pname": "L, u, v",
"return": "<p>an array of [l, c, h] where lightness (l) and chroma (c) is from 0 to 100, and hue (h) is from 0 to 360</p>"
},
{
"description": "<h2>Static function <code>Color.LCHtoLUV</code> transforms Cylindrical LCH to LUV</h2>",
"name": "LCHtoLUV",
"param": [
"<p><code>L, c, h</code> lightness (L) and chroma (c) is from 0 to 100, and hue (h) is from 0 to 360</p>"
],
"pname": "L, c, h",
"return": "<p>an array of [l, u, v] where lightness is from 0 to 100, u is from -134 to 220, and v is from -140 o 122</p>"
}
]
},
"Const": {
"cls": "Const",
"description": "<h3>A list of useful constant values for calculations and labeling.</h3>",
"extend": "",
"file": "Const.coffee",
"funcs": [],
"props": [
{
"description": "<h2>represents the xy plane</h2>",
"name": "xy",
"param": []
},
{
"description": "<h2>represents the yz plane</h2>",
"name": "yz",
"param": []
},
{
"description": "<h2>reporesents the xz plane</h2>",
"name": "xz",
"param": []
},
{
"description": "<h2>represents xyz space</h2>",
"name": "xyz",
"param": []
},
{
"description": "<h2>represents identical point or value</h2>",
"name": "identical",
"param": []
},
{
"description": "<h2>represents right position or direction</h2>",
"name": "right",
"param": []
},
{
"description": "<h2>represents bottom right position or direction</h2>",
"name": "bottom_right",
"param": []
},
{
"description": "<h2>represents bottom position or direction</h2>",
"name": "bottom",
"param": []
},
{
"description": "<h2>represents bottom left position or direction</h2>",
"name": "bottom_left",
"param": []
},
{
"description": "<h2>represents left position or direction</h2>",
"name": "left",
"param": []
},
{
"description": "<h2>represents top left position or direction</h2>",
"name": "top_left",
"param": []
},
{
"description": "<h2>represents top position or direction</h2>",
"name": "top",
"param": []
},
{
"description": "<h2>represents top right position or direction</h2>",
"name": "top_right",
"param": []
},
{
"description": "<h2>an array of strings to label position constants above. Eg, <code>Const.sideLabels[ Const.top_left]</code> will return the string \"top left\"</h2>",
"name": "sideLabels",
"param": []
},
{
"description": "<h2>represents an arbitrary very small number. It is set as 0.0001 here.</h2>",
"name": "epsilon",
"param": []
},
{
"description": "<h2>pi radian (180 deg)</h2>",
"name": "pi",
"param": []
},
{
"description": "<h2>two pi radian (360deg)</h2>",
"name": "two_pi",
"param": []
},
{
"description": "<h2>half pi radian (90deg)</h2>",
"name": "half_pi",
"param": []
},
{
"description": "<h2>pi/4 radian (45deg)</h2>",
"name": "quarter_pi",
"param": []
},
{
"description": "<h2>pi/180 = 1 degree in radian</h2>",
"name": "one_degree",
"param": []
},
{
"description": "<h2>multiply this constant with a radian to get a degree</h2>",
"name": "rad_to_deg",
"param": []
},
{
"description": "<h2>multiply this constant with a degree to get a radian</h2>",
"name": "deg_to_rad",
"param": []
},
{
"description": "<h2>Gravity acceleration (unit = m/s^2) and gravity force (unit = Newton) on 1kg of mass.</h2>",
"name": "gravity",
"param": []
},
{
"description": "<h2>1 Newton = 0.10197 Kilogram-force</h2>",
"name": "newton",
"param": []
},
{
"description": "<h2>Gaussian constant (1 / Math.sqrt(2 * Math.PI))</h2>",
"name": "gaussian",
"param": []
}
],
"statics": []
},
"Curve": {
"cls": "Curve",
"description": "<h3>A straight line or a moving particle, swayed by external forces or internal constraints, gradually deviates from its ideal path and becomes a curve. A river meanders and a strain of hair curls. A curve expresses the effects of forces and constraints.</h3>",
"extend": "PointSet",
"file": "Curve.coffee",
"funcs": [
{
"description": "<h2>Create a new Curve. A Curve uses a set of anchor and/or control points to interpolate a curve.</h2>",
"eg": "<p><code>new PointSet()</code> <code>new PointSet(1,2,3)</code> <code>new PointSet([2,4])</code> <code>new PointSet({x:3, y:6, z:9}).to(1,2,3)</code> <code>new PointSet(1,2,3).to([p1, p2, p3, p4, p5])</code></p>",
"name": "Curve",
"param": [
"<p><code>args</code> Similar to PointSet constructor, use comma-separated values, an array, or an object as parameters to specify the anchor point. Use <code>to()</code> to add points to the set.</p>"
],
"pname": "",
"return": "<p>a new Curve object</p>"
},
{
"description": "<h2>Given an index for the starting position in <code>points</code> array, get the control and/or end points of a curve segment</h2>",
"name": "controlPoints",
"param": [
"<p><code>index</code> start index in <code>points</code> array. Default is 0.</p>",
"<p><code>copyStart</code> an optional boolean value to indicate if the start index should be used twice. Default is false.</p>"
],
"pname": "index=0, copyStart=false",
"return": "<p>an object with 4 points <code>{p0, p1, p2, p3}</code></p>"
},
{
"description": "<h2>Create a Catmull-Rom curve. Catmull-Rom is a kind of Cardinal curve with smooth-looking curve.</h2>",
"name": "catmullRom",
"param": [
"<p><code>step</code> the number of line segments. Defaults to 10 steps.</p>"
],
"pname": "steps=10",
"return": "<p>an array of Points</p>"
},
{
"description": "<h2>Interpolate to get a point on Catmull-Rom curve</h2>",
"name": "catmullRomPoint",
"param": [
"<p><code>step</code> the point to interpolate, as an array of <code>[t, t*t, t*t*t]</code> where <code>t</code> is between 0 to 1</p>",
"<p><code>ctrls</code> the control points which can be provided by <code>controlPoints()</code> function</p>"
],
"pname": "step, ctrls",
"return": "<p>a Point on the curve</p>"
},
{
"demo": "curve.cardinal",
"description": "<h2>Create a Cardinal spline curve</h2>",
"name": "cardinal",
"param": [
"<p><code>step</code> the number of line segments. Defaults to 10 steps.</p>",
"<p><code>tension</code> optional value between 0 to 1 to specify a \"tension\". Default to 0.5 which is the tension for Catmull-Rom curve</p>"
],
"pname": "steps=10, tension=0.5",
"return": "<p>an array of Points</p>"
},
{
"description": "<h2>Interpolate to get a point on Cardinal curve</h2>",
"name": "cardinalPoint",
"param": [
"<p><code>step</code> the point to interpolate, as an array of <code>[t, t*t, t*t*t]</code> where <code>t</code> is between 0 to 1</p>",
"<p><code>ctrls</code> the control points which can be provided by <code>controlPoints()</code> function</p>",
"<p><code>tension</code> optional value between 0 to 1 to specify a \"tension\". Default to 0.5 which is the tension for Catmull-Rom curve</p>"
],
"pname": "step, ctrls, tension=0.5",
"return": "<p>a Point on the curve</p>"
},
{
"demo": "curve.bezier",
"description": "<h2>Create a Bezier curve. In a cubic bezier curve, the first and 4th points are end points, and 2nd and 3rd points are control points.</h2>",
"name": "bezier",
"param": [
"<p><code>step</code> the number of line segments. Defaults to 10 steps</p>"
],
"pname": "steps=10",
"return": "<p>an array of Points</p>"
},
{
"description": "<h2>Interpolate to get a point on a cubic Bezier curve</h2>",
"name": "bezierPoint",
"param": [
"<p><code>step</code> the point to interpolate, as an array of <code>[t, t*t, t*t*t]</code> where <code>t</code> is between 0 to 1</p>",
"<p><code>ctrls</code> the control and end points which can be provided by <code>controlPoints()</code> function. The first and 4th points are end points, and 2nd and 3rd points are control points.</p>"
],
"pname": "step, ctrls",
"return": "<p>a Point on the curve</p>"
},
{
"demo": "curve.bspline",
"description": "<h2>Create a B-Spline cuve</h2>",
"name": "bspline",
"param": [
"<p><code>step</code> the number of line segments. Defaults to 10 steps.</p>",
"<p><code>tension</code> optional value between 0 to 1 to specify a \"tension\". Or <code>false</code> to have normal tension. Default is false.</p>"
],
"pname": "steps=10, tension=false",
"return": "<p>an array of Points</p>"
},
{
"description": "<h2>Interpolate to get a point on B-Spline curve</h2>",
"name": "bsplinePoint",
"param": [
"<p><code>step</code> the point to interpolate, as an array of <code>[t, t*t, t*t*t]</code> where <code>t</code> is between 0 to 1</p>",
"<p><code>ctrls</code> the control points which can be provided by <code>controlPoints()</code> function</p>"
],
"pname": "step, ctrls",
"return": "<p>a Point on the curve</p>"
},
{
"description": "<h2>Interpolate to get a point on B-Spline curve with tension (Duff)</h2>",
"name": "bsplineTensionPoint",
"param": [
"<p><code>step</code> the point to interpolate, as an array of <code>[t, t*t, t*t*t]</code> where <code>t</code> is between 0 to 1</p>",
"<p><code>ctrls</code> the control points which can be provided by <code>controlPoints()</code> function</p>",
"<p><code>tension</code> optional value between 0 to 1 to specify a \"tension\". Default to 1 which is the normal tension.</p>"
],
"pname": "step, ctrls, tension=1",
"return": "<p>a Point on the curve</p>"
}
],
"props": [
{
"description": "<h2>a boolean value to specify if this Curve is 2D or 3D. Default is <code>false</code> (2D).</h2>",
"name": "is3D",
"param": []
}
],
"statics": []
},
"DOMSpace": {
"cls": "DOMSpace",
"description": "<h3>DOMSpace is a space that represents a html dom. It is similar to <code>CanvasSpace</code> but usually used as a space for SVG or HTML.</h3>",
"extend": "Space",
"file": "DOMSpace.coffee",
"funcs": [
{
"description": "<h2>Create a DOMSpace which represents a HTML DOM</h2>",
"name": "DOMSpace",
"param": [
"<p><code>id</code> an id property which refers to the \"id\" attribute of the element in DOM.</p>",
"<p><code>bgcolor</code> a background color string to specify the background. Default is <code>false</code> which shows a transparent background.</p>",
"<p><code>context</code> a string of dom context type, such as \"html\" or \"svg\". Default is \"html\"</p>"
],
"pname": "id='pt_space', bgcolor=false, context='html'"
},
{
"description": "<h2>Place a new canvas element into a container dom element. When canvas is ready, a \"ready\" event will be fired. Track this event with <code>space.canvas.addEventListener(\"ready\")</code></h2>",
"name": "display",
"param": [
"<p><code>parent_id</code> the DOM element into which the canvas element should be appended</p>",
"<p><code>readyCallback</code> a callback function with parameters <code>width</code>, <code>height</code>, and <code>canvas_element</code>, which will get called when canvas is appended and ready.</p>"
],
"pname": "parent_id=\"#pt\", readyCallback",
"return": "<p>this CanvasSpace</p>"
},
{
"description": "<h2>Set whether the canvas element should resize when its container is resized. Default will auto size</h2>",
"name": "autoResize",
"param": [
"<p><code>auto</code> a boolean value indicating if auto size is set. Default is <code>true</code>.</p>"
],
"pname": "auto=true",
"return": "<p>this CanvasSpace</p>"
},
{
"demo": "canvasspace.resize",
"description": "<h2>This overrides Space's <code>resize</code> function. It's a callback function for window's resize event. Keep track of this with <code>onSpaceResize(w,h,evt)</code> callback in your added objects.</h2>",
"name": "resize",
"param": [],
"pname": "w, h, evt",
"return": "<p>this CanvasSpace</p>"
},
{
"description": "<h2>Overrides Space's <code>animate</code> function</h2>",
"name": "animate",
"param": [
"<p><code>time</code> current time</p>"
],
"pname": "time",
"return": "<p>this CanvasSpace</p>"
}
],
"props": [
{
"description": "<h2>A property to store the DOM element</h2>",
"name": "space",
"param": []
},
{
"description": "<h2>A boolean property to track if the element is added to container or not</h2>",
"name": "appended",
"param": []
}
],
"statics": []
},
"Form": {
"cls": "Form",
"description": "<h3>Form makes visible the invisible. It transforms a point into an inkblot, or an arrow, or a musical note. By separating forms from its concepts, we may create a myriad of expressions on a single concept, or apply a unified style to various concepts. The Form class provides basic method to draw points, lines, and other primitives on CanvasSpace. Extend this class to visualize in different ways in different contexts.</h3>",
"extend": "",
"file": "Form.coffee",
"funcs": [
{
"description": "<h2>Create a new Form which is based on HTML Canvass</h2>",
"name": "Form",
"param": [
"<p><code>space</code> A space that has a valid context for this form. In this case, the space should represent an html canvas.</p>"
],
"pname": "space",
"return": "<p>a new Form object</p>"
},
{
"demo": "form.fill",
"description": "<h2>Set current fill style</h2>",
"eg": "<p><code>form.fill(\"#F90\")</code> <code>form.fill(\"rgba(0,0,0,.5\")</code> <code>form.fill(false)</code></p>",
"name": "fill",
"param": [
"<p><code>c</code> fill color which can be as color, gradient, or pattern. (See <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle\">canvas documentation</a>) Default is <code>false</code> (transparent)</p>"
],
"pname": "c",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Set current stroke style</h2>",
"eg": "<p><code>form.stroke(\"#F90\")</code> <code>form.stroke(\"rgba(0,0,0,.5\")</code> <code>form.stroke(false)</code> <code>form.stroke(\"#000\", 0.5, 'round')</code></p>",
"name": "stroke",
"param": [
"<p><code>c</code> stroke color which can be as color, gradient, or pattern. (See <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle\">canvas documentation</a>) Default is false (transparent)</p>",
"<p><code>width</code> Optional value (can be floating point) to set line width</p>",
"<p><code>joint</code> Optional string to set line joint style. Can be \"miter\", \"bevel\", or \"round\".</p>"
],
"pname": "c, width, joint",
"return": "<p>this Form</p>"
},
{
"demo": "form.font",
"description": "<h2>Set font size and font face</h2>",
"eg": "<p><code>form.font(24)</code> <code>form.font(12, \"Georgia\")</code></p>",
"name": "font",
"param": [
"<p><code>size</code> an integer value to specify font size in pixels</p>",
"<p><code>face</code> optional name to change the font face, such as \"sans-serif\" or \"Helvetica\"</p>"
],
"pname": "size, face=@fontFace",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Draw a shape. Defaults to <code>sketch()</code>. Override this function to draw differently.</h2>",
"name": "draw",
"param": [],
"pname": "shape",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Default draw based on the types of shape (Point, Line, Circle, etc)</h2>",
"name": "sketch",
"param": [
"<p><code>shape</code> any shape such as <code>Point</code> or <code>Line</code>, or an array of Points</p>"
],
"pname": "shape",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Draw a point</h2>",
"name": "point",
"param": [
"<p><code>p</code> a Point object</p>",
"<p><code>halfsize</code> radius or half size of the point. Default is 2.</p>",
"<p><code>isCircle</code> a boolean value to specify if the point should be drawn as a circle. Default is false.</p>"
],
"pname": "p, halfsize=2, isCircle=false",
"return": "<p>this Form</p>"
},
{
"demo": "form.points",
"description": "<h2>Draw a series of points</h2>",
"name": "points",
"param": [
"<p><code>ps</code> an array of Points</p>",
"<p><code>halfsize</code> radius or half size of the point. Default is 2.</p>",
"<p><code>isCircle</code> a boolean value to specify if the point should be drawn as a circle. Default is false.</p>"
],
"pname": "ps, halfsize=2, isCircle=false",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Draw a line</h2>",
"name": "line",
"param": [
"<p><code>p</code> a Pair object</p>"
],
"pname": "p",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Draw a series of lines</h2>",
"name": "lines",
"param": [
"<p><code>ps</code> an array of Lines</p>"
],
"pname": "ps",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Draw a rectangle</h2>",
"name": "rect",
"param": [
"<p><code>p</code> a Pair object</p>"
],
"pname": "p",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Draw a circle</h2>",
"name": "circle",
"param": [
"<p><code>p</code> a Circle object</p>"
],
"pname": "p",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Draw an arc</h2>",
"name": "arc",
"param": [
"<p><code>p</code> a Circle object</p>",
"<p><code>start</code> start angle</p>",
"<p><code>end</code> end angle</p>"
],
"pname": "p, start, end",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Draw a triangle</h2>",
"name": "triangle",
"param": [
"<p><code>p</code> a Triangle object</p>"
],
"pname": "p",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Draw a polygon</h2>",
"name": "polygon",
"param": [
"<p><code>ps</code> an array of Points</p>",
"<p><code>closePath</code> a boolean value to specify if the path should be closed (joining last point with first point)</p>"
],
"pname": "ps, closePath",
"return": "<p>this Form</p>"
},
{
"demo": "form.curve",
"description": "<h2>Draw a curve</h2>",
"name": "curve",
"param": [
"<p><code>ps</code> an array of Points</p>"
],
"pname": "ps",
"return": "<p>this Form</p>"
},
{
"description": "<h2>Draw text</h2>",
"name": "text",
"param": [
"<p><code>p</code> a Point to specify anchor position</p>",
"<p><code>txt</code> a string of text</p>",
"<p><code>maxWidth</code> maximum width per line</p>",
"<p><code>xoff, yoff</code> x and y positional offset values</p>"
],
"pname": "p, txt, maxWidth=1000, xoff, yoff"
}
],
"props": [
{
"description": "<h2>a property to reference the space</h2>",
"name": "space",
"param": []
},
{
"description": "<h2>a property to reference the canvas rendering context</h2>",
"name": "cc",
"param": []
},
{
"description": "<h2>a boolean property to set if the next drawing should be filled with current fill style</h2>",
"name": "filled",
"param": []
},
{
"description": "<h2>a boolean property to set if the next drawing should be stroked with current stroke style</h2>",
"name": "stroked",
"param": []
},
{
"description": "<h2>a property to specify the current font size</h2>",
"name": "fontSize",
"param": []
},
{
"description": "<h2>a property to specify the current font face</h2>",
"name": "fontFace",
"param": []
}
],
"statics": [
{
"description": "<h2>A static function to get 2d context from a canvas element in the DOM</h2>",
"eg": "<p><code>Form.context('my_canvas')</code></p>",
"name 40EA ": "context",
"param": [
"<p><code>canvas_id</code> the id attribute of the canvas element</p>"
],
"pname": "canvas_id",
"return": "<p>a canvas rendering context object</p>"
},
{
"description": "<h2>A static function to draw a line</h2>",
"name": "line",
"param": [
"<p><code>ctx</code> canvas rendering context</p>",
"<p><code>pair</code> a Pair object</p>"
],
"pname": "ctx, pair"
},
{
"description": "<h2>A static function to draw a line</h2>",
0