/* ciiicecream.c ** Copyright Ó 1990, 1993 by Xerox Corporation. All rights reserved. ** Michael Plass, September 28, 1993 11:34 am PDT */ #define TESTVERSION #include "cii.h" #include "cii_matrix.h" static void Shape1(CII_PathGenerator self, CII_PathSink sink) { CII_RectangleRep* rect = self->data; CII_VectorRep p; CII_VectorRep c[3]; p.x = rect->x; p.y = rect->y; CII_MoveTo(sink, &p); c[0].x = rect->x; c[0].y = rect->y + rect->h; c[1].x = rect->x + rect->w; c[1].y = rect->y + rect->h; c[2].x = rect->x + rect->w; c[2].y = rect->y; CII_CurveTo(sink, c); } float red[3] = {1.0, 0.0, 0.0}; float green[3] = {0.0, 1.0, 0.0}; float blue[3] = {0.0, 0.0, 1.0}; float coneRGB[3] = {0.4,0.3,0.25}; float strokeRGB[3] = {0.0,0.0,0.1}; static CII_RES ConePath(CII_PathGenerator self, CII_PathSink sink) { CII_VectorRep p0 = {70.0, 75.0}; CII_VectorRep p1 = {50.0, 25.0}; CII_VectorRep p2 = {30.0, 75.0}; CII_MoveTo(sink, &p0); CII_LineTo(sink, &p1); CII_LineTo(sink, &p2); } static CII_RES IceCreamPath(CII_PathGenerator self, CII_PathSink sink) { CII_VectorRep p0 = {30.0, 75.0}; CII_ConicControlRep c1 = {{50.0, 25.0}, {70.0, 75.0}, 0.1}; CII_VectorRep c2[3] = {{80.0, 80.0}, {80.0, 90.0}, {72.0, 87.0}}; CII_ConicControlRep c3 = {{88.84093, 122.0}, {50.0, 122.0}, 0.3473314}; CII_ConicControlRep c4 = {{11.15908, 122.0}, {28.0, 87.0}, 0.3473315}; CII_ConicControlRep c5 = {{15.0, 90.0}, {30.0, 75.0}, 0.5}; CII_MoveTo(sink, &p0); CII_ConicTo(sink, &c1); CII_CurveTo(sink, c2); CII_ConicTo(sink, &c3); CII_ConicTo(sink, &c4); CII_ConicTo(sink, &c5); } static void IceCreamCone(dev, mp, flavor) CII_Handle dev; float mp[]; float flavor[]; { CII_StrokeControlRep stroke = CII_INITIALSTROKECONTROL; CII_PathGeneratorObjectRep p; stroke.strokeType = CII_CLOSED_STROKE; stroke.end = CII_SQUARE_END; stroke.joint = CII_BEVEL_JOINT; stroke.strokeWidth = 2.0; CII_SetMatrix(dev, mp); p.data = (void*)0; p.GeneratePath = &ConePath; CII_SetRGB(dev, coneRGB); CII_MaskFill(dev, &p, CII_NONZERO_FILL); p.GeneratePath = &IceCreamPath; CII_SetHSV(dev, flavor); CII_MaskFill(dev, &p, CII_NONZERO_FILL); CII_SetRGB(dev, strokeRGB); CII_MaskStroke(dev, &p, &stroke); } static void TCone(dev, mp, flavor) CII_Handle dev; float mp[]; float flavor[]; { float t[6]; CII_VectorRep t0 = {0.0, 200.0}; float r0 = -22.0; CII_VectorRep t1 = {-50.0, -25.0}; CIU_MakeScale(1.0, t); CIU_ApplyPreConcat(mp, t); CIU_ApplyPreTranslate(t0.x, t0.y, t); CIU_ApplyPreRotate(r0, t); CIU_ApplyPreTranslate(t1.x, t1.y, t); IceCreamCone(dev, &t, flavor); } static void SixCones(dev, mp, h, s) CII_Handle dev; float mp[]; float h, s; { float t[6]; float flavor[3] = {1.0, 1.0, 0.8}; CII_VectorRep t0 = {0.0, 200.0}; float r0 = 60.0; CII_VectorRep t1 = {-50.0, -25.0}; int i = 6; CIU_MakeScale(1.0, t); CIU_ApplyPreConcat(mp, t); while (i > 0) { flavor[0] = h; flavor[1] = s; IceCreamCone(dev, t, flavor); CIU_ApplyPreRotate(r0, t); h += 1.0/6.0; if (h > 1.0) {h -= 1.0;}; flavor[0] = h; i -= 1; }; } static CII_RES CirclePath(CII_PathGenerator self, CII_PathSink sink) { CII_VectorRep p = {100.0, 0.0}; int i; CII_MoveTo(sink, &p); i = 1; while (i <= 4) { CII_ConicControlRep cc; float x, y; x = -p.y; y = p.x; cc.p1.x = p.x + x; cc.p1.y = p.y + y; cc.p2.x = x; cc.p2.y = y; cc.s = 0.4142; CII_ConicTo(sink, &cc); p.x = x; p.y = y; i = i + 1; } } static void CircleClip(dev) CII_Handle dev; { CII_PathGeneratorObjectRep p; p.data = (void*)0; p.GeneratePath = &CirclePath; CII_Clip(dev, &p, CII_NONZERO_FILL); } CII_VectorRep center = {300.0, 400.0}; CII_VectorRep scale = {4.0, 4.0}; extern void run_ciiicecream(dev) CII_Handle dev; { float r0 = 25.0; float m[6]; float save[6]; float h, s; float shrink = 0.7; int i = 16; CII_GetMatrix(dev, m); CII_GetMatrix(dev, save); CIU_ApplyPreTranslate(center.x, center.y, m); CIU_ApplyPreScale((float)4.0, m); CII_SetMatrix(dev, m); h = 1.0; s = 1.0; CircleClip(dev); while (i > 0) { SixCones(dev, m, h, s); CIU_ApplyPreRotate(r0, m); CIU_ApplyPreScale(shrink, m); h += 1.0/18.0; if (h > 1.0) {h -= 1.0;}; s *= shrink; i -= 1; }; CII_SetMatrix(dev, save); } void XR_run_ciiicecream() { #ifdef TESTVERSION CII_Handle dev = (CII_Handle)CII_TestDevice(); float t[6]; CII_GetInitialMatrix(dev, t); CII_SetMatrix(dev, t); run_ciiicecream(dev); CII_Destroy(dev); #endif }