EE445M RTOS
Taken at the University of Texas Spring 2015
Geometric modeling

Spatial and geometric modeling library. More...

Data Structures

struct  point
 Representation of an ordered pair with a shade. More...
 
struct  shape
 Representation of a shape. More...
 
struct  circle
 Representation of a circle. More...
 

Functions

void shape_destroy_point (point *p)
 
void shape_destroy_circle (circle *cir)
 
pointshape_create_point (ushort, ushort, shade_t)
 
pointshape_duplicate_point (point *p)
 
shapeshape_create (ushort,...)
 
shapeshape_duplicate_shape (shape *)
 
void shape_destroy_shape (shape *)
 
circleshape_create_circle (ushort, point *)
 
shapeshape_create_triangle (point *, point *, point *)
 
shapeshape_create_quad (point *, uchar, uchar)
 

Detailed Description

Spatial and geometric modeling library.

Graphics framework for describing 2D systems.

Author
Hershal Bhave
Eric Crosson
Version
0.1
Date
2014
Note
Destroy whatever you create.

Function Documentation

shape* shape_create ( ushort  ,
  ... 
)

Return a pointer to a shape with numPoints points.

Parameters
numpointsNumber of vertices in this polygon
points...Comma separated point-defined polygon
Returns
point* Pointer to the described polygon
Note
va_args requires a preceeding argument (size va_args).

Definition at line 31 of file shape.c.

References shape::num_points, and shape::points.

Referenced by CHToShape(), shape_create_quad(), and shape_create_triangle().

31  {
32 
33  unsigned char i;
34  shape* sh = (shape*) calloc(1, sizeof(shape));
35  point** pts = (point**) calloc(num_points, sizeof(point*));
36  va_list args;
37 
38  va_start(args, num_points);
39  for(i=0; i < num_points; ++i) {
40  pts[i] = va_arg(args, point*);
41  }
42  va_end(args); /* clean up the list */
43 
44  sh->num_points = num_points;
45  sh->points = pts;
46  return sh;
47 }
unsigned short num_points
Definition: shape.h:28
Representation of a shape.
Definition: shape.h:26
point ** points
Definition: shape.h:29
Representation of an ordered pair with a shade.
Definition: shape.h:13

Here is the caller graph for this function:

circle* shape_create_circle ( ushort  ,
point  
)

Return a pointer to a circle in memory described by center and radius.

Parameters
centerPoint describing the center of the circle
radiusLength of the radius in units
Returns
shape* to newly described circle

Definition at line 58 of file shape.c.

References circle::center, and circle::radius.

58  {
59 
60  circle* cir = (circle*) calloc(1, sizeof(circle));
61  cir->center = center;
62  cir->radius = radius;
63  return cir;
64 }
ushort radius
Definition: shape.h:41
Representation of a circle.
Definition: shape.h:37
point * center
Definition: shape.h:40
point* shape_create_point ( ushort  ,
ushort  ,
shade_t   
)

Return a point that describes the given arguments.

Parameters
xx coordinate
yy coordinate
shadeshading of this point
Returns
point* The newly created point

Definition at line 6 of file shape.c.

References point::shade, point::x, and point::y.

Referenced by _FBDrawGraphBounds(), _FBDrawGraphData(), FBDrawFullscreenGraph(), FBEraseFullscreenGraph(), FBEraseFullscreenGraphData(), shape_create_quad(), and shape_duplicate_point().

6  {
7  point* p = malloc(sizeof(point));
8  p->x = x;
9  p->y = y;
10  p->shade = shade;
11  return p;
12 }
unsigned short y
Definition: shape.h:16
shade_t shade
Definition: shape.h:18
Representation of an ordered pair with a shade.
Definition: shape.h:13
unsigned short x
Definition: shape.h:15

Here is the caller graph for this function:

shape* shape_create_quad ( point ,
uchar  ,
uchar   
)

A handy function to create a general quadrilateral.

Parameters
top_left_cornerCoordinates of the top left corner of the quadrilateral
widthWidth of the quadrilateral
p2height Height of the quadrilateral
Returns
shape* to newly described quadrilateral

Definition at line 19 of file shape.c.

References point::shade, shade_t, shape_create(), shape_create_point(), point::x, and point::y.

19  {
20 
21  ushort x = top_left_corner->x;
22  ushort y = top_left_corner->y;
23  shade_t shade = top_left_corner->shade;
24  return shape_create(4,
25  top_left_corner,
26  shape_create_point(x+width, y, shade),
27  shape_create_point(x+width, y+height, shade),
28  shape_create_point(x, y+height, shade));
29 }
shape * shape_create(ushort num_points,...)
Definition: shape.c:31
unsigned short ushort
Definition: defines.h:35
point * shape_create_point(ushort x, ushort y, shade_t shade)
Definition: shape.c:6
#define shade_t
Definition: defines.h:41

Here is the call graph for this function:

shape* shape_create_triangle ( point ,
point ,
point  
)

A handy function to create a triangle.

Parameters
p0Vertex a
p1Vertex b
p2Vertex c
Returns
shape* to newly described triangle

Definition at line 14 of file shape.c.

References shape_create().

14  {
15 
16  return shape_create(3, p0, p1, p2);
17 }
shape * shape_create(ushort num_points,...)
Definition: shape.c:31

Here is the call graph for this function:

void shape_destroy_circle ( circle cir)
inline

Destroys a circle described by center and radius.

Parameters
cirCircle to destroy

Definition at line 57 of file shape.h.

57  {
58 
59  free(cir);
60 }
void shape_destroy_point ( point p)
inline

Destroys a point described by x and y coordinates.

Parameters
pPoint to destroy

Definition at line 48 of file shape.h.

48  {
49 
50  free(p);
51 }
void shape_destroy_shape ( shape )

Destroy a shape object.

Parameters
shShape object to destroy
Returns
void

Definition at line 49 of file shape.c.

References shape::num_points, and shape::points.

49  {
50 
51  ushort i;
52  for(i=0; i<sh->num_points; ++i) {
53  free(sh->points[i]);
54  }
55  free(sh->points);
56 }
unsigned short ushort
Definition: defines.h:35
point* shape_duplicate_point ( point p)
inline

Duplicate a point

Parameters
pPoint to duplicate
Returns
point* Duplicated point
Warning
Don't forget to destroy each duplicated (created) point.

Definition at line 77 of file shape.h.

References point::shade, shape_create_point(), point::x, and point::y.

Referenced by _fb_draw_line(), _fb_draw_string(), CHCreateClockHand(), CHDuplicateClockHand(), fb_erase_char(), and fb_erase_string().

77  {
78 
79  return shape_create_point(p->x, p->y, p->shade);
80 }
unsigned short y
Definition: shape.h:16
shade_t shade
Definition: shape.h:18
point * shape_create_point(ushort, ushort, shade_t)
Definition: shape.c:6
unsigned short x
Definition: shape.h:15

Here is the call graph for this function:

Here is the caller graph for this function:

shape* shape_duplicate_shape ( shape )

Duplicate a shape object.

Parameters
shapeThe shape to duplicate
Returns
shape A duplicate of the given shape

Definition at line 66 of file shape.c.

References shape::num_points, and shape::points.

Referenced by CHDuplicateClockHand().

66  {
67 
68  ushort i;
69  shape* dup = (shape*) calloc(1, sizeof(shape));
70 
71  dup->num_points = s->num_points;
72  dup->points = (point**) calloc(dup->num_points, sizeof(point*));
73 
74  for(i=0; i < dup->num_points; ++i) {
75  dup->points[i] = s->points[i];
76  }
77  return dup;
78 }
unsigned short num_points
Definition: shape.h:28
Representation of a shape.
Definition: shape.h:26
unsigned short ushort
Definition: defines.h:35
point ** points
Definition: shape.h:29
Representation of an ordered pair with a shade.
Definition: shape.h:13

Here is the caller graph for this function: