TXLWizard.Patterns.Polyline

Implements a class for Pattern objects of type Polyline (B).

Renders an path specified by points.

Classes

Polyline(Points, **kwargs) Implements a class for Pattern objects of type Polyline.
class TXLWizard.Patterns.Polyline.Polyline(Points, **kwargs)[source]

Bases: TXLWizard.Patterns.AbstractPattern.AbstractPattern

Implements a class for Pattern objects of type Polyline.

Corresponds to the TXL command P (PR if RoundCaps is True).

Renders an path specified by points.

The ends can be rounded by specifying RoundCaps

Parameters:
  • Points (list of list of float) – List of points (each point is a list of float, specifying the x- and y-coordinate of the point) that define the path
  • RoundCaps (bool, optional) –

    If set to True, the end of the path is rounded.

    Defaults to False.

  • **kwargs – keyword arguments passed to the TXLWizard.Patterns.AbstractPattern.AbstractPattern constructor. Can specify attributes of the current pattern.

Examples

Import required modules

>>> import TXLWizard.TXLWriter

Initialize TXLWriter

>>> TXLWriter = TXLWizard.TXLWriter.TXLWriter()

Create Content Structure for polyline and add Pattern of type Polyline

>>> PolylineStructure = TXLWriter.AddContentStructure('MyPolylineID')
>>> PolylineStructure.AddPattern(
...     'Polyline',
...     Points=[[0,0], [0,10], [20,50], [0,0]],
...     StrokeWidth=3,
...     Layer=1
... ) 
<TXLWizard.Patterns.Polyline.Polyline object at 0x...>

Complex structures can easily be added by generating the Polyline points

>>> import math
>>> PolylinePoints = []
>>> Radius = 10.
>>> for i in range(21):
...     # AngleRadians goes from 0 to pi in 20 steps
...     AngleRadians = 0.5*2.*math.pi*1./20.*i
...     PolylinePoints.append([
...         Radius*math.cos(AngleRadians),Radius*math.sin(AngleRadians)
...     ])
>>> PolylinePoints.append([-20,-30])
>>> PolylinePoints.append([20,-30])
>>>
>>> PolylineStructure.AddPattern(
...     'Polyline',
...     Points=PolylinePoints,
...     RoundCaps=True,
...     StrokeWidth=3,
...     Layer=1
... ) 
<TXLWizard.Patterns.Polyline.Polyline object at 0x...>

Generate Files

>>> TXLWriter.GenerateFiles('Tests/Results/Patterns/Polyline')
Points = None

list of list of float – List of points (each point is a list of float, specifying the x- and y-coordinate of the point) that define the polygon

RoundCaps = None

bool – If set to True, the end of the path is rounded

Type = None

str – specifies the type of the pattern. Set to ‘Polyline’