composites module#
Composite shape generation functions.
This module provides functions for creating common geometric shapes like
rectangles, capsules, triangles, and other composite shapes used in JITX designs.
These functions generate Shape objects with the specified dimensions and properties.
- compute_rect_anchor_transform(anchor, x, y)[source]#
Compute transform to position a rectangle according to an anchor.
- compute_shape_anchor_transform(anchor, coreSh)[source]#
Compute transform to position a shape according to an anchor.
- rectangle(width, height, *, radius=None, chamfer=None, anchor=Anchor.C)[source]#
Create an axis aligned rectangle at the origin.
- Parameters:
width (
float) – X-dimension size of the rectangle in mm.height (
float) – Y-dimension size of the rectangle in mm.radius (
float|TypeAliasType|None) –- Optional parameter to round the corners of the rectangle. Value in mm
If this is a singular float - then that radius is applied to all 4 corners.
If this is a tuple of 4 floats - then each float is applied to the corners of the rectangle individually, starting with the top-right quadrant (+X, +Y) and then moving counter-clockwise.
If None - then no rounding occurs.
chamfer (
float|TypeAliasType|None) –- Optional parameter to chamfer the corners of the rectangle. Value in mm.
If this is a singular float - then that chamfer is applied to all 4 corners.
If this is a tuple of 4 floats - then each float is applied to the corners of the rectangle individually, starting with the top-right corner (+X, +Y) and then moving counter-clockwise.
If None - then no chamfering occurs.
anchor (
Anchor) – Localizes the rectangle feature around the origin. The default value isCwhich means that the rectangle is centered about the origin for both the X and Y axes. If provided the valueNW, then the rectangle is created such that its top-left corner is located at the origin and the rest of the rectangle projects to the right and down.
- Return type:
- Returns:
A
Shapecontaining aPolygonorArcPolygonwith the characteristics described above.
To create a normal 1x2 rectangle centered around the middle of the rectangle, you can do the following: >>> shape = rectangle(1.0, 2.0)
Simliarly to create a 1x2 rectangle with rounded corners: >>> shape = rectangle(1.0, 2.0, radius=0.25)
To create a 1x2 rectangle with chamfered corners: >>> shape = rectangle(1.0, 2.0, chamfer=0.25)
Rounded and chamfered corners can be applied simultaneously to the rectangle, causing the corners from the chamfer to be rounded: >>> shape = rectangle(1.0, 2.0, radius=0.25, chamfer=0.25)
Rounded or chamfered corners can be applied individually to each corner of the rectangle. >>> shape = rectangle(1.0, 2.0, radius=(0.1, 0.2, 0.3, 0.4))
To create a 1x2 rectangle anchored in the north-west corner, such that the rectangle projects to the right and down: >>> rectangle(1.0, 2.0, anchor=Anchor.NW)
- rectangle_from_bounds(bounds)[source]#
Construct a rectangular polygon from a shapely.bounds tuple.
- Parameters:
bounds (
TypeAliasType) – Tuple of 4 values [minx, miny, maxx, maxy]- Return type:
- Returns:
Polygon with 4-sides representing the axis-aligned bounding rectangle defined by the bounds argument.
- bounds_union(boxes)[source]#
Combine multiple bounding boxes into a single bounding box.
- Parameters:
boxes (
Iterable[TypeAliasType]) – Iterable of bounding box tuples (minx, miny, maxx, maxy).- Return type:
TypeAliasType- Returns:
Combined bounding box containing all input boxes.
- bounds_area(bounds)[source]#
Calculate area of a bounding box.
- Parameters:
bounds (
TypeAliasType) – Bounding box (minx, miny, maxx, maxy).- Return type:
- Returns:
Area of the bounding box, or 0 if invalid dimensions.
- plus_symbol(length, line_width, *, anchor=Anchor.C)[source]#
Generate a “+” plus symbol shape The plus symbol shape is often used for localization markers (ie, origin of a component) or used to indicate the positive (anode) terminal of a capacitor.
- Parameters:
length (
float|tuple[float,float]) – If a single float, then this length is applied to both the horizontal and vertical bars. If a tuple of 2 floats, then the first float is the horizontal bar length and the second is the vertical bar lengthline_width (
float|tuple[float,float]) – If a single float, then this is the width of the line used for the horizontal and vertical bars. If a tuple of 2 floats, then the first float is the horizontal bar width and the second is the vertical bar width.anchor (
Anchor) – Placement of the plus symbol with respect to the origin. By default this value isCimplying that the plus sign is located with is cross centered at (0,0)
- Return type:
- Returns:
A polygon shape in the form of a + according the passed arguments. This shape will be centered at the origin.
- capsule(width, height, *, anchor=Anchor.C)[source]#
Create a capsule shape represented by a line with a thickness. Fillets the end of the shorter side (min(width,height)) with a radius of half that sides dimension. So if width < height - then the length of the capsule is in the Y dimension. If width > height - then the length of the capsule is in the X dimension. If width == height - then a circle is returned.
- Parameters:
width (
float) – X dimension of the constructed capsule shape.height (
float) – Y dimension of the constructed capsule shape.anchor (
Anchor) – Localizes the capsule shape around the origin. The default value isCwhich means that the capsule is centered about the origin for both the X and Y axes. If provided the valueNW, then the capsule is created such that its top edge abuts X axis and its left edge abuts the Y axis.
- Return type:
- equilateral_triangle(side, *, radius=None, anchor=Anchor.C)[source]#
Construct an equilateral triangle from a given side. Constructed triangle is drawn with one side (the base) drawn parallel to the X axis and in the negative half plane of the Y axis. The tip of the triangle is in the positive half plane of the Y axis.
- notch_rectangle(width, height, notch_width, notch_height, anchor=Anchor.C)[source]#
Construct a rectangular shape with a triangular notch on one edge of the rectangle. This shape is often used with differential via structures. The notch will be taken out of the top edge (+Y) of the rectangle.
- Parameters:
width (
float) – X dimension for the overall rectangular shape.height (
float) – Y dimension for the overall rectangular shape.notch_width (
float) – Width of the base of the triangle that will be notched into the overall rectangle shape. This value must be less than the overall width of the rectangle.notch_height (
float) – Height of the triangle that will be notched into the overall rectangle shape. This height must be less than the total height of the overall rectangle.anchor (
Anchor) – Initial anchoring of the rectangle shape. Default isCwhich means that the rectangle is centered at the origin (0, 0).
- Return type:
- double_notch_rectangle(width, height, notch_width, notch_height, anchor=Anchor.C)[source]#
Construct a rectangular shape with a triangular notch on the two long edges of the rectangle. This shape is often used with differential via structures. The notch will be taken out of the top edge (+Y) and bottom edge (-Y) of the rectangle.
- Parameters:
width (
float) – X dimension for the overall rectangular shape.height (
float) – Y dimension for the overall rectangular shape.notch_width (
float) – Width of the base of the triangle that will be notched into the overall rectangle shape. This value must be less than the overall width of the rectangle.notch_height (
float) – Height of the triangle that will be notched into the overall rectangle shape. This height must be less than height/2.anchor (
Anchor) – Initial anchoring of the rectangle shape. Default isCwhich means that the rectangle is centered at the origin (0, 0).
- Return type:
- chipped_circle(radius, edge_dist, anchor=Anchor.C)[source]#
Construct a single-sided Chipped Circle shape. This shape is often used when constructing antipads for via structures. Imagine a chord is drawn across one side of the circle. This function constructs a shape such that the sliver of the circle on the other side of the chord is removed. This ends up meaning that circle has one side that is flattened.
- Parameters:
radius (
float) – Radius for the overall circle shape.edge_dist (
float) – Distance from the center to the chord edge of the circle.anchor (
Anchor) – Placement of the chipped circle with respect to the origin. By default this value isCimplying that the shape is located with the center of the circle at (0,0)
- Return type:
- double_chipped_circle(radius, edge_dist, anchor=Anchor.C)[source]#
Construct a double-sided Chipped Circle shape This shape is often used when constructing antipads for via structures. Similar to the single-sided chipped circle, except the chord is drawn on both sides, opposite the center of the circle, creating two flat edges.
- Parameters:
radius (
float) – Radius for the overall circle shape.edge_dist (
float) – Distance from the center to the chord edge of the circle.anchor (
Anchor) – Placement of the chipped circle with respect to the origin. By default this value isCimplying that the shape is located with the center of the circle at (0,0)
- Return type:
- bullseye(radii, line_widths, *, anchor=Anchor.C)[source]#
Construct a bullseye shape consisting of concentric circle outlines of a given width.
- Parameters:
radii (
Sequence[float]) – A sequence of radiuses for the rings of the bullseye. Each entry in this sequence indicates a unique ring to be drawn.line_widths (
float|Sequence[float]) – Either a single line width to apply to all of the circles or a sequence of line widths to apply to each circle. If a sequence, the length of this sequence must match the length ofradiianchor (
Anchor) – Initial anchoring of the bullseye shape. The default value isCwhich centers the bullseye over the origin.
- Return type: