Svg3DPanel

class visualife.core.three_d.Svg3DPanel(svg_canvas, width, height)

Bases: object

Represents a panel for displaying 3D objects

Attributes Summary

center_x Center of rotation : X
center_y Center of rotation : Y
center_z Center of rotation : Z
drawing Viewport for this object
offset_x Center of the SVG element: this should be half of SVG box size
offset_y Center of the SVG element: this should be half of SVG box size
scale Returns current scale
z_order

Methods Summary

add_sphere(id, x, y, z, r, **kwargs) Adds sphere at (x,y,z) and also adds a vertex with this coordinates
add_vertex(x, y, z) Adds a vertex to the scene
append_spheres_group(spheres_group) Adds spheres group to the scene
clear() Clears whole scene
count_faces() Count the current number of faces
count_lines() Count the current number of lines
count_spheres() Count the current number of speres
count_vertices() Count the current number of vertics
define_gradient(id, stop1, stop2) Adds gradient to gradiens list
dot_product(vi, vj) Calculates dot product
drag(evt) Performs the actual drag action
draw() Draws all elements in the scene
end_drag(evt) Function called when “mouseup” event is recorded; drag is stopped at that moment
face_at(id, points, **kwargs) Adds face defined by the list of vertices’ ids
key_pressed(evt) Rotates elements in the scene after pressing arrows keys
length(v) Calculates length of vector
line_at(id, vb_index, ve_index, **kwargs) Adds line from vertex with index vb_index to vertex with index ve_index
normalize(v) Normalize vector - it will have length 1
plane_normal(verts)
rotate_vertices() Rotates a vertix with current alpha and beta values
sphere_at(id, v_index, r, **kwargs) Adds sphere in the position of vertex given by index
start_drag(evt) Function called when “mousedown” event is recorded; drag is started at that moment
subtract_vectors(vi, vj) Substruct vi-vj

Attributes Documentation

center_x

Center of rotation : X

center_y

Center of rotation : Y

center_z

Center of rotation : Z

drawing

Viewport for this object

offset_x

Center of the SVG element: this should be half of SVG box size

offset_y

Center of the SVG element: this should be half of SVG box size

scale

Returns current scale

z_order

Methods Documentation

add_sphere(id, x, y, z, r, **kwargs)

Adds sphere at (x,y,z) and also adds a vertex with this coordinates

add_vertex(x, y, z)

Adds a vertex to the scene

append_spheres_group(spheres_group)

Adds spheres group to the scene

clear()

Clears whole scene

count_faces()

Count the current number of faces

count_lines()

Count the current number of lines

count_spheres()

Count the current number of speres

count_vertices()

Count the current number of vertics

define_gradient(id, stop1, stop2)

Adds gradient to gradiens list

static dot_product(vi, vj)

Calculates dot product

drag(evt)

Performs the actual drag action

@param evt: event object passed by a web browser; mouse coordinates are extracted from it

draw()

Draws all elements in the scene

end_drag(evt)

Function called when “mouseup” event is recorded; drag is stopped at that moment

@param evt: event object passed by a web browser

face_at(id, points, **kwargs)

Adds face defined by the list of vertices’ ids

key_pressed(evt)

Rotates elements in the scene after pressing arrows keys

static length(v)

Calculates length of vector

line_at(id, vb_index, ve_index, **kwargs)

Adds line from vertex with index vb_index to vertex with index ve_index

static normalize(v)

Normalize vector - it will have length 1

static plane_normal(verts)
rotate_vertices()

Rotates a vertix with current alpha and beta values

sphere_at(id, v_index, r, **kwargs)

Adds sphere in the position of vertex given by index

start_drag(evt)

Function called when “mousedown” event is recorded; drag is started at that moment

@param evt: event object passed by a web browser

static subtract_vectors(vi, vj)

Substruct vi-vj