virtual_knitting_machine.visualizer.visualizer_elements.diagram_elements.loop_circle module
Module containing the Loop_Circle class
- class Loop_Circle(loop, diagram_settings, radius=None, y=None, **shape_kwargs)[source]
Bases:
Circle_ElementWrapper for SVG element that represents a loop placed on a needle in the diagram.
- __init__(loop, diagram_settings, radius=None, y=None, **shape_kwargs)[source]
- Parameters:
loop (Machine_Knit_Loop) – The loop being rendered.
diagram_settings (Diagram_Settings) – The settings for the diagram being rendered.
radius (float, optional) – The radius of the loop circle. Defaults to the radius in the diagram settings.
y (int, optional) – The y position of the loop circle relative to the needle box. Defaults to the mid point of the needle box.
**shape_kwargs (Any) – Additional keyword arguments to pass to the shape.
Notes
If this is the first loop in the stack, it will be centered on the needle box. Subsequent loops will be shifted outward from the needle beds.
- property loop_unique_id: str
Returns: str: The unique string identifier of the loop based on its id, the carrier that formed it, and the needle it is formed on.
- property loop: Machine_Knit_Loop
Returns: Machine_Knit_Loop: The loop that this represents.
- add_to_drawing(drawing)
Adds this element to the given svg drawing. :param drawing: The drawing to add. :type drawing: Drawing
- static darken_color(color='none', factor=0.7)
Darken a hex or named color.
- Parameters:
- Returns:
The color-string of the darkened color. If “none” color is given, this will return “black”.
- Return type:
- static fill_from_stroke(stroke, lighten_factor=0.3)
- property global_x: float
Returns: float: The global x coordinate of this element based on its parent’s coordinates.
- global_x_position(x)
- property global_y: float
Returns: float: The global y coordinate of this element based on its parent’s coordinates.
- global_y_position(y)
- static lighten_color(color='none', factor=0.3)
Lighten a hex or named color.
- Parameters:
- Returns:
The color-string of the lightened color. If “none” color is given, this will return “black”.
- Return type:
- property name: str
Returns: str: The unique name of this element. This will match the id of the svg element being wrapped.
- static stroke_from_fill(fill, darken_factor=0.7)
- class Loop_Stack(loops, needle_box, diagram_settings)[source]
Bases:
Visualizer_Group- property loop_stack_unique_name: str
Returns: str: The unique string identifier for the stack of loops ona specific needle.
- __contains__(element_id)
- __getitem__(element_id)
- add_child(child)
Add the given child element as a sub element to this element. :param child: The child element to add. :type child: Visualizer_Element
- add_to_drawing(drawing)
Adds this element to the given svg drawing. :param drawing: The drawing to add. :type drawing: Drawing
- static darken_color(color='none', factor=0.7)
Darken a hex or named color.
- Parameters:
- Returns:
The color-string of the darkened color. If “none” color is given, this will return “black”.
- Return type:
- static fill_from_stroke(stroke, lighten_factor=0.3)
- property global_x: float
Returns: float: The global x coordinate of this element based on its parent’s coordinates.
- global_x_position(x)
- property global_y: float
Returns: float: The global y coordinate of this element based on its parent’s coordinates.
- global_y_position(y)
- static lighten_color(color='none', factor=0.3)
Lighten a hex or named color.
- Parameters:
- Returns:
The color-string of the lightened color. If “none” color is given, this will return “black”.
- Return type:
- property name: str
Returns: str: The unique name of this element. This will match the id of the svg element being wrapped.
- static stroke_from_fill(fill, darken_factor=0.7)