Cauldron3D.Setup (Cauldron3D v0.2.2)

Copy Markdown View Source

A polygon made ready for drawing: clipped to the near plane, projected, and reduced to the rows it covers, its edges, and a plane {at_origin, per_x, per_y} for each attribute across the picture.

Cauldron3D.Setup.new(view, polygon)
#=> %Cauldron3D.Setup{} | nil

nil is a polygon that cannot be seen: wholly behind the near plane, facing away under its cull, edge-on, or outside the picture.

The attributes are :near (grows toward the camera), :w (see Cauldron3D.View), :uw and :vw (the paint position times w), :light (carried straight across the picture, or nil) and :tint (four planes, each of red, green, blue and alpha times w, or nil). Rows are sampled at their centres.

A polygon drawn with depth: :near_third has its :near plane moved into the nearest third of the depth range: 0.333 * near + 0.6665 / view.near.

Summary

Functions

The value of an attribute plane at the centre of pixel {x, y}.

The polygon ready to draw in view, or nil when it cannot be seen.

Whether an overlay setup hides what is behind it where it is drawn.

Whether the setup is drawn over the solid polygons rather than among them.

The pixels row y covers, as {first, last} columns inside a picture width wide, or nil when it covers none.

Types

edge()

@type edge() :: {float(), float(), float(), float()}

plane()

@type plane() :: {float(), float(), float()}

t()

@type t() :: %Cauldron3D.Setup{
  alpha_test: float() | nil,
  blend: Cauldron3D.Polygon.blend(),
  bottom: non_neg_integer(),
  clear: byte() | nil,
  depth: :test | :always,
  edges: [edge()],
  light: plane() | nil,
  near: plane(),
  nearest: float(),
  paint: term(),
  tint: {plane(), plane(), plane(), plane()} | nil,
  top: non_neg_integer(),
  uw: plane(),
  vw: plane(),
  w: plane()
}

Functions

at(arg, x, y)

@spec at(plane(), number(), number()) :: float()

The value of an attribute plane at the centre of pixel {x, y}.

new(view, polygon)

@spec new(Cauldron3D.View.t(), Cauldron3D.Polygon.t()) :: t() | nil

The polygon ready to draw in view, or nil when it cannot be seen.

opaque?(setup)

@spec opaque?(t()) :: boolean()

Whether an overlay setup hides what is behind it where it is drawn.

overlay?(setup)

@spec overlay?(t()) :: boolean()

Whether the setup is drawn over the solid polygons rather than among them.

span(setup, y, width)

@spec span(t(), integer(), pos_integer()) :: {integer(), integer()} | nil

The pixels row y covers, as {first, last} columns inside a picture width wide, or nil when it covers none.