Draw Module Reference
Routines that paint shapes and Mylib objects onto an Array or Slice.
More...
#include <draw.h>
Structures
• |
op
| : Drawer |
• |
val
| : Value |
|
|
Enumerated Scalars
|
Drawer
| : { SET_PIX, ADD_PIX, SUB_PIX, MUL_PIX, MIN_PIX, MAX_PIX } |
|
|
Descriptive Types
|
Brush_Bundle
| : union { Plain_Bundle; Color_Bundle; Complex_Bundle } |
|
|
Routines
void |
Draw_Region
(Array *canvas M, Brush_Bundle *brush, Region *r) |
void |
Draw_Region_Outline
(Array *canvas M, Brush_Bundle *brush, Region *r) |
void |
Draw_Region_Exterior
(Array *canvas M, Brush_Bundle *brush, Region *r) |
void |
Draw_Region_Holes
(Array *canvas M, Brush_Bundle *brush, Region *r) |
void |
Draw_Region_Image
(Array *canvas M, Array *image, Region *r) |
void |
Draw_Level_Set
(Array *canvas M, Brush_Bundle *brush, Level_Tree *t, Level_Set *r, int share) |
void |
Draw_Level_Set_Outline
(Array *canvas M, Brush_Bundle *brush, Level_Tree *t, Level_Set *r, int share) |
void |
Draw_Level_Set_Exterior
(Array *canvas M, Brush_Bundle *brush, Level_Tree *t, Level_Set *r, int share) |
void |
Draw_Level_Set_Holes
(Array *canvas M, Brush_Bundle *brush, Level_Tree *t, Level_Set *r, int share) |
void |
Draw_Level_Set_Image
(Array *canvas M, Array *image, Level_Tree *t, Level_Set *r, int share) |
void |
Draw_P_Vertex
(Array *canvas M, Brush_Bundle *brush, Partition *p, int v, int share) |
void |
Draw_P_Vertex_Outline
(Array *canvas M, Brush_Bundle *brush, Partition *p, int v, int share) |
void |
Draw_P_Vertex_Exterior
(Array *canvas M, Brush_Bundle *brush, Partition *p, int v, int share) |
void |
Draw_P_Vertex_Holes
(Array *canvas M, Brush_Bundle *brush, Partition *v, int v, int share) |
void |
Draw_P_Vertex_Image
(Array *canvas M, Array *image, Partition *p, int v, int share) |
void |
Draw_Floodfill
(Array *canvas M, Brush_Bundle *brush, APart *source, int share, boolean iscon2n, Indx_Type seed, void *arg, boolean (*test)(Indx_Type p, void *arg)) |
void |
Draw_Basic
(Array *canvas M, Brush_Bundle *brush, APart *source, int share, boolean iscon2n, Indx_Type seed, Comparator cmprsn, Value level) |
void |
Draw_Point
(Array *canvas M, Brush_Bundle *brush, Coordinate *point F) |
void |
Draw_Cross
(Array *canvas M, Brush_Bundle *brush, Coordinate *center F, int radius) |
void |
Draw_Rectangle
(Array *canvas M, Brush_Bundle *brush, Coordinate *corner1 F, Coordinate *corner2 F) |
void |
Draw_Circle
(Array *canvas M, Brush_Bundle *brush, Coordinate *center F, int radius) |
void |
Draw_Line
(Array *canvas M, Brush_Bundle *brush, Coordinate *b F, Coordinate *e F) |
void |
Draw_Image
(Array *image M, Brush_Bundle *brush) |
Detailed Description
The drawing module has routines that paint, with a given kind of brush, shapes
and Mylib objects like Regions, Level_Sets, and P_Vertexes (i.e. Partition regions)
onto an array
called a canvas in this context. The canvas need not be the array over which an
object was created, and it can be of any kind or type, but the core shape of the
canvas must be the same as that of the array over which an object was created (if
relevant).
A generic Brush_Bundle is used to pass a brush to a drawing routine, where the type
(Value_Kind actually) and kind of the brush to actually use is inferred from the type
and kind of the associated canvas.
For a PLAIN_KIND canvas one sets a Plain_Bundle where the Value_Kind of the Value field of
the brush should be appropriate for the type of the canvas (e.g. UVAL if the canvs is
UINT8_TYPE, UINT16_TYPE, UINT32_TYPE, or UINT64_TYPE, etc.). Similarly, for an RGB_KIND
or RGBA_KIND canvas one sets up a Color_Bundle, and for a COMPLEX_KIND canvas one specifies
a Complex_Bundle. Each drawing routine will apply a brush to a set of pixels in a canvas,
where the manner in which the brush's value(s) is combined with the value of a pixel in the
canvas is determined by the op field of the brush. One can simply set the
pixel of the canvas to the value of the brush, or one can add, subtract, multiply, or divide the
canvas pixel by the brush value, or take the maximum or minimum. For color and complex
brushes the combining is with the brush values given for each special dimension.
For example, the Color_Bundle { SET_PIX, 255, 255, 0 }, would paint a yellow pixel
in a UINT8_TYPE, RGB_KIND canvas. The Complex_Bundle
{ MUL_PIX, .5, .5 }, would halve the "painted" values of a FLOAT_TYPE (FVAL), COMPLEX_KIND
canvas. Finally, the Plain_Bundle { MAX_PIX, -10 } would set all painted pixels less than
-10 to -10 in an INT_TYPE (IVAL), PLAIN_KIND array.
One can draw Regions, or their outline, exterior, or holes, and the same is possible
for Level_Sets and P_Vertexes (i.e. Partition regions). One can also paint with a
general flood
fill or more
simply a connected set of pixels of above or below some threshold with Draw_Floodfill
and Draw_Basic, respectively. One can paint a point, a cross, a rectangle, a circle,
and a line (in any number of dimensions) with appropriate draw routines. Finally one can
effectively set an entire image with Draw_Image.
Structure Documentation
Specifies a value, val, and combination operation, op, for a paint operation on a
PLAIN_KIND canvas. Practically, paint brushes are easy to initialize, for example:
Plain_Bundle clip = { MAX_PIX, -10 };
sets up a bundle for clipping pixels to a minimum of -10 in INT_TYPE (IVAL) canvases. Note
carefully that val is set to the int64 arrangement of bits encoding -10 in a
double word. One could subsequently interpret this arrangement of bits as a uint64 or
float64 value from the Value field, but presumably you're canvas is an integer type
canvas so it will be interpreted as an int64.
Specifies a combination operation, op, and a value to apply to each of the special
dimensions of an RGB_KIND, or RGBA_KIND canvas. If the canvas is RGB_KIND, then the
value of alpha is ignored. A paint brush is easy to initialize, for
example:
Color_Bundle yellow = { SET_PIX, 255, 255, 0, 0 };
Specifies a combination operation, op, and a value to apply to each of the special
dimensions of a COMPLEX_KIND canvas.
A paint brush is easy to initialize, for example:
Color_Bundle halve = { MUL_PIX, .5, .5 };
Enumerated Scalars Documentation
Drawer | : { SET_PIX, ADD_PIX, SUB_PIX, MUL_PIX, MIN_PIX, MAX_PIX } |
Specifies how brush values are to be combined with canvas values. In the table below c is
the canvas data, p is the canvas pixel to be combined with the brush, and v is the brush's
value for the given dimension of the canvas.
Operator | Effect |
SET_PIX | c = v |
ADD_PIX | c = c + v |
SUB_PIX | c = c - v |
MUL_PIX | c = c * v |
DIV_PIX | c = c / v |
MIN_PIX | c = min(c,v) |
MAX_PIX | c = max(c,v) |
Generally, the type of v is assumed to be the same as that of c, with the exception of
the multiplicative combiners, MUL_PIX and DIV_PIX, where it is assumed that the Value_Kind of
v is FVAL (floating point).
Descriptive Types Documentation
Brush_Bundle | : union { Plain_Bundle; Color_Bundle; Complex_Bundle } |
Generic declaration that could be any one of the specific paint brush kinds.
Routine Documentation
Paint all the pixels in the Region r on the canvas canvas using paint brush brush.
Holes are observed, i.e. not painted.
The canvas must have the same core shape as the array from which r was recorded.
Paint all the pixels on the outer border of the Region r on the canvas canvas using
paint brush brush.
The canvas must have the same core shape as the array from which r was recorded.
Paint all the pixels exterior to the Region r on the canvas canvas using
paint brush brush.
The canvas must have the same core shape as the array from which r was recorded.
Paint all the pixels in holes of the Region r on the canvas canvas using
paint brush brush.
The canvas must have the same core shape as the array from which r was recorded.
Set the pixels in canvas canvas to the corresponding pixels of image within the Region
region.
The canvas must have the same core shape as the array from which r was recorded.
Moreover, the canvas and the image must be of the same kind, type, and shape.
void |
Draw_Level_Set (Array *canvas M, Brush_Bundle *brush, Level_Tree *t, Level_Set *r, int share) |
void |
Draw_Level_Set_Outline (Array *canvas M, Brush_Bundle *brush, Level_Tree *t, Level_Set *r, int share) |
void |
Draw_Level_Set_Exterior (Array *canvas M, Brush_Bundle *brush, Level_Tree *t, Level_Set *r, int share) |
void |
Draw_Level_Set_Holes (Array *canvas M, Brush_Bundle *brush, Level_Tree *t, Level_Set *r, int share) |
void |
Draw_Level_Set_Image (Array *canvas M, Array *image, Level_Tree *t, Level_Set *r, int share) |
The Draw_Level_Set(_X) routines are equivalent to Draw_Region(_X) above, save that
the painting is with respect to Level_Set r in Level_Tree t, versus the Region
r of the former routines.
For unthreaded applications, the parameter share can safely be set to 0. For those
that need to know more see
this.
void |
Draw_P_Vertex (Array *canvas M, Brush_Bundle *brush, Partition *p, int v, int share) |
void |
Draw_P_Vertex_Outline (Array *canvas M, Brush_Bundle *brush, Partition *p, int v, int share) |
void |
Draw_P_Vertex_Exterior (Array *canvas M, Brush_Bundle *brush, Partition *p, int v, int share) |
void |
Draw_P_Vertex_Holes (Array *canvas M, Brush_Bundle *brush, Partition *v, int v, int share) |
void |
Draw_P_Vertex_Image (Array *canvas M, Array *image, Partition *p, int v, int share) |
The Draw_P_Vertex(_X) routines are equivalent to Draw_Region(_X) above, save that
the painting is with respect to P_Vertex region or vertex v in Partition p, versus
the Region
r of the former routines.
For unthreaded applications, the parameter share can safely be set to 0. For those
that need to know more see
this.
With brush brush, paint all the pixels in canvas canvas that correspond to the pixels
in the array or slice source that are iscon2n-connected to the pixel seed and for which
test(p,arg) is true.
The canvas must have the same core shape as AForm_Array(source).
For unthreaded applications, the parameter share can safely be set to 0. For those
that need to know more see
this.
With brush brush, paint all the pixels in canvas canvas that correspond to the pixels
in the array or slice source that are iscon2n-connected to the pixel seed and for which
'val[p] cmprsn level ' is true, where val[p] is the value of pixel p in source.
For example, if cmprsn = GE_COMP and level = 12, then the region of all pixels
iscon2n-connected to seed with value greater than or equal to 12 are painted.
The canvas must have the same core shape as AForm_Array(source).
For unthreaded applications, the parameter share can safely be set to 0. For those
that need to know more see
this.
Paint the core coordinate point of canvas canvas with brush brush.
Paint an n-dimensional cross centered on core coordinate center with arms of
length radius pixels on canvas canvas with brush brush.
Pixels of the cross outside the boundary of the canvas are clipped.
Paint an n-dimensional rectangle with minimum core coordinate b and maximum core
coordinate e on canvas canvas with brush brush.
Pixels of the rectangle outside the boundary of the canvas are clipped.
Paint an n-dimensional sphere centered on core coordinate center with radius of r pixels
on canvas canvas with brush brush.
Pixels of the sphere outside the boundary of the canvas are clipped.
Paint an n-dimensional line from core coordinate b to core coorindate e
on canvas canvas with brush brush. The line is not anti-aliased but simply
guaranteed to be a connected discretization of the line.
Pixels of the line outside the boundary of the canvas are clipped.
Paint every pixel of image with brush brush.
|