Boxart.Render.Shapes (Boxart v0.3.2)

Copy Markdown View Source

Shape renderers for node drawing.

Each function draws a specific node shape onto a Boxart.Canvas, returning the updated canvas. Shapes are drawn with box-drawing characters from the given charset and labels centered inside.

Summary

Functions

Draws an asymmetric (flag) shape: >text].

Draws a circle with ◯ markers at top/bottom center.

Draws a cylinder (database) shape with double top border.

Draws a diamond (decision) shape with ◇ markers at top/bottom center.

Draws a double circle (concentric rounded borders).

Draws an end state: bullseye (◉).

Draws a fork/join bar: solid thick block.

Draws a parallelogram leaning right: /text/.

Draws a parallelogram leaning left: \text.

Draws a rectangular box with the label centered.

Draws a box with rounded corners.

Dispatches to the appropriate shape renderer.

Draws a stadium (pill) shape with parenthesized sides.

Draws a start state: filled circle (●).

Draws a subroutine (double-bordered) box.

Draws a trapezoid: /text\ — top corners slant inward.

Draws an inverted trapezoid: \text/ — bottom corners slant inward.

Types

shape()

@type shape() ::
  :rectangle
  | :rounded
  | :stadium
  | :subroutine
  | :diamond
  | :hexagon
  | :circle
  | :double_circle
  | :asymmetric
  | :cylinder
  | :parallelogram
  | :parallelogram_alt
  | :trapezoid
  | :trapezoid_alt
  | :start_state
  | :end_state
  | :fork_join
  | :junction

Functions

draw_asymmetric(canvas, x, y, width, height, label, cs)

@spec draw_asymmetric(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws an asymmetric (flag) shape: >text].

draw_circle(canvas, x, y, width, height, label, cs)

@spec draw_circle(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a circle with ◯ markers at top/bottom center.


   text   

draw_cylinder(canvas, x, y, width, height, label, cs)

@spec draw_cylinder(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a cylinder (database) shape with double top border.



   text   

draw_diamond(canvas, x, y, width, height, label, cs)

@spec draw_diamond(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a diamond (decision) shape with ◇ markers at top/bottom center.


 decide? 

draw_double_circle(canvas, x, y, width, height, label, cs)

@spec draw_double_circle(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a double circle (concentric rounded borders).

draw_end_state(canvas, x, y, width, height, label, cs)

@spec draw_end_state(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws an end state: bullseye (◉).

draw_fork_join(canvas, x, y, width, height, label, cs)

@spec draw_fork_join(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a fork/join bar: solid thick block.

draw_hexagon(canvas, x, y, width, height, label, cs)

@spec draw_hexagon(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a hexagon shape.

 /\
   text   
 \/

draw_parallelogram(canvas, x, y, width, height, label, cs)

@spec draw_parallelogram(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a parallelogram leaning right: /text/.

draw_parallelogram_alt(canvas, x, y, width, height, label, cs)

@spec draw_parallelogram_alt(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a parallelogram leaning left: \text.

draw_rectangle(canvas, x, y, width, height, label, cs)

@spec draw_rectangle(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a rectangular box with the label centered.


   text   

draw_rounded(canvas, x, y, width, height, label, cs)

@spec draw_rounded(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a box with rounded corners.


   text   

draw_shape(canvas, arg2, x, y, w, h, label, cs)

@spec draw_shape(
  Boxart.Canvas.t(),
  shape(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Dispatches to the appropriate shape renderer.

draw_stadium(canvas, x, y, width, height, label, cs)

@spec draw_stadium(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a stadium (pill) shape with parenthesized sides.


(   text   )

draw_start_state(canvas, x, y, width, height, label, cs)

@spec draw_start_state(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a start state: filled circle (●).

draw_subroutine(canvas, x, y, width, height, label, cs)

@spec draw_subroutine(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a subroutine (double-bordered) box.


  text  

draw_trapezoid(canvas, x, y, width, height, label, cs)

@spec draw_trapezoid(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws a trapezoid: /text\ — top corners slant inward.

draw_trapezoid_alt(canvas, x, y, width, height, label, cs)

@spec draw_trapezoid_alt(
  Boxart.Canvas.t(),
  integer(),
  integer(),
  integer(),
  integer(),
  String.t(),
  Boxart.Charset.t()
) :: Boxart.Canvas.t()

Draws an inverted trapezoid: \text/ — bottom corners slant inward.