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

Linux Cross Reference
Tina4/src/covira/synth.c

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

  1 /*
  2  * synth.c
  3  *
  4  * @(#)Make test image
  5  *
  6  */
  7 
  8 #include <tina/all_tina.h>
  9 
 10 static Imrect *im_ellipse(int width, int height,
 11     double cx, double cy,
 12     double ax, double ay, double theta, int low, int high)
 13 {
 14     int *row;
 15     Imrect *im = im_alloc(height, width, NULL, uchar_v);
 16     int x, y;
 17     double c = cos(theta), s = sin(theta);
 18 
 19     row = tvector_alloc(0, width, int);
 20     for (y = 0; y < height; y++)
 21     {
 22         for (x = 0; x < width; x++)
 23         {
 24             double x1, x2, y1, y2;
 25 
 26             x1 = x-cx;
 27             y1 = y-cy;
 28             x2 =  c*x1+s*y1;
 29             y2 = -s*x1+c*y1;
 30             x2 /= ax;
 31             y2 /= ay;
 32 
 33             if (x2 * x2 + y2 * y2 > 1.0)
 34                 row[x] = low;
 35             else
 36                 row[x] = high;
 37         }
 38         im_put_row(row, im, y, 0, width);
 39     }
 40 
 41     tvector_free(row, 0, int);
 42     return (im);
 43 }
 44 
 45 main(void)
 46 {
 47     Imrect *im1 = im_ellipse(256, 256, 128.0, 128.0, 100.0, 64.0, 0, 0, 100);
 48     Imrect *im2 = im_ellipse(256, 256, 128.0, 128.0, 50.0, 25.0, 0, 0, 100);
 49     Imrect *im = im_sum(im1, im2);
 50     im = im_cast(im, ushort_v);
 51     raw_write_image(im, "ellipse.1");
 52 }
 53 

~ [ 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.