virtual_knitting_machine.visualizer.visualizer_elements.diagram_elements.needle_box module
Module containing the Needle_Group class
- class Needle_Box(needle, bed_element, **shape_kwargs)[source]
Bases:
Rect_Element- __init__(needle, bed_element, **shape_kwargs)[source]
Initialize the Rectangle SVG element.
- Parameters:
width (float) – The width of the rectangle in pixels.
height (float) – The height of the rectangle in pixels.
x (float) – The x coordinate of the rectangle’s top left corner.
y (float) – The y coordinate of the rectangle’s top left corner.
name (str) – The name-id of the shape.
stroke_width (int) – The width of the outline of the shape.
fill (str | int, optional) – The fill color of the shape or the factor to lighten the stroke color by. Defaults to no fill color.
stroke (str | float, optional) – The color of the outline of the shape or the factor to darken the fill color by. Defaults to darkening the fill color by a factor of 0.7.
**shape_kwargs (Any) – Additional keyword arguments to pass to the shape.
- property is_front: bool
Returns: bool: True if this represents a front bed needle. False otherwise.
- property is_slider: bool
Returns: bool: True if this represents a slider bed needle. False otherwise.
- property all_needle_rack: bool
Returns: bool: True if the needle bed is set for all needle racking.
- property settings: Diagram_Settings
Returns: Diagram_Settings: The settings of the diagram.
- 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)