~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/draw/paint/ucbs_draw.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 #include <tina/sys.h>
  4 #include <tina/sysfuncs.h>
  5 #include <tina/math.h>
  6 #include <tina/mathfuncs.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 #include <tina/tv.h>
 10 #include <tina/draw.h>
 11 #include <tina/drawfuncs.h>
 12 #include <tina/tvfuncs.h>
 13 
 14 void    ucbs2_draw_ctrl(Tv * tv, Ucbs2 * ucbs, int i)
 15 {
 16     Vec2    c = {Vec2_id};
 17     Vec2    p = {Vec2_id};
 18 
 19     if (ucbs == NULL)
 20         return;
 21 
 22     switch (ucbs->type)
 23     {                           /** only draw relevant controls **/
 24     case STRING:
 25         if (i < 1 || i > ucbs->n)
 26             return;
 27         break;
 28     case LOOP:
 29         i %= ucbs->n;
 30         if (i <= 0)
 31             i += ucbs->n;
 32         break;
 33     }
 34 
 35     c = vec2(ucbs->cx[i], ucbs->cy[i]);
 36     p = ucbs2_eval(ucbs, i - 1.0);
 37     tv_dot2(tv, c);
 38     tv_line2(tv, c, p);
 39 }
 40 
 41 void    ucbs2_draw_ctrls(Tv * tv, Ucbs2 * ucbs)
 42 {
 43     int     i;
 44 
 45     if (ucbs == NULL)
 46         return;
 47 
 48     for (i = 1; i <= ucbs->n; i++)
 49         ucbs2_draw_ctrl(tv, ucbs, i);
 50 }
 51 
 52 void    ucbs2_draw_points(Tv * tv, Ucbs2 * ucbs)
 53 {
 54     int     i;
 55 
 56     if (ucbs == NULL)
 57         return;
 58     for (i = 0; i < ucbs->n; i++)
 59         tv_bigdot2(tv, ucbs2_eval(ucbs, (double) i), 2);
 60 }
 61 
 62 static Ipos ucbs2_proj2(Tv * tv, Ucbs2 * ucbs, double t)
 63 {
 64     Vec2    v = {Vec2_id};
 65 
 66     v = ucbs2_eval(ucbs, t);
 67     return (tv_proj2(tv, v));
 68 }
 69 
 70 void    ucbs2_draw_section(Tv * tv, Ucbs2 * ucbs, int i)
 71 {
 72     if (ucbs == NULL)
 73         return;
 74 
 75     switch (ucbs->type)
 76     {
 77     case STRING:
 78         if (i < 0 || i >= ucbs->n - 1)
 79             return;
 80         break;
 81     case LOOP:
 82         while (i < 0)
 83             i += ucbs->n;
 84         i %= ucbs->n;
 85         break;
 86     }
 87 
 88     curve_draw(tv, ucbs2_proj2, (void *) ucbs, (double) i, i + 1.0);
 89 }
 90 
 91 static double z_plane;
 92 
 93 static Ipos ucbs2_proj3(Tv * tv, Ucbs2 * ucbs, double t)
 94 {
 95     Vec2    v2 = {Vec2_id};
 96     Vec3    v3 = {Vec3_id};
 97 
 98     v2 = ucbs2_eval(ucbs, t);
 99     v3 = vec3(vec2_x(v2), vec2_y(v2), z_plane);
100     return (tv_proj3(tv, v3));
101 }
102 
103 void    ucbs2_draw_section3(Tv * tv, Ucbs2 * ucbs, double z, int i)
104 {
105     if (ucbs == NULL)
106         return;
107 
108     z_plane = z;
109     switch (ucbs->type)
110     {
111     case STRING:
112         if (i < 0 || i >= ucbs->n - 1)
113             return;
114         break;
115     case LOOP:
116         while (i < 0)
117             i += ucbs->n;
118         i %= ucbs->n;
119         break;
120     }
121     curve_draw(tv, ucbs2_proj3, (void *) ucbs, (double) i, i + 1.0);
122 }
123 
124 void    ucbs2_skeldraw_section3(Tv * tv, Ucbs2 * ucbs, double z, int i)
125 {
126     if (ucbs == NULL)
127         return;
128 
129     z_plane = z;
130     switch (ucbs->type)
131     {
132     case STRING:
133         if (i < 0 || i >= ucbs->n - 1)
134             return;
135         break;
136     case LOOP:
137         while (i < 0)
138             i += ucbs->n;
139         i %= ucbs->n;
140         break;
141     }
142     tv_line(tv, ucbs2_proj3(tv, ucbs, (double) i), ucbs2_proj3(tv, ucbs, i + 1.0));
143 }
144 
145 void    ucbs2_draw(Tv * tv, Ucbs2 * ucbs)
146 {
147     int     i;
148 
149     if (ucbs == NULL)
150         return;
151 
152     for (i = 0; i < ucbs->n; i++)
153         ucbs2_draw_section(tv, ucbs, i);
154 }
155 
156 void    ucbs2_draw3(Tv * tv, Ucbs2 * ucbs, double z)
157 {
158     int     i;
159 
160     if (ucbs == NULL)
161         return;
162 
163     for (i = 0; i < ucbs->n; i++)
164         ucbs2_draw_section3(tv, ucbs, z, i);
165 }
166 
167 void    ucbs2_skeldraw3(Tv * tv, Ucbs2 * ucbs, double z)
168 {
169     int     i;
170 
171     if (ucbs == NULL)
172         return;
173 
174     for (i = 0; i < ucbs->n; i++)
175         ucbs2_skeldraw_section3(tv, ucbs, z, i);
176 }
177 
178 void    ucbs2_draw_chunk(Tv * tv, Ucbs2 * ucbs, int i)
179 {
180     ucbs2_draw_ctrl(tv, ucbs, i - 1);
181     ucbs2_draw_ctrl(tv, ucbs, i);
182     ucbs2_draw_ctrl(tv, ucbs, i + 1);
183     ucbs2_draw_section(tv, ucbs, i - 3);
184     ucbs2_draw_section(tv, ucbs, i - 2);
185     ucbs2_draw_section(tv, ucbs, i - 1);
186     ucbs2_draw_section(tv, ucbs, i);
187 }
188 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.