simetri.extensions package¶
Submodules¶
simetri.extensions.easing module¶
- class simetri.extensions.easing.BackEaseIn(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.BackEaseInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.BackEaseOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.BounceEaseIn(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.BounceEaseInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.BounceEaseOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.CircularEaseIn(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.CircularEaseInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.CircularEaseOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.CubicEaseIn(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.CubicEaseInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.CubicEaseOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.EasingBase(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
object- limit = (0, 1)¶
- class simetri.extensions.easing.ElasticEaseIn(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.ElasticEaseInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.ElasticEaseOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.ExponentialEaseIn(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.ExponentialEaseInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.ExponentialEaseOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.LinearInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.QuadEaseIn(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.QuadEaseInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.QuadEaseOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.QuarticEaseIn(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.QuarticEaseInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.QuarticEaseOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.QuinticEaseIn(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.QuinticEaseInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.QuinticEaseOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.SineEaseIn(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.SineEaseInOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
- class simetri.extensions.easing.SineEaseOut(start: float = 0, end: float = 1, duration: float = 1)[source]¶
Bases:
EasingBase
simetri.extensions.l_system module¶
simetri.extensions.music module¶
Musical notes and scales. MIDI and frequency conversions.
- simetri.extensions.music.jump_scale(scale: Sequence, reference: Any, step: int) Any[source]¶
Return the note in a scale that is a certain number of steps away from a reference note. :param scale: A list of MIDI notes in a scale. :param reference: The reference note. :param step: The number of steps away from the reference note.
- Returns:
The note in the scale that is a certain number of steps away from the reference note.
Example
jump_scale([60, 62, 64, 65, 67, 69, 71], 60, -2) returns 69.
- simetri.extensions.music.midi_freq(m: int) float[source]¶
Return the frequency of a MIDI note number.
- simetri.extensions.music.midi_m(freq: float) int[source]¶
Return the MIDI note number of a frequency.
simetri.extensions.ndfsm module¶
simetri.extensions.turtle_sg module¶
Turtle graphics variant, with a twist.
- class simetri.extensions.turtle_sg.State(pos: tuple, angle: float, pen_is_down: bool)[source]¶
Bases:
objectA state of the turtle.
- pos¶
The position of the turtle.
- Type:
tuple
- angle¶
The angle of the turtle.
- Type:
float
- pen_is_down¶
Whether the pen is down.
- Type:
bool
- angle: float¶
- pen_is_down: bool¶
- pos: tuple¶
- class simetri.extensions.turtle_sg.Turtle(*args: Any, in_degrees: bool = False, **kwargs: Any)[source]¶
Bases:
BatchA Turtle graphics variant, with a twist.
This class implements a turtle graphics system that can be used to draw geometric shapes and patterns.
- Parameters:
*args – Variable length argument list passed to the parent class.
in_degrees (bool, optional) – Whether angles are measured in degrees. Defaults to False.
**kwargs – Arbitrary keyword arguments passed to the parent class.
- property angle: float¶
Return the current angle of the turtle.
The angle is clamped to the appropriate range based on the angle mode.
- Returns:
The current angle, normalized to 0-360 degrees or 0-2π radians.
- Return type:
float
- backward(dist: float | None = None) None[source]¶
Move the turtle backward by the given distance.
- Parameters:
dist (float, optional) – The distance to move backward. Defaults to self.def_dist.
- forward(dist: float | None = None) None[source]¶
Move the turtle forward by the given distance.
Moves the turtle and draws a line if the pen is down.
- Parameters:
dist (float, optional) – The distance to move forward. Defaults to self.def_dist.
- go(dist: float | None = None) None[source]¶
Move the turtle forward without drawing.
Moves the turtle regardless of the pen state, and doesn’t draw. Saves the current path and starts a new one.
- Parameters:
dist (float, optional) – The distance to move forward. Defaults to self.def_dist.
- left(angle: float | None = None) None[source]¶
Turn the turtle left by the given angle.
- Parameters:
angle (float, optional) – The angle to turn left. Defaults to self.def_angle.
- move_to(pos: tuple) None[source]¶
Move the turtle to the given position.
- Parameters:
pos (tuple) – The target position as (x, y) coordinates.
- pen_down() None[source]¶
Lower the pen.
Enables drawing when the turtle moves and adds the current position to the current path.
- pen_up() None[source]¶
Lift the pen.
Stops drawing and saves the current path when the turtle moves.
- pop() None[source]¶
Restore the last saved state of the turtle.
Retrieves the most recently saved state and restores the turtle to it.
- push() None[source]¶
Save the current state of the turtle.
Stores the current position, angle, and pen state for later retrieval.
- reset() None[source]¶
Reset the turtle to its initial state.
Appends the current shape to the batch and resets position, angle, and pen state.
- simetri.extensions.turtle_sg.add_digits(n: int) int[source]¶
Return the sum of the digits of n.
Spirolateral helper function that adds all digits in a number.
- Parameters:
n (int) – The number to process.
- Returns:
The sum of all digits in n.
- Return type:
int
Examples
10 -> 1 + 0 -> 1 123 -> 1 + 2 + 3 -> 6
- simetri.extensions.turtle_sg.spiral(turtle: Turtle, side: float, angle: float, delta: float, cycles: int = 15) Turtle[source]¶
Draw a spiral with the given side, angle, delta, and cycles.
- Parameters:
turtle (Turtle) – The turtle object to use for drawing.
side (float) – Initial length of the side.
angle (float) – Angle to turn after drawing each side.
delta (float) – Amount to increase the side length in each step.
cycles (int, optional) – Number of segments to draw. Defaults to 15.
- Returns:
The turtle object used for drawing.
- Return type:
- simetri.extensions.turtle_sg.spirolateral(sequence: Sequence, angle: float, cycles: int = 15, multiplier: float = 50) Turtle[source]¶
Draw a spirolateral with the given sequence and angle.
- Parameters:
sequence (Sequence) – Sequence of numbers determining segment lengths.
angle (float) – Angle in degrees for turns.
cycles (int, optional) – Number of cycles to draw. Defaults to 15.
multiplier (float, optional) – Scaling factor for segment lengths. Defaults to 50.
- Returns:
The turtle object used for drawing.
- Return type: