simetri.tikz package¶
Submodules¶
simetri.tikz.tikz module¶
TikZ exporter. Draws shapes using the TikZ package for LaTeX. Sketch objects are converted to TikZ code.
- class simetri.tikz.tikz.Grid(p1, p2, dx, dy, **kwargs)[source]¶
Bases:
Shape
Grid shape.
- Parameters:
p1 – (x_min, y_min)
p2 – (x_max, y_max)
dx – x step
dy – y step
- class simetri.tikz.tikz.Tex(begin_document: str = '\\begin{document}\n', end_document: str = '\\end{document}\n', begin_tikz: str = '\\begin{tikzpicture}[x=1pt, y=1pt, scale=1]\n', end_tikz: str = '\\end{tikzpicture}\n', packages: List[str] = None, tikz_libraries: List[str] = None, tikz_code: str = '', sketches: List['Sketch'] = <factory>)[source]¶
Bases:
object
Tex class for generating tex code.
- begin_document¶
The beginning of the document.
- Type:
str
- end_document¶
The end of the document.
- Type:
str
- begin_tikz¶
The beginning of the TikZ environment.
- Type:
str
- end_tikz¶
The end of the TikZ environment.
- Type:
str
- packages¶
List of required TeX packages.
- Type:
List[str]
- tikz_libraries¶
List of required TikZ libraries.
- Type:
List[str]
- tikz_code¶
The generated TikZ code.
- Type:
str
- sketches¶
List of TexSketch objects.
- Type:
List[“Sketch”]
- begin_document: str = '\\begin{document}\n'¶
- begin_tikz: str = '\\begin{tikzpicture}[x=1pt, y=1pt, scale=1]\n'¶
- end_document: str = '\\end{document}\n'¶
- end_tikz: str = '\\end{tikzpicture}\n'¶
- get_doc_class(border: float, font_size: int) str [source]¶
Returns the document class.
- Parameters:
border (float) – The border size.
font_size (int) – The font size.
- Returns:
The document class string.
- Return type:
str
- get_packages(canvas) str [source]¶
Returns the required TeX packages.
- Parameters:
canvas – The canvas object.
- Returns:
The required TeX packages.
- Return type:
str
- get_preamble(canvas) str [source]¶
Returns the TeX preamble.
- Parameters:
canvas – The canvas object.
- Returns:
The TeX preamble.
- Return type:
str
- get_tikz_libraries() str [source]¶
Returns the TikZ libraries.
- Returns:
The TikZ libraries string.
- Return type:
str
- packages: List[str] = None¶
- sketches: List['Sketch']¶
- tex_code(canvas: Canvas, aux_code: str) str [source]¶
Generate the final TeX code.
- Parameters:
canvas ("Canvas") – The canvas object.
aux_code (str) – Auxiliary code to include.
- Returns:
The final TeX code.
- Return type:
str
- tikz_code: str = ''¶
- tikz_libraries: List[str] = None¶
- simetri.tikz.tikz.color2tikz(color)[source]¶
Converts a Color object to a TikZ color string.
- Parameters:
color (Color) – The color object.
- Returns:
The TikZ color string.
- Return type:
str
- simetri.tikz.tikz.draw_arc_sketch(sketch)[source]¶
Draws an arc sketch.
- Parameters:
sketch – The arc sketch object.
- Returns:
The TikZ code for the arc sketch.
- Return type:
str
- simetri.tikz.tikz.draw_batch_sketch(sketch, canvas)[source]¶
Converts a BatchSketch to TikZ code.
- Parameters:
sketch – The BatchSketch object.
canvas – The canvas object.
- Returns:
The TikZ code for the BatchSketch.
- Return type:
str
- simetri.tikz.tikz.draw_bbox_sketch(sketch, canvas)[source]¶
Converts a BBoxSketch to TikZ code.
- Parameters:
sketch – The BBoxSketch object.
canvas – The canvas object.
- Returns:
The TikZ code for the BBoxSketch.
- Return type:
str
- simetri.tikz.tikz.draw_bezier_sketch(sketch)[source]¶
Draws a Bezier curve sketch.
- Parameters:
sketch – The Bezier curve sketch object.
- Returns:
The TikZ code for the Bezier curve sketch.
- Return type:
str
- simetri.tikz.tikz.draw_circle_sketch(sketch)[source]¶
Draws a circle sketch.
- Parameters:
sketch – The circle sketch object.
- Returns:
The TikZ code for the circle sketch.
- Return type:
str
- simetri.tikz.tikz.draw_ellipse_sketch(sketch)[source]¶
Draws an ellipse sketch.
- Parameters:
sketch – The ellipse sketch object.
- Returns:
The TikZ code for the ellipse sketch.
- Return type:
str
- simetri.tikz.tikz.draw_lace_sketch(item)[source]¶
Converts a LaceSketch to TikZ code.
- Parameters:
item – The LaceSketch object.
- Returns:
The TikZ code for the LaceSketch.
- Return type:
str
- simetri.tikz.tikz.draw_line(line)[source]¶
Tikz code for a line.
- Parameters:
line – The line object.
- Returns:
The TikZ code for the line.
- Return type:
str
- simetri.tikz.tikz.draw_line_sketch(sketch)[source]¶
Draws a line sketch.
- Parameters:
sketch – The line sketch object.
- Returns:
The TikZ code for the line sketch.
- Return type:
str
- simetri.tikz.tikz.draw_rect_sketch(sketch)[source]¶
Draws a rectangle sketch.
- Parameters:
sketch – The rectangle sketch object.
- Returns:
The TikZ code for the rectangle sketch.
- Return type:
str
- simetri.tikz.tikz.draw_shape_sketch(sketch, ind=None)[source]¶
Draws a shape sketch.
- Parameters:
sketch – The shape sketch object.
ind – Optional index for the shape sketch.
- Returns:
The TikZ code for the shape sketch.
- Return type:
str
- simetri.tikz.tikz.draw_shape_sketch_with_indices(sketch, ind)[source]¶
Draws a shape sketch with circle markers with index numbers in them.
- Parameters:
sketch – The shape sketch object.
ind – The index.
- Returns:
The TikZ code for the shape sketch with indices.
- Return type:
str
- simetri.tikz.tikz.draw_shape_sketch_with_markers(sketch)[source]¶
Draws a shape sketch with markers.
- Parameters:
sketch – The shape sketch object.
- Returns:
The TikZ code for the shape sketch with markers.
- Return type:
str
- simetri.tikz.tikz.draw_sketch(sketch)[source]¶
Draws a plain shape sketch.
- Parameters:
sketch – The shape sketch object.
- Returns:
The TikZ code for the plain shape sketch.
- Return type:
str
- simetri.tikz.tikz.draw_tag_sketch(sketch, canvas)[source]¶
Converts a TagSketch to TikZ code.
- Parameters:
sketch – The TagSketch object.
canvas – The canvas object.
- Returns:
The TikZ code for the TagSketch.
- Return type:
str
- simetri.tikz.tikz.frame_options(sketch: TagSketch) List[str] [source]¶
Returns the options for the frame of the tag node.
- Parameters:
sketch (TagSketch) – The tag sketch object.
- Returns:
The options for the frame of the tag node.
- Return type:
List[str]
- simetri.tikz.tikz.get_axis_shading_colors(sketch)[source]¶
Returns the shading colors for the axis.
- Parameters:
sketch – The sketch object.
- Returns:
The shading colors for the axis.
- Return type:
str
- simetri.tikz.tikz.get_back_code(canvas: Canvas) str [source]¶
Get the background code for the canvas.
- Parameters:
canvas ("Canvas") – The canvas object.
- Returns:
The background code.
- Return type:
str
- simetri.tikz.tikz.get_back_grid_code(grid: Grid, canvas: Canvas) str [source]¶
Page background grid code.
- Parameters:
grid (Grid) – The grid object.
canvas ("Canvas") – The canvas object.
- Returns:
The background grid code.
- Return type:
str
- simetri.tikz.tikz.get_begin_scope(ind=None)[source]¶
Returns egin{scope}[every node/.append style=nodestyle{ind}].
- Parameters:
ind – Optional index for the scope.
- Returns:
The begin scope string.
- Return type:
str
- simetri.tikz.tikz.get_bilinear_shading_colors(sketch)[source]¶
Returns the shading colors for the bilinear shading.
- Parameters:
sketch – The sketch object.
- Returns:
The shading colors for the bilinear shading.
- Return type:
str
- simetri.tikz.tikz.get_canvas_scope(canvas)[source]¶
Returns the TikZ code for the canvas scope.
- Parameters:
canvas – The canvas object.
- Returns:
The TikZ code for the canvas scope.
- Return type:
str
- simetri.tikz.tikz.get_clip_code(item: 'Sketch' | 'Canvas') str [source]¶
Returns the clip code for a sketch or Canvas.
- Parameters:
item (Union["Sketch", "Canvas"]) – The item to get clip code for.
- Returns:
The clip code as a string.
- Return type:
str
- simetri.tikz.tikz.get_dash_pattern(line_dash_array)[source]¶
Returns the dash pattern for a line.
- Parameters:
line_dash_array – The dash array for the line.
- Returns:
The dash pattern as a string.
- Return type:
str
- simetri.tikz.tikz.get_draw(sketch)[source]¶
Returns the draw command for sketches.
- Parameters:
sketch – The sketch object.
- Returns:
The draw command as a string.
- Return type:
str
- simetri.tikz.tikz.get_end_scope()[source]¶
Returns end{scope}.
- Returns:
The end scope string.
- Return type:
str
- simetri.tikz.tikz.get_fill_style_options(sketch, exceptions=None, frame=False)[source]¶
Returns the options for the fill style.
- Parameters:
sketch – The sketch object.
exceptions – Optional exceptions for the fill style options.
frame – Optional flag for frame fill style.
- Returns:
The fill style options as a list.
- Return type:
list
- simetri.tikz.tikz.get_frame_options(sketch)[source]¶
Returns the options for the frame of a TagSketch.
- Parameters:
sketch – The TagSketch object.
- Returns:
The options for the frame of the TagSketch.
- Return type:
list
- simetri.tikz.tikz.get_limits_code(canvas: Canvas) str [source]¶
Get the limits of the canvas for clipping.
- Parameters:
canvas ("Canvas") – The canvas object.
- Returns:
The limits code for clipping.
- Return type:
str
- simetri.tikz.tikz.get_line_style_options(sketch, exceptions=None)[source]¶
Returns the options for the line style.
- Parameters:
sketch – The sketch object.
exceptions – Optional exceptions for the line style options.
- Returns:
The line style options as a list.
- Return type:
list
- simetri.tikz.tikz.get_marker_options(sketch)[source]¶
Returns the options for the markers.
- Parameters:
sketch – The sketch object.
- Returns:
The marker options as a list.
- Return type:
list
- simetri.tikz.tikz.get_min_size(sketch: ShapeSketch) str [source]¶
Returns the minimum size of the tag node.
- Parameters:
sketch (ShapeSketch) – The shape sketch object.
- Returns:
The minimum size of the tag node.
- Return type:
str
- simetri.tikz.tikz.get_pattern_options(sketch)[source]¶
Returns the options for the patterns.
- Parameters:
sketch – The sketch object.
- Returns:
The pattern options as a list.
- Return type:
list
- simetri.tikz.tikz.get_radial_shading_colors(sketch)[source]¶
Returns the shading colors for the radial shading.
- Parameters:
sketch – The sketch object.
- Returns:
The shading colors for the radial shading.
- Return type:
str
- simetri.tikz.tikz.get_scope_options(item: 'Canvas' | 'Sketch') str [source]¶
Used for creating namespaces in TikZ.
- Parameters:
item (Union["Canvas", "Sketch"]) – The item to get scope options for.
- Returns:
The scope options as a string.
- Return type:
str
- simetri.tikz.tikz.get_shading_options(sketch)[source]¶
Returns the options for the shading.
- Parameters:
sketch – The sketch object.
- Returns:
The shading options as a list.
- Return type:
list
- simetri.tikz.tikz.get_tex_code(canvas: Canvas) str [source]¶
Convert the sketches in the Canvas to TikZ code.
- Parameters:
canvas ("Canvas") – The canvas object.
- Returns:
The TikZ code.
- Return type:
str
- simetri.tikz.tikz.is_stroked(shape: Shape) bool [source]¶
Returns True if the shape is stroked.
- Parameters:
shape (Shape) – The shape object.
- Returns:
True if the shape is stroked, False otherwise.
- Return type:
bool
- simetri.tikz.tikz.scope_code_required(item: 'Canvas' | 'Batch') bool [source]¶
Check if a TikZ namespace is required for the item.
- Parameters:
item (Union["Canvas", "Batch"]) – The item to check.
- Returns:
True if a TikZ namespace is required, False otherwise.
- Return type:
bool
- simetri.tikz.tikz.sg_to_tikz(sketch, attrib_list, attrib_map, conditions=None, exceptions=None)[source]¶
Converts the attributes of a sketch to TikZ options.
- Parameters:
sketch – The sketch object.
attrib_list – The list of attributes to convert.
attrib_map – The map of attributes to TikZ options.
conditions – Optional conditions for the attributes.
exceptions – Optional exceptions for the attributes.
- Returns:
The TikZ options as a list.
- Return type:
list