virtual_knitting_machine.visualizer.visualizer_elements.diagram_elements.needle_bed_element module
Module containing the Needle_Bed_Element class
- class Needle_Bed_Element(is_front, is_slider, leftmost_needle, rightmost_needle, render_sliders, diagram_setting, machine_state)[source]
Bases:
Visualizer_Group- __init__(is_front, is_slider, leftmost_needle, rightmost_needle, render_sliders, diagram_setting, machine_state)[source]
- property all_needle_rack: bool
Returns: bool: True if the machine state is set for all needle rack. False otherwise.
- property carriage_direction: Carriage_Pass_Direction
Returns: Carriage_Pass_Direction: The last direction of movement of the carriage.
- on_bed(needle)[source]
- Parameters:
needle (Needle) – Needle to check if it belongs to this bed.
- Returns:
True if this needle belongs to this bed. False otherwise.
- Return type:
Notes
This does not check that the needle is rendered within the diagram’s window. Only that it belongs to this bed. For full index checking, use in operator.
- property bed_x_shift: int
Returns: int: The amount to horizontally shift this bed based on its position and all needle racking.
- 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)