Methods
(static) canvas_px_to_window_px(canvas_pt) → {Array.<float>}
get the position of the mouseclick event wrt canvas
Parameters:
Name | Type | Description |
---|---|---|
canvas_pt |
Array.<float> | the [x, y] position wrt canvas |
- Source:
Returns:
x and y position wrt window
- Type
- Array.<float>
(static) compute_edge_geometry(graph, edge) → {Array.<Object>}
computes the geometric start, end, and quadratic bezier curve control
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | the graph containing the edge |
edge |
Object | the edge we want to compute the start and end and mid of |
- Source:
Returns:
[start, end, mid], all 2d vectors
- Type
- Array.<Object>
(static) compute_edge_start_end(graph, edge) → {Array.<Object>}
computes the geometric start and end of the edge wrt canvas
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | the graph containing the edge |
edge |
Object | the edge we want to compute the start and end of |
- Source:
Returns:
[start, end], both 2d vectors
- Type
- Array.<Object>
(static) draw(graph)
draw the entire graph on the canvas
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | the graph object to draw on the canvas |
- Source:
(static) draw_arrow(start, end, mid, edge_text, text_size)
draw an curved array with start, end and a mid
Parameters:
Name | Type | Description |
---|---|---|
start |
Array.<float> | where to begin |
end |
Array.<float> | where to end |
mid |
Array.<float> | control point for quadratic bezier curve |
edge_text |
string | the text to display on the edge |
text_size |
float | the size of the text |
- Source:
(static) draw_circle(x, y, r, highlighted, thickness)
draw a circle on the current canvas
Parameters:
Name | Type | Description |
---|---|---|
x |
int | x position from left wrt canvas |
y |
int | y position from top wrt canvas |
r |
int | radius of the circle |
highlighted |
boolean | if true, fill the circle with color |
thickness |
float | line width |
- Source:
(static) draw_edge(graph, edge, text_size)
draws the edge object on the canvas
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | the graph containing the edge |
edge |
Object | the edge object you want to draw |
text_size |
float | the font size of the transition label |
- Source:
(static) draw_final_circle(vertex)
draws a smaller concentric circle within the vertex
Parameters:
Name | Type | Description |
---|---|---|
vertex |
Object | the vertex object in which we want to draw a circle |
- Source:
(static) draw_text(text, pos, size, text_align, color_map)
draw text on the canvas
Parameters:
Name | Type | Description |
---|---|---|
text |
string | the text you want to draw on the screen |
pos |
Array.<float> | the position wrt canvas |
size |
float | font size |
text_align |
string | choice from {'center', 'left', 'right'} |
color_map |
Array.<string> | an array of colors the same length as the text coding the color of each char |
- Source:
(static) draw_triangle(tip1, tip2, tip3)
draw a triangle with three tips provided
Parameters:
Name | Type | Description |
---|---|---|
tip1 |
Array.<float> | |
tip2 |
Array.<float> | |
tip3 |
Array.<float> |
- Source:
(static) draw_vertex(vertex)
given the name of the vertex, grab the vertex from graph and draw it on screen
Parameters:
Name | Type | Description |
---|---|---|
vertex |
Object | the vertex we want to draw |
- Source:
(static) event_position_on_canvas(e) → {Array.<float>}
get the position of the mouseclick event wrt canvas
Parameters:
Name | Type | Description |
---|---|---|
e |
Object |
- Source:
Returns:
x and y position of the mouseclick wrt canvas
- Type
- Array.<float>
(static) get_canvas()
get the machine drawing canvas
- Source:
Returns:
the canvas object on which the machine is drawn
(static) highlight_states(graph, cur_states)
remove old highlited vertexes and mark current vertexes as highlited
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | |
cur_states |
Iterable.<string> | vertex names |
- Source:
(static) in_any_vertex(graph, x, y) → {string}
detects if the current click is inside a vertex
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | the graph of interest |
x |
float | x position wrt canvas |
y |
float | y position wrt canvas |
- Source:
Returns:
returns the first vertex in the graph that contains (x, y), null otherwise
- Type
- string
(static) in_edge_text(graph, x, y) → {Object}
detects if the current click is inside edge text
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | the graph of interest |
x |
float | x position wrt canvas |
y |
float | y position wrt canvas |
- Source:
Returns:
returns the first edge in the graph that contains (x, y), null otherwise
- Type
- Object
(static) in_vertex(graph, x, y, v) → {boolean}
checks if (x, y) wrt canvas is inside vertex v
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | the graph of interest |
x |
float | x position |
y |
float | y position |
v |
string | name of the vertex |
- Source:
Returns:
whether (x, y) is in v
- Type
- boolean
(static) save_as_png(graph)
grab the current graph and download onto user's computer
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | the graph object whose drawing is to be downloaded |
- Source:
(static) viz_NFA_input(input_str, index)
displays the input_str and highlight the character being processed at this step
Parameters:
Name | Type | Description |
---|---|---|
input_str |
string | the machine input that is currently being run |
index |
int | index of the input_str the machine is currently consuming |
- Source:
(static) viz_PDA_configs(graph, PDA_configs)
Displays each compute configuration near the vertex the non-deterministic branch is at
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | |
PDA_configs |
Map.<string, Array.<string>> | set of PDA configurations. Using map to avoid duplicates the key is the serialized configuration as a string |
- Source:
(static) viz_TM_tape(tape, tape_idx)
displays the relavant section of the Turing Machine tape as an overlay
Parameters:
Name | Type | Description |
---|---|---|
tape |
Map.<int, string> | tape contents indexed by position. Using map due to potentially neg index |
tape_idx |
int | the current tape head position |
- Source:
(inner) compute_machine_drawing_size(graph) → {Array.<Array.<float>>}
Computes the total size taken by the graph drawing on the canvas
Parameters:
Name | Type | Description |
---|---|---|
graph |
Object | target graph |
- Source:
Returns:
- [[xmin, ymin], [xmax, ymax]] enclosing the graph
- Type
- Array.<Array.<float>>
(inner) drawSplit(start, end, mid)
draw a split arrow with start, end and a mid
do not draw points if the distance from point to mid is less than radius
Parameters:
Name | Type | Description |
---|---|---|
start |
Array.<float> | where to begin |
end |
Array.<float> | where to end |
mid |
Array.<float> | control point for quadratic bezier curve |
- Source:
(inner) text_size_heuristic(textbox_width, text) → {int}
computes an appropriate text size to display the label
Parameters:
Name | Type | Description |
---|---|---|
textbox_width |
int | width of textbox in pxiels |
text |
string | the text message to display |
- Source:
Returns:
fontsize in pixels
- Type
- int