Scenic.Primitives.sector
sector
, go back to Scenic.Primitives module for more information.
Specs
sector( source :: Scenic.Graph.t() | Scenic.Primitive.t(), sector :: sector(), options :: list() ) :: Scenic.Graph.t() | Scenic.Primitive.t()
Add a sector to a graph
A sector looks like a piece of pie. It is wedge shaped with a pointy bit on one side and a rounded bit on the other. It has a radius, a start angle and a finish angle. The angles are specified in radians.
Data:
{radius, start, finish}
To create a sector of an ellipse, create a normal sector, and apply
a :scale
transform with unequal x and y sizing.
The following example will draw a sector with a radius of 100, starting straight out to the right, then going down 0.4 radians.
|> sector( {100, 0, 0.4} )
Styles
Sectors honor the following styles
:hidden
- Iftrue
, the outline is rendered. Iffalse
, it is skipped. Default:false
.:fill
- Fills in the interior with the specified paint. If not set, the default is to not draw anything in the interior. This is similar to specifying fill: :clear, except optimized out to do nothing.:stroke
- Draws the outline with the specified width and paint. The default if not set is{1, :white}
When you apply a stroke to a sector, it goes around the whole piece of pie. If you only want to stroke the curvy part, which is common in pie charts, overlay an Arc on top of the sector and stroke that.
If you also put both the sector and the arc together in a Group, you can then apply transforms to the group to position both the primitives as a single unit.
Example:
graph
|> group(fn(g) ->
g
|> sector( {100, 0, 0.4}, fill: :red )
|> arc( {100, 0, 0.4}, stroke: {4, :blue} )
end, translate: {30, 40})