virtual_knitting_machine.visualizer.diagram_settings module

Module containing the Diagram_Settings class.

class Diagram_Settings(Needle_Height=20, Needle_Width=20, Loop_Stack_Overlap=0.6, White_Space_Padding_Proportional_to_Needle=0.25, Minimum_Loop_Portion_of_Needle=0.2, Carriage_Height_in_Needles=1.5, Carriage_Width_in_Needles=2.0, Slider_Background_Color='lightgrey', Carriage_Color='grey', Yarn_Fill_Lightening_Factor=0.3, Needle_Stroke_Color='black', font_family='Arial', font_size=14, Needle_Stroke_Width=1, Loop_Stroke_Width=1, Carrier_Stroke_Width=1, Left_Needle_Buffer=0, Right_Needle_Buffer=0, render_front_labels=True, render_back_labels=True, render_left_labels=True, render_right_labels=True, render_empty_sliders=False, render_carriers=True, render_carriage=True, render_legend=True)[source]

Bases: object

A data class containing the settings for a virtual knitting machine visualization.

Needle_Height: int = 20
Needle_Width: int = 20
Loop_Stack_Overlap: float = 0.6
White_Space_Padding_Proportional_to_Needle: float = 0.25
Minimum_Loop_Portion_of_Needle: float = 0.2
Carriage_Height_in_Needles: float = 1.5
Carriage_Width_in_Needles: float = 2.0
Slider_Background_Color: str = 'lightgrey'
Carriage_Color: str = 'grey'
Yarn_Fill_Lightening_Factor: float = 0.3
Needle_Stroke_Color: str = 'black'
font_family: str = 'Arial'
font_size: int = 14
Needle_Stroke_Width: int = 1
Loop_Stroke_Width: int = 1
Carrier_Stroke_Width: int = 1
Left_Needle_Buffer: int = 0
Right_Needle_Buffer: int = 0
render_front_labels: bool = True
render_back_labels: bool = True
render_left_labels: bool = True
render_right_labels: bool = True
render_empty_sliders: bool = False
render_carriers: bool = True
render_carriage: bool = True
render_legend: bool = True
property carriage_height: float

Returns: float: The height of the carriage element.

property carriage_width: int

Returns: int: The width of the carriage element.

property white_space_padding: int

Returns: int: The required white space padding around elements.

property label_height: int

Returns: int: The reserved vertical spacing for a label including whitespace padding.

side_label_width(has_sliders)[source]
Parameters:

has_sliders (bool) – True if the sliders were rendered.

Returns:

The approximate width of the needle bed side labels based on the font size.

Return type:

float

all_needle_shift(is_all_needle_rack, carriage_direction)[source]
Parameters:
  • is_all_needle_rack (bool) – If True, the back beds are shifted to align with the carriage direction.

  • carriage_direction (Carriage_Pass_Direction) – Direction of the carriage.

Returns:

The amount to shift back bed x coordinates for a given all needle shift

Return type:

int

Notes

If not all needle racking, this is the same as the front-bed’s x-coordinate. In a leftward all needle alignment, the bed is shifted leftward. In a rightward all needle alignment, the bed is shifted rightward

property minimum_needle_size: int

Returns: int: The smallest dimension of a needle box.

property loop_diameter: int

Returns: int: The diameter of a solo-loop on a needle box.

property minimum_loop_diameter: float

Returns: float: The minimum diameter to render a loop on a needle box.

property loop_radius: float

Returns: float: The radius of loop circles based on their proportion of a needle box.

property loop_stack_shift_portion: float

Returns: float: The portion of a loops diameter to shift by when stacking multiple loops on a single needle box.

property loop_stack_top: float

Returns: float: The distance from the top edge of the needle to the top of the top loop stack.

stacked_loop_diameter(loop_count)[source]
Parameters:

loop_count (int) – The number of loops to stack on a needle box.

Returns:

The diameter of the stacked loops adjusted for the number overlapping loops in the stack.

Return type:

float

Notes

The diameter is based on the number of loops in a stack, however a minimum diameter is set to ensure that loops are clearly rendered.

property carrier_size: int

Returns: int: The side length of carrier triangles. Set to 1/3 of the needle width.

x_of_needle(needle_index)[source]
Parameters:

needle_index (int) – The index of the needle to render. Note that this may differ from the slot number if the needle bed does not render from slot 0.

Returns:

The x coordinate position of the left side of the needle slot in the diagram.

Return type:

int

__init__(Needle_Height=20, Needle_Width=20, Loop_Stack_Overlap=0.6, White_Space_Padding_Proportional_to_Needle=0.25, Minimum_Loop_Portion_of_Needle=0.2, Carriage_Height_in_Needles=1.5, Carriage_Width_in_Needles=2.0, Slider_Background_Color='lightgrey', Carriage_Color='grey', Yarn_Fill_Lightening_Factor=0.3, Needle_Stroke_Color='black', font_family='Arial', font_size=14, Needle_Stroke_Width=1, Loop_Stroke_Width=1, Carrier_Stroke_Width=1, Left_Needle_Buffer=0, Right_Needle_Buffer=0, render_front_labels=True, render_back_labels=True, render_left_labels=True, render_right_labels=True, render_empty_sliders=False, render_carriers=True, render_carriage=True, render_legend=True)