Empirical
|
Generator for regular old (cartesian) lines. More...
#include <svg_shapes.h>
Public Member Functions | |
LineGenerator () | |
template<typename X_SCALE_TYPE > | |
void | AddXScale (X_SCALE_TYPE &scale) |
template<typename Y_SCALE_TYPE > | |
void | AddYScale (Y_SCALE_TYPE &scale) |
void | SetX (std::string x) |
void | SetY (std::string y) |
void | SetCurve (std::string curve) |
void | SetTension (float tension) |
void | SetDefined (std::string defined) |
template<typename T , size_t SIZE> | |
std::string | Generate (emp::array< emp::array< T, 2 >, SIZE > &data) |
template<typename T , std::size_t SIZE> | |
Selection | DrawShape (emp::array< emp::array< T, 2 >, SIZE > &data, Selection &s) |
Selection | DrawShape (Dataset data, Selection s) |
DrawShape will also accept a D3::Dataset. More... | |
template<typename T , std::size_t SIZE, std::size_t SIZE2> | |
Selection | DrawShape (emp::array< emp::array< emp::array< T, 2 >, SIZE >, SIZE2 > &data) |
If you pass a triple-nested array, it will be treated as an array of paths. More... | |
int | GetID () const |
void | Log () const |
Protected Attributes | |
int | id |
Generator for regular old (cartesian) lines.
|
inline |
|
inline |
Often, when you're drawing cartesion lines, you want to use a scale to transform numbers from range of your data to the range of pixels on your screen. Adding an X scale will cause the x-coordinates of all points on the line to be passed through that scale function. This stacks on top of whatever the current function for accessing x is (which means scales will also stack).
|
inline |
Often, when you're drawing cartesion lines, you want to use a scale to transform numbers from range of your data to the range of pixels on your screen. Adding a Y scale will cause the y-coordinates of all points on the line to be passed through that scale function. This stacks on top of whatever the current function for accessing y is (which means scales will also stack).
|
inlineinherited |
Draws the path associated with [data] onto the [s] selection (must contain a single SVG) element).
DrawShape will also accept a D3::Dataset.
|
inlineinherited |
If you pass a triple-nested array, it will be treated as an array of paths.
|
inlineinherited |
Generate the string describing the path associated with [data] Assumes [data] is an array of 2-element arrays describing (x,y) coordinates and makes the line that connects them
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Set the method used to interpolate a curve between points in the line. For allowed options, see the d3 documntation
|
inlineinherited |
Set a function indicating where the line is defined (i.e. valid) Can be a C++ function or a string indicating a Javascript function
|
inlineinherited |
If interpolation is "bundle", "cardinal", "cardinal-open", or "cardinal-closed", a tension parameter is used.
|
inline |
If the data that you are generating lines from is anything more complicated than a sequence of pairs of numbers, representing x and y (in that order), you need to tell the line generator how it should figure out what the x coordinate of a point in the line is. The parameter you pass to SetX should be instructions for doing so. It can either be a function (as a string indicating a Javascript function or as a literal C++ function) that accepts an element of the data sequence you are generating the line from, or it can be a constant, in which case the x coordinate of every point will be that constant.
Note: This function will re-set any scales that you've added to the X coordinate
As an example, the default function expects data like this (array of arrays): [[0,0], [1,1], [2,2]] And has (a Javascript equivalent of) this accessor: int x(emp::array<int, 2> d) {return d[0];}
If your data instead looked like this (array of Javascript objects with x and y values): [{x:0, y:0}, {x:1, y:1}, {x:2, y:2}] You might want to use an accessor like this: int x(JSONObject d) {return d.x();} Where JSONObject is a struct designed to hold necessary data from the Javascript object: struct JSONObject { EMP_BUILD_INTROSPECTIVE_TUPLE( int, x, int, y ) };
|
inline |
If the data that you are generating lines from is anything more complicated than a sequence of pairs of numbers, representing x and y (in that order), you need to tell the line generator how it should figure out what the y coordinate of a point in the line is. The parameter you pass to SetY should be instructions for doing so. It can either be a function (as a string indicating a Javascript function or as a literal C++ function) that accepts an element of the data sequence you are generating the line from, or it can be a constant, in which case the y coordinate of every point will be that constant.
Note: This function will re-set any scales that you've added to the Y coordinate
As an example, the default function expects data like this (array of arrays): [[0,0], [1,1], [2,2]] And has (a Javascript equivalent of) this accessor: int x(emp::array<int, 2> d) {return d[1];}
If your data instead looked like this (array of Javascript objects with x and y values): [{x:0, y:0}, {x:1, y:1}, {x:2, y:2}] You might want to use an accessor like this: int x(JSONObject d) {return d.y();} Where JSONObject is a struct designed to hold necessary data from the Javascript object: struct JSONObject { EMP_BUILD_INTROSPECTIVE_TUPLE( int, x, int, y ) };
|
protectedinherited |