Styled geometry entities

Entities can also be "styled"—paired with a GeometryEntityStyle. This creates a StyledEntity <: GeometryEntity that still supports the entity interface (including the ability to be styled).

DeviceLayout.GeometryEntityStyleType
abstract type GeometryEntityStyle

A style that can be used with a GeometryEntity to create a modified entity.

May use (sty::MyStyle)(ent), styled(ent, sty), or MyStyle(ent, style_args...; style_kwargs...) to create a StyledEntity.

A GeometryEntityStyle should implement to_polygons(::MyEntity, ::MyStyle; kwargs...) for any entity type it can be applied to. As a fallback, it can implement to_polygons(::Polygon, ::MyStyle; kwargs...), in which case entities will be converted to polygons before applying the style.

Unless implemented by the style, lowerleft and upperright (and hence bounds) of a styled entity will use the underlying entity's bounds.

source
DeviceLayout.StyledEntityType
StyledEntity{T, U <: GeometryEntity{T}, S <: GeometryEntityStyle} <: GeometryEntity

GeometryEntity composing another GeometryEntity with a GeometryEntityStyle.

The use of a StyledEntity allows the composition of operations like rounding on geometric entities without committing to a particular representation of those entities.

source
DeviceLayout.unstyledFunction
unstyled(styled_ent::StyledEntity)

Return the unstyled entity referenced by styled_ent.

If styled_ent.ent is itself a StyledEntity, apply unstyled recursively until the original plain GeometyEntity is found.

source
DeviceLayout.unstyled_typeFunction
unstyled_type(::GeometryEntity)
unstyled_type(::Type{GeometryEntity})

Return the type of the unstyled entity beneath all styles.

source

Basic styles

The styles below can be applied to most entities for generic purposes.

DeviceLayout.PlainType
Plain <: GeometryEntityStyle

Plain style. Does not affect rendering of the styled entity.

source
DeviceLayout.MeshSizedType
struct MeshSized{T, S} <: GeometryEntityStyle where {T, S <: Real}
    h::T
    α::S
end

Style that annotates a GeometryEntity with a mesh size to use in SolidModel rendering. The generated mesh will include a size field defined as:

mesh size = `h` * max(`s_g`, (d/`h`)^`α`)

where d is the distance away from the styled entity, and s_g is the global mesh scale parameter specified in MeshingParameters. A smaller value of h will give a finer mesh attached to the styled entity, and a larger value of α will give a more rapid increase in size away from the styled entity.

For α < 0, the size field will use α_default from the MeshingParameters used in rendering.

See also meshsized_entity and SolidModels.MeshingParameters.

source
DeviceLayout.meshsized_entityFunction
meshsized_entity(ent::GeometryEntity, h::T, α::S=-1.0) where {T, S <: Real}

Create a MeshSized entity, specifying a mesh size use in SolidModel rendering. The generated mesh will include a size field defined as:

mesh size = `h` * max(`s_g`, (d/`h`)^`α`)

where d is the distance away from the styled entity, and s_g is the global mesh scale parameter specified in MeshingParameters. A smaller value of h will give a finer mesh attached to the styled entity, and a larger value of α will give a more rapid increase in size away from the styled entity.

For α < 0, the size field will use α_default from the SolidModels.MeshingParameters used in rendering.

source
DeviceLayout.OptionalStyleType
struct OptionalStyle <: GeometryEntityStyle
    true_style::GeometryEntityStyle
    false_style::GeometryEntityStyle
    flag::Symbol
    default::Bool
end
OptionalStyle(true_style::GeometryEntityStyle, flag::Symbol;
    false_style::GeometryEntityStyle=Plain(), default::Bool=true)

Style that depends on a Boolean rendering option flag with default default.

Examples

sty = OptionalStyle(Rounded(1μm), :rounding)
p = Rectangle(4μm, 4μm)
rounded_rect = to_polygons(sty(p))
plain_rect = to_polygons(sty(p), rounding=false)
source
DeviceLayout.optional_entityFunction
optional_entity(ent::GeometryEntity, flag::Symbol;
    true_style::GeometryEntityStyle=Plain(), default=true)

Return an entity to be rendered or not based on the rendering option flag.

Example

julia> c = Cell();

julia> ent = optional_entity(Rectangle(2, 2), :optional_entities; default=false);

julia> render!(c, ent);

julia> length(elements(c))
0

julia> render!(c, ent; optional_entities=true);

julia> length(elements(c))
1
source
DeviceLayout.ToToleranceType
struct ToTolerance{T<:Coordinate} <: GeometryEntityStyle
    atol::T
end

Style for rendering an entity to absolute tolerance atol.

Equivalent to passing or overriding the keyword atol when rendering this entity.

source

AbstractPolygons also have the Polygons.Rounded style, while ClippedPolygons have Polygons.StyleDict.