virtual_knitting_machine.visualizer.visualizer_elements.diagram_elements.carrier_triangle module
Module containing the Carrier Triangle class
- class Carrier_Triangle(carrier, needle_box, diagram_settings, **shape_kwargs)[source]
Bases:
Triangle_ElementWrapper for the SVG element that represents carriers as downward pointed triangles aligned above the needle bed.
- __init__(carrier, needle_box, diagram_settings, **shape_kwargs)[source]
- Parameters:
carrier (Yarn_Carrier) – The carrier represented by this element.
needle_box (Needle_Box | float) – The needle box to get the x-coordinate from or an x-coordinate.
diagram_settings (Diagram_Settings) – The diagram settings used to draw the carrier.
**shape_kwargs (Any) – Keyword arguments used to draw the carrier triangle.
- property carrier: Yarn_Carrier_State
Returns: Yarn_Carrier_State: The carrier represented by this element.
- __getitem__(item)
- add_to_drawing(drawing)
Adds this element to the given svg drawing. :param drawing: The drawing to add. :type drawing: Drawing
- property bottom_vertex: tuple[float, float]
Returns: tuple[float, float]: The bottom vertex of the equilateral triangle pointing downward.
- 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_points: list[tuple[float, float]]
Returns: list[tuple[float, float]]: The global coordinates of the polygon vertices.
- 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)
- property top_left_vertex: tuple[float, float]
Returns: tuple[float, float]: The top left vertex of the equilateral triangle pointing downward.
- property top_right_vertex: tuple[float, float]
Returns: tuple[float, float]: The top right vertex of the equilateral triangle pointing downward.
- property x: float
Returns: float: The x coordinate of this element relative to its parent (or globally).
- property x_coordinates: list[float]
Returns: list[float]: The x coordinate values for each vertex in the polygon.