X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=demos%2Fobjects%2Fobjects-sample.c;h=5b005636bdd2b04ffe6c0b8ca6fd8f28091fed39;hb=e0467a3b7ccda77d1a75405e21c9723c72d33002;hp=f0a800ae3d89352a1424f835f20a7288c236bd95;hpb=24cfa6bd1046afbbe6049d9b463cf76c97d5e7d4;p=svn%2FCll1h%2F.git diff --git a/demos/objects/objects-sample.c b/demos/objects/objects-sample.c index f0a800a..5b00563 100644 --- a/demos/objects/objects-sample.c +++ b/demos/objects/objects-sample.c @@ -56,7 +56,7 @@ def_mem(Object_list) void drawTri(Shape community) { - I_am(Tri); + I_am(self, Tri); printf("Drawing %s: %d,%d - %d,%d - %d,%d .\n", self->name, self->x1, self->y1, self->x2, self->y2, self->x3, self->y3); @@ -64,7 +64,7 @@ void drawTri(Shape community) void drawRect(Shape community) { - I_am(Rect); + I_am(self, Rect); printf("Drawing %s: %d,%d - %d,%d .\n", self->desc, self->x1, self->y1, self->x2, self->y2); @@ -72,7 +72,7 @@ void drawRect(Shape community) void drawCirc(Shape community) { - I_am(Circ); + I_am(self, Circ); printf("Drawing %s: %d,%d - r=%d .\n", self->comment, self->x1, self->y1, self->r); @@ -80,7 +80,7 @@ void drawCirc(Shape community) void moveTri(Shape community, int x, int y) { - I_am(Tri); + I_am(self, Tri); self->x1 += x; self->y1 += y; @@ -92,7 +92,7 @@ void moveTri(Shape community, int x, int y) void moveRect(Shape community, int x, int y) { - I_am(Rect); + I_am(self, Rect); self->x1 += x; self->y1 += y; @@ -102,7 +102,7 @@ void moveRect(Shape community, int x, int y) void moveCirc(Shape community, int x, int y) { - I_am(Circ); + I_am(self, Circ); self->x1 += x; self->y1 += y; @@ -110,49 +110,49 @@ void moveCirc(Shape community, int x, int y) str descTri(Shape community) { - I_am(Tri); + I_am(self, Tri); return self->name; } str descRect(Shape community) { - I_am(Rect); + I_am(self, Rect); return self->desc; } str descCirc(Shape community) { - I_am(Circ); + I_am(self, Circ); return self->comment; } float calcAreaTri(Shape community) { - I_am(Tri); + I_am(self, Tri); return 0; } float calcAreaRect(Shape community) { - I_am(Rect); + I_am(self, Rect); - return (self->x2-self->x1)*(self->y2-self->y1); + return (self->x2 - self->x1)*(self->y2 - self->y1); } float calcAreaCirc(Shape community) { - I_am(Circ); + I_am(self, Circ); - return 3.14159*self->r*self->r; + return PI * self->r * self->r; } void setTri(Shape community, int x1, int y1, int x2, int y2, int x3, int y3) { - I_am(Tri); + I_am(self, Tri); self->x1 = x1; self->y1 = y1; @@ -164,7 +164,7 @@ void setTri(Shape community, int x1, int y1, int x2, int y2, int x3, int y3) void setRect(Shape community, int x1, int y1, int x2, int y2, int dummy1, int dummy2) { - I_am(Rect); + I_am(self, Rect); self->x1 = x1; self->y1 = y1; @@ -174,7 +174,7 @@ void setRect(Shape community, int x1, int y1, int x2, int y2, int dummy1, int du void setCirc(Shape community, int x1, int y1, int r, int dummy1, int dummy2, int dummy3) { - I_am(Circ); + I_am(self, Circ); self->x1 = x1; self->y1 = y1; @@ -183,7 +183,7 @@ void setCirc(Shape community, int x1, int y1, int r, int dummy1, int dummy2, int void nameRect(Shape community, str name) { - I_am(Rect); + I_am(self, Rect); self->desc = name; }