Empirical
Namespaces | Classes | Functions
emp::web Namespace Reference

Namespaces

 internal
 

Classes

class  Animate
 An object that, when active, repeatedly calls a function as fast as possible, to a maximum of 60 frames per second. More...
 
class  Attributes
 Maintains a map of attribute names to values for use in JavaScript Closely related to Style.h, which is for CSS-values. More...
 
class  Button
 Create or control an HTML Button object that you can manipulate and update as needed. More...
 
class  Canvas
 Manage an HTML Canvas object. More...
 
class  CanvasAction
 Base class to maintain canvas actions. More...
 
class  CanvasCircle
 Track a circle shape to be drawn on a canvas. More...
 
class  CanvasClearRect
 Clear a rectangular area in a canvas. More...
 
class  CanvasFont
 Change the default font to be used. More...
 
class  CanvasImage
 Change the default font to be used. More...
 
class  CanvasLine
 A line segment on the canvas. More...
 
class  CanvasMultiLine
 
class  CanvasPolygon
 An arbitrary-sized polygon to be drawn on a canvas. More...
 
class  CanvasRect
 Track a rectangle shape to be drawn on a canvas. More...
 
class  CanvasRotate
 Rotate the entire canvas for subsequent drawings. More...
 
class  CanvasShape
 Define an arbitrary shape to draw on a canvas (base clase) More...
 
class  CanvasStrokeColor
 Set the line color on subsequent draw-related actions. More...
 
class  CanvasText
 Text to be written on a canvas. More...
 
class  Close
 
class  D3Visualization
 
class  Div
 A widget to track a div in an HTML file, and all of its contents. More...
 
class  Document
 
class  DotPlot
 
struct  Event
 Data common to all web events. More...
 
class  FileInput
 
class  Font
 Maintain information about an HTML font. More...
 
class  HeatMap
 
class  HistogramChart
 
class  Image
 
struct  KeyboardEvent
 Keyboard-specific information about web events. More...
 
class  KeypressManager
 
class  LineGraph
 
class  Listeners
 Track a set of JavaScript Listeners with their callback IDs. More...
 
struct  MouseEvent
 Mouse-specific information about web events. More...
 
class  PrintStr
 The PrintStr command will print a pre-specified string to a widget. More...
 
class  Selector
 
struct  SpatialGridTreeNode
 
class  SpatialGridTreeVisualization
 
class  Style
 
class  Table
 
class  TableCell
 An object that focuses on a single cell in a specified table. More...
 
class  TableCol
 An object that focuses on a single column in a specified table. More...
 
class  TableColGroup
 An object that focuses on a group of columns in a specified table. More...
 
class  TableRow
 An object that focuses on a single column in a specified table. More...
 
class  TableRowGroup
 An object that focuses on a group of rows in a specified table. More...
 
class  TableWidget
 
class  Text
 A Text widget handles putting text on a web page that can be controlled and modified. More...
 
class  TextArea
 
struct  TreeDataNode
 
struct  TreeNode
 
class  TreeVisualization
 
class  TreeVisualizationReplacement
 
class  Tween
 
struct  WheelEvent
 Mouse-wheel-specific information about web events. More...
 
class  Widget
 Widget is effectively a smart pointer to a WidgetInfo object, plus some basic accessors. More...
 
struct  WidgetExtras
 

Functions

void Draw (Canvas canvas, const emp::Circle &circle, const std::string &fill="", const std::string &line="")
 Draw a Circle onto the canvas. More...
 
template<size_t COLS, size_t ROWS>
void Draw (Canvas canvas, const BitMatrix< COLS, ROWS > &matrix, double w, double h)
 Draw a BitMatrix onto a canvas using black and white squares (can specify cell width and height) More...
 
template<typename BODY_TYPE >
void Draw (Canvas canvas, const Surface2D< BODY_TYPE > &surface, const emp::vector< std::string > &color_map)
 
template<typename BODY_TYPE >
void Draw (Canvas canvas, const Surface2D< BODY_TYPE > &surface, size_t num_colors)
 
void Draw (Canvas canvas, const emp::vector< emp::vector< size_t >> &grid, const emp::vector< std::string > &color_map, std::string line_color, double cell_width, double cell_height, double offset_x, double offset_y)
 
void Draw (Canvas canvas, const emp::vector< emp::vector< size_t >> &grid, const emp::vector< std::string > &color_map, std::string line_color, double cell_w, double cell_h)
 
void Draw (Canvas canvas, const emp::vector< emp::vector< size_t >> &grid, const emp::vector< std::string > &color_map, std::string line_color="black")
 
void Draw (Canvas canvas, const emp::vector< size_t > &grid, size_t grid_cols, const emp::vector< std::string > &color_map, std::string line_color, double cell_width, double cell_height, double offset_x, double offset_y)
 
void Draw (Canvas canvas, const StateGrid &state_grid, const emp::vector< std::string > &color_map, std::string line_color="black")
 
void DrawGridBG (Canvas canvas, size_t rows, size_t cols, const std::string &bg_color, const std::string &line_color)
 
template<typename CONTAINER_T , typename POINT_FUN_T , typename COLOR_FUN_T >
void DrawPoints (Canvas canvas, CONTAINER_T &&container, double radius, POINT_FUN_T &&point_fun, COLOR_FUN_T &&color_fun, const std::string &line_color="black")
 
static const PrintStr endl ("<br>")
 Pre-define emp::endl to insert a "<br>" and thus acting like a newline. More...
 
template<typename FUN_TYPE >
void OnDocumentReady (FUN_TYPE &&fun)
 Runs the specified function when the document is finished loading and being set up. More...
 

Function Documentation

void emp::web::Draw ( Canvas  canvas,
const emp::Circle circle,
const std::string &  fill = "",
const std::string &  line = "" 
)

Draw a Circle onto the canvas.

template<size_t COLS, size_t ROWS>
void emp::web::Draw ( Canvas  canvas,
const BitMatrix< COLS, ROWS > &  matrix,
double  w,
double  h 
)

Draw a BitMatrix onto a canvas using black and white squares (can specify cell width and height)

template<typename BODY_TYPE >
void emp::web::Draw ( Canvas  canvas,
const Surface2D< BODY_TYPE > &  surface,
const emp::vector< std::string > &  color_map 
)

Draw a Surface2D, specifying the full colormap to be used. The surface has a range of circle bodies, each with a color id.

Parameters
canvasThe Canvas to draw on.
surfaceA surface containing a set of shapes to draw.
color_mapMapping of values to the colors with which they should be associated.
template<typename BODY_TYPE >
void emp::web::Draw ( Canvas  canvas,
const Surface2D< BODY_TYPE > &  surface,
size_t  num_colors 
)

Draw a Surface2D, just specifying the number of colors (and using a generated hue map). The surface has a range of circle bodies, each with a color id.

Parameters
canvasThe Canvas to draw on.
surfaceA surface containing a set of shapes to draw.
num_colorsThe number of distinct colors to use in visualization.
void emp::web::Draw ( Canvas  canvas,
const emp::vector< emp::vector< size_t >> &  grid,
const emp::vector< std::string > &  color_map,
std::string  line_color,
double  cell_width,
double  cell_height,
double  offset_x,
double  offset_y 
)

Draw a grid onto a canvas.

Parameters
canvasThe Canvas to draw on.
gridA vector of vectors of color IDs.
color_mapMapping of values to the colors with which they should be associated.
line_colorThe background line color for the grid.
cell_widthHow many pixels wide is each cell to draw?
cell_heightHow many pixels tall is each cell to draw?
offset_xHow far should we shift the grid relative to the left side of the canvas?
offset_yHow far should we shift the grid relative to the top of the canvas?
void emp::web::Draw ( Canvas  canvas,
const emp::vector< emp::vector< size_t >> &  grid,
const emp::vector< std::string > &  color_map,
std::string  line_color,
double  cell_w,
double  cell_h 
)

Draw a grid onto a canvas, but without offsets provided – the grid is centered.

Parameters
canvasThe Canvas to draw on.
gridA vector of vectors of color IDs.
color_mapMapping of values to the colors with which they should be associated.
line_colorThe background line color for the grid.
cell_widthHow many pixels wide is each cell to draw?
cell_heightHow many pixels tall is each cell to draw?
void emp::web::Draw ( Canvas  canvas,
const emp::vector< emp::vector< size_t >> &  grid,
const emp::vector< std::string > &  color_map,
std::string  line_color = "black" 
)

Draw a grid onto a canvas, but without cell size provided – maximize to fill the canvas!

Parameters
canvasThe Canvas to draw on.
gridA vector of vectors of color IDs.
color_mapMapping of values to the colors with which they should be associated.
line_colorThe background line color for the grid.
void emp::web::Draw ( Canvas  canvas,
const emp::vector< size_t > &  grid,
size_t  grid_cols,
const emp::vector< std::string > &  color_map,
std::string  line_color,
double  cell_width,
double  cell_height,
double  offset_x,
double  offset_y 
)

Draw a vector onto a canvas as a grid.

Parameters
canvasThe Canvas to draw on.
gridA vector of vectors of color IDs
grid_colsNumber of columns in the grid
color_mapMapping of values to the colors with which they should be associated.
line_colorThe background line color for the grid
cell_widthHow many pixels wide is each cell to draw?
cell_heightHow many pixels tall is each cell to draw?
offset_xHow far should we shift the grid relative to the left side of the canvas?
offset_yHow far should we shift the grid relative to the top of the canvas?
void emp::web::Draw ( Canvas  canvas,
const StateGrid state_grid,
const emp::vector< std::string > &  color_map,
std::string  line_color = "black" 
)

Draw a state grid onto a canvas.

Parameters
canvasThe Canvas to draw on.
state_gridA StateGrid object.
color_mapMapping of values to the colors with which they should be associated.
line_colorThe background line color for the grid.
void emp::web::DrawGridBG ( Canvas  canvas,
size_t  rows,
size_t  cols,
const std::string &  bg_color,
const std::string &  line_color 
)

Draw a grid as the background of a canvas. Since this is a BG, clear the canvas first.

Parameters
canvasThe Canvas to draw on.
rowsNumber of rows to draw in the grid.
colsNumber of columns to draw in the grid.
bg_colorThe background color for the grid.
line_colorThe color of the liens on the grid.
template<typename CONTAINER_T , typename POINT_FUN_T , typename COLOR_FUN_T >
void emp::web::DrawPoints ( Canvas  canvas,
CONTAINER_T &&  container,
double  radius,
POINT_FUN_T &&  point_fun,
COLOR_FUN_T &&  color_fun,
const std::string &  line_color = "black" 
)
static const PrintStr emp::web::endl ( "<br>"  )
static

Pre-define emp::endl to insert a "<br>" and thus acting like a newline.

template<typename FUN_TYPE >
void emp::web::OnDocumentReady ( FUN_TYPE &&  fun)

Runs the specified function when the document is finished loading and being set up.