home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / logo / part01 / sun.i < prev    next >
Encoding:
Text File  |  1987-06-23  |  1.8 KB  |  75 lines

  1.  
  2. /* Include file for turtle.c for Sun Microsystems workstation */
  3.  
  4. #include <gfx.h>
  5. /* If we are on a Sun, Logo must be loaded -lgfx */
  6.  
  7. int sunturt(),sunfrom(),sunto(),suninit(),sunstate();
  8. struct display sun ={0.0,0.0,0.0,-1000.0,1000.0,-1000.0,1000.0,1.0,0,
  9.     "","","","",sunturt,sunfrom,sunto,nullfn,suninit,nullfn,
  10.     nullfn,nullfn,nullfn,sunstate};
  11.  
  12. NUMBER sunoldx,sunoldy;
  13.  
  14. transline(type,fromx,fromy,tox,toy) {
  15.     line(type,fromx+screen.w/2,screen.h/2-fromy,tox+screen.w/2,
  16.             screen.h/2-toy);
  17. }
  18.  
  19. sunturt(hide)
  20. int hide;    /* nonzero to erase turtle */
  21. {
  22.     double newx,newy,oldx,oldy,angle;
  23.  
  24.     angle = (mydpy->turth-90.0)*3.141592654/180.0;
  25.     oldx = mydpy->turtx + 15.0*sin(angle);
  26.     oldy = mydpy->turty + 15.0*cos(angle);
  27.     angle = mydpy->turth*3.141592654/180.0;
  28.     newx = mydpy->turtx + 15.0*sin(angle);
  29.     newy = mydpy->turty + 15.0*cos(angle);
  30.     transline(GXinvert,(int)oldx,(int)(yscrunch*oldy),
  31.         (int)newx,(int)(yscrunch*newy));
  32.     oldx = newx;
  33.     oldy = newy;
  34.     angle = (mydpy->turth+90.0)*3.141592654/180.0;
  35.     newx = mydpy->turtx + 15.0*sin(angle);
  36.     newy = mydpy->turty + 15.0*cos(angle);
  37.     transline(GXinvert,(int)oldx,(int)(yscrunch*oldy),
  38.         (int)newx,(int)(yscrunch*newy));
  39.     oldx = newx;
  40.     oldy = newy;
  41.     angle = (mydpy->turth-90.0)*3.141592654/180.0;
  42.     newx = mydpy->turtx + 15.0*sin(angle);
  43.     newy = mydpy->turty + 15.0*cos(angle);
  44.     transline(GXinvert,(int)oldx,(int)(yscrunch*oldy),
  45.         (int)newx,(int)(yscrunch*newy));
  46. }
  47.  
  48. suninit() {
  49.     initscreen();
  50.     drasterop(GXset,0,0,SCREEN,1024,1024);
  51. }
  52.  
  53. sunfrom(x,y)
  54. NUMBER x,y;
  55. {
  56.     sunoldx = x;
  57.     sunoldy = y;
  58. }
  59.  
  60. sunto(x,y)
  61. NUMBER x,y;
  62. {
  63.     static int sunpens[] = {GXclear,GXset,GXinvert};
  64.     /* NOTE should be set,clear but it works this way, why??? */
  65.  
  66.     transline((sunpens[penerase],
  67.         (int)sunoldx,(int)sunoldy,(int)x,(int)y);
  68. }
  69.  
  70. sunstate(which) {
  71.     if (which == 'c' || which == 'w')
  72.         drasterop(GXset,0,0,SCREEN,1024,1024);
  73. }
  74.  
  75.