Animation module

class factodiagrams.vis.animation.Draw(fps=60, animation_duration=0.3, pause_duration=0.6)

Creates animation of the prime factorization of a number.

This class contains functions displaying the animation of the prime factorization, buttons and the corresponding text.

Parameters
  • fps (int) – animation framerate.

  • animation_duration (float) – fps realization time.

  • pause_duration (float) – pause duration at animation end.

  • txt (str) – text to display.

  • points (list of Point object) – list of points

  • target_positions (list) – list of points positions.

  • status (str) – status of the animation (play or pause).

  • speed (int) – animation speed.

  • n (int) – number to decompose.

Parma speed_txt

text display speed.

compute_current_position(o, t, total_frames, current_frame)

Compute point position at the frame current_frame.

This function calculates the transition point to t from the point o. Used in the “frame” function to calculate each frame of transitions.

Parameters
  • o (list) – coordinates of old point.

  • t (list) – coordinates of new point.

  • total_frames (int) – number of frames between two diagrams.

  • current_frame (int) – current frame number

Returns

coordinates of the transition point for the current frame.

Return type

list

decrease_speed(e)

Creates the “Sp. -” button.

Creates a button that allows you to decrease the speed of the animation. When the speed is negative the animation goes back and display speed text.

display_next_iter()

Display the following diagram.

Displays the following diagram depending on whether the animation is forward or reverse.

display_points(points)

Display points.

Clear previous points and display new points.

Parameters

points (list of Point objects) – list of coordinates for each point.

display_speed()

Displays animation speed.

Displays the expression “Speed :” followed by the speed of the animation.

display_text(n, factors)

Displays the text associated with the number n.

Displays the number to be decomposed and its prime factorization in parentheses.

Parameters
  • n (int) – number to decompose.

  • factors (array) – list of prime factors of n.

frame(n, reverse=False)

Computes positions and display each points at each frame.

This function calculates intermediate points between each diagram for transitions.

Parameters

n (int) – number to decompose.

generate_color(i, n)

Creates RGB code that covers the entire color spectrum.

Parameters
  • i (float) – x coordinate of a point.

  • n (int) – number to decompose.

Returns

3 numbers for colors

Return type

float, float, float

increase_speed(e)

Creates the “Sp. +” button.

Creates a button that allows you to increase the speed of the animation and display speed text.

on_close(e)

Close animation.

play_pause(e)

Creates the “play/pause” button.

It’s a button that displays “pause” when the animation is running and “play” when paused.

class factodiagrams.vis.points.Point(x, y)

Definition of a geometric point (x, y).

factodiagrams.vis.points.generatePoints(factors)

Returns the position of each point according to the number to decompose.

Parameters

factors – list containing the prime factorization of a number.

Returns

list of coordinates for each point

Return type

list of Point object