Module core.GraphPainter

Class that handles the painting of a feed-forward neural network graph.

Functions

GraphPainter.new (r) Constructor.
GraphPainter:calc_size (layer_array, bias_array, zoom, y_space, show_bias) Calculates the sizes of the graph elements.
GraphPainter:draw_connection (cr, x1, y1, x2, y2, w, color) Draws a connection.
GraphPainter:draw_neuron (cr, xc, yc, r, color) Draws a neuron as a circle.

Tables

Color RGB color representation (referenced in the draw_* methods).


Functions

GraphPainter.new (r)
Constructor.

Parameters

  • r: Neuron radius (it's used as base for the other sizes too)

Return value:

New instance of GraphPainter
GraphPainter:calc_size (layer_array, bias_array, zoom, y_space, show_bias)
Calculates the sizes of the graph elements.

Parameters

  • layer_array: Array with number of neurons in each layer
  • bias_array:
  • zoom: Zoom level of the graph ( default = 1 (100%) )
  • y_space: Spacing between layers ( default = 1 (100%) )
  • show_bias: To show the bias neurons too ( default = false )

Return value:

width, height, zoom, y_space, new radius, max layer size, space ratio, border spacing
GraphPainter:draw_connection (cr, x1, y1, x2, y2, w, color)
Draws a connection.

Parameters

  • cr: Cairo context to be used
  • x1: from x
  • y1: from y
  • x2: to x
  • y2: to y
  • w: Connection width
  • color: Connection color
GraphPainter:draw_neuron (cr, xc, yc, r, color)
Draws a neuron as a circle.

Parameters

  • cr: Cairo context to be used
  • xc: x-center of the neuron
  • yc: y-center of the neuron
  • r: radius of the neuron
  • color: Color of the neuron (fill)

Tables

Color
RGB color representation (referenced in the draw_* methods).

Parameters

  • 1: red (0 to 1)
  • 2: green (0 to 1)
  • 3: blue (0 to 1)

Valid XHTML 1.0!