Skip to content

Rendering

Render methods

# Devices.render!Function.

render!(c::Cell, r::Rectangle, meta::Meta=GDSMeta()) = render!(c, p, Rectangles.Plain(), meta)
render!(c::Cell, r::Rectangle,  ::Rectangles.Plain, meta::Meta)
render!(c::Cell, r::Rectangle, s::Rectangles.Rounded, meta::Meta)
render!(c::Cell, r::Rectangle, s::Rectangles.Undercut, meta::Meta)

Render a rectangle r to cell c, defaulting to plain styling.

source

render!(c::Cell, p::Polygon, meta::Meta=GDSMeta()) = render!(c, p, Polygons.Plain(), meta)
render!(c::Cell, r::Polygon, s::Polygons.Style, meta::Meta)

Render a polygon r to cell c, defaulting to plain styling. Currently there is no other Polygon rendering style implemented.

source

render!{T}(c::Cell, p::Path{T}, meta::Meta=GDSMeta(); kwargs...)

Render a path p to a cell c.

source

render!(c::Cell, segment::Paths.Segment, s::Paths.DecoratedStyle, meta::Meta; kwargs...)

Render a segment with decorated style s to cell c. Cell references held by the decorated style will have their fields modified by this method, which is why they are shallow copied in the Paths.attach! function.

This method draws the decorations before the path itself is drawn.

source

Rectangle rendering styles

# Devices.Rectangles.PlainType.

struct Plain{T} <: Rectangles.Style{T}
    meta::T
end

Plain rectangle style. Use this if you are fond for the simpler times when rectangles were just rectangles.

source

# Devices.Rectangles.RoundedType.

struct Rounded{S<:Coordinate,T} <: Rectangles.Style{T}
    r::S
    meta::T
end

Rounded rectangle style. All corners are rounded off with a given radius r. The bounding box of the unstyled rectangle should remain unaffected.

source

# Devices.Rectangles.UndercutType.

struct Undercut{S<:Coordinate,T} <: Rectangles.Style{T}
    ucl::S
    uct::S
    ucr::S
    ucb::S
    meta::T
    undercut_meta::T
end

Undercut rectangles. In each direction around a rectangle (left, top, right, bottom) an undercut is rendered on .

source

Polygon rendering styles

# Devices.Polygons.PlainType.

struct Plain{T} <: Polygons.Style{T}
    meta::T
end

Plain polygon style.

source

Rendering arbitrary paths

A Segment and Style together define one or more closed curves in the plane. The job of rendering is to approximate these curves by closed polygons. To enable rendering of styles along generic paths in the plane, an adaptive algorithm is used when no other method is available:

# Devices.adapted_gridFunction.

adapted_grid(f, anchors;
    max_recursions::Real = 7, max_change = 5°, rand_factor::Real = 0.05,
    grid_step = 1.0μm)

Computes a resampled grid given anchor points so that f.(grid) is sufficiently smooth. The method used is to create an initial grid around the anchor points and refine intervals. When an interval becomes "straight enough" it is no longer divided. Adapted from a contribution to PlotUtils.jl from Kristoffer Carlsson.

  • max_recursions: how many times each interval is allowed to be refined.
  • max_change: specifies acceptable change between evaluations of f on subsequent grid points, as estimated by the derivative times the distance between grid points. Typically, f is the angle of a path in the plane, so this is often an angle threshold. This condition is approximately valid in the end result, but may be weakly violated. This condition may be grossly violated if max_recursions is too low.
  • rand_factor: between anchor points, adapted_grid will wiggle initial grid points a bit to prevent aliasing. The wiggling is sampled uniformly from the interval: [-rand_factor, rand_factor], times the distance between three grid points (e.g. i+1 and i-1). A random number generator is given a fixed seed every time adapted_grid is called, so the rendered results are deterministic.
  • grid_step: Step size for initial grid points. If you set this to be larger than the maximum anchor point, then the lowest resolution consistent with max_change is used (unless f has some fast variations that the algorithm might miss).

source

In some cases, custom rendering methods are implemented when it would improve performance for simple structures or when special attention is required. The rendering methods can specialize on either the Segment or Style types, or both.