⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jiim.c

📁 frasr200的win 版本源码(18.21),使用make文件,使用的vc版本较低,在我的环境下编译有问题! 很不错的分形程序代码!
💻 C
📖 第 1 页 / 共 3 页
字号:
	       break;
	    case LEFT_ARROW:
	       dxcrsr = -1;
	       break;
	    case RIGHT_ARROW:
	       dxcrsr = 1;
	       break;
	    case UP_ARROW_2:
	       dycrsr = -4;
	       break;
	    case DOWN_ARROW_2:
	       dycrsr = 4;
	       break;
	    case LEFT_ARROW_2:
	       dxcrsr = -4;
	       break;
	    case RIGHT_ARROW_2:
	       dxcrsr = 4;
	       break;
	    case 'z':
	    case 'Z':
	       zoom = 1.0;
	       break;
	    case '<':
	    case ',':
	       zoom /= 1.15;
	       break;
	    case '>':
	    case '.':
	       zoom *= 1.15;
	       break;
	    case SPACE:
	       xcjul = cr;
	       ycjul = ci;
	       goto finish;
	       break;
	    case 'c':   /* circle toggle */
	    case 'C':   /* circle toggle */
	       mode = mode ^ 1;
	       break;
	    case 'l':
	    case 'L':
	       mode = mode ^ 2;
	       break;
	    case 'n':
	    case 'N':
	       show_numbers = 8 - show_numbers;
	       if(windows == 0 && show_numbers == 0)
	       {
		  Cursor_Hide();
		  cleartempmsg();
		  Cursor_Show();
	       }
	       break;
	    case 'p':
	    case 'P':
	       get_a_number(&cr,&ci);
               exact = 1;
               xcrsr = cvt.a*cr + cvt.b*ci + cvt.e + .5;
               ycrsr = cvt.c*cr + cvt.d*ci + cvt.f + .5;
               dxcrsr = dycrsr = 0;
	       break;
	    case 'h':   /* hide fractal toggle */
	    case 'H':   /* hide fractal toggle */
	       if(windows == 2)
		  windows = 3;
	       else if(windows == 3 && xd == sxdots)
	       {
		  RestoreRect(0, 0, xdots, ydots);
		  windows = 2;
	       }
	       break;
#ifdef XFRACT
	    case ENTER:
		break;
#endif
	    case '0':
	    case '1':
	    case '2':
/*	    case '3': */  /* don't use '3', it's already meaningful */
	    case '4':
	    case '5':
	    case '6':
	    case '7':
	    case '8':
	    case '9':
	       if (which == JIIM)
	       {
		  SecretExperimentalMode = kbdchar - '0';
		  break;
	       }
	    default:
	       still = 0;
	    }  /* switch */
	    if(kbdchar == 's' || kbdchar == 'S')
	       goto finish;
            if(dxcrsr > 0 || dycrsr > 0)
               exact = 0;
            xcrsr += dxcrsr;
            ycrsr += dycrsr;
            
	    /* keep cursor in logical screen */
	   if(xcrsr >= xdots)
	      xcrsr = xdots -1, exact = 0;
	   if(ycrsr >= ydots)
	      ycrsr = ydots -1, exact = 0;
	   if(xcrsr < 0)
	      xcrsr = 0, exact = 0;
	   if(ycrsr < 0)
	      ycrsr = 0, exact = 0;
	    
            Cursor_SetPos(xcrsr,ycrsr);
	 }  /* end while (keypressed) */

         if(exact == 0)
         {
	    if(integerfractal)
	    {
	       cr = lx0[xcrsr]+lx1[ycrsr];  /* supports rotated zoom boxes! */
	       ci = ly0[ycrsr]+ly1[xcrsr];
	       cr /= (1L<<bitshift);
	       ci /= (1L<<bitshift);
	    }
	    else
	    {
	       cr = dx0[xcrsr]+dx1[ycrsr];
	       ci = dy0[ycrsr]+dy1[xcrsr];
	    }
	 }
	 actively_computing = 1;
	 if(show_numbers) /* write coordinates on screen */
	 {
	    char str[80];
	    sprintf(str,"x=%16.14f y=%16.14f   ",cr,ci);
	    str[40] = 0;
	    if(windows == 0)
	    {
	       Cursor_Hide();
	       actively_computing = 1;
	       showtempmsg(str);
	       Cursor_Show();
	    }
	    else
	       displays(5, sydots-show_numbers, WHITE, BLACK, str,strlen(str));
	 }
	 iter = 1;
	 old.x = old.y = 0;
	 SaveC.x = init.x =  cr;
	 SaveC.y = init.y =  ci;
	 old_x = old_y = -1;
/*
 * MIIM code:
 * compute fixed points and use them as starting points of JIIM
 */
	 if (which == JIIM && OKtoMIIM)
	 {
	    _CMPLX f1, f2, Sqrt;	/* Fixed points of Julia */

	    Sqrt = ComplexSqrtFloat(1 - 4 * cr, -4 * ci);
	    f1.x = (1 + Sqrt.x) / 2;
	    f2.x = (1 - Sqrt.x) / 2;
	    f1.y =  Sqrt.y / 2;
	    f2.y = -Sqrt.y / 2;

	    ClearQueue();
	    maxhits = 1;
	    EnQueueFloat(f1.x, f1.y);
	    EnQueueFloat(f2.x, f2.y);
	 }
/*
 * End MIIM code.
 */
	 if(which == ORBIT)
           do_fractal_routines(cr, ci,PER_PIXEL);
	 /* move window if bumped */
	 if(windows==0 && xcrsr>xc && xcrsr < xc+xd && ycrsr>yc && ycrsr < yc+yd)
	 {
	    RestoreRect(xc,yc,xd,yd);
	    if (xc == xd*2)
	       xc = 2;
	    else
	       xc = xd*2;
	    xoff = xc + xd /  2;
	    SaveRect(xc,yc,xd,yd);
	 }
	 if(windows == 2)
	 {
	    fillrect(xdots, yc, xd-xdots, yd-show_numbers, color_dark);
	    fillrect(xc   , ydots, xdots, yd-ydots-show_numbers, color_dark);
	 }
	 else
	    fillrect(xc, yc, xd, yd, color_dark);

      } /* end if (keypressed) */

      if(which == JIIM)
      {
         if(hasinverse == 0)
            continue;
/*
 * MIIM code:
 * If we have MIIM queue allocated, then use MIIM method.
 */
	 if (OKtoMIIM)
	 {
	    if (QueueEmpty())
	    {
	       if (maxhits < colors - 1 && maxhits < 5 &&
		  (luckyx != 0.0 || luckyy != 0.0))
	       {
		  int i;

		  lsize  = lmax   = 0;
		  old.x  = new.x  = luckyx;
		  old.y  = new.y  = luckyy;
		  luckyx = luckyy = 0.0;
		  for (i=0; i<199; i++)
		  {
		     old = ComplexSqrtFloat(old.x - cr, old.y - ci);
		     new = ComplexSqrtFloat(new.x - cr, new.y - ci);
		     EnQueueFloat( new.x,  new.y);
		     EnQueueFloat(-old.x, -old.y);
		  }
		  maxhits++;
	       }
	       else
		  continue;		/* loop while (still) */
	    }

	    old = DeQueueFloat();

#if 0 /* try a different new method */
	    if (lsize < (lmax / 8) && maxhits < 5)	/* NEW METHOD */
	       if (maxhits < colors - 1)
		   maxhits++;
#endif
	    x = old.x * xfactor * zoom + xoff;
	    y = old.y * yfactor * zoom + yoff;
	    color = c_getcolor(x, y);
	    if (color < maxhits)
	    {
	       c_putcolor(x, y, color + 1);
	       new = ComplexSqrtFloat(old.x - cr, old.y - ci);
	       EnQueueFloat( new.x,  new.y);
	       EnQueueFloat(-new.x, -new.y);
	    }
	 }
	 else
	 {
/*
 * end Msnyder code, commence if not MIIM code.
 */
	 old.x -= cr;
	 old.y -= ci;
	 r = old.x*old.x + old.y*old.y;
	 if(r > 10.0)
	 {
	     old.x = old.y = 0.0; /* avoids math error */
	     iter = 1;
	 }
	 iter++;
	 color = ((count++)>>5)&(colors-1); /* chg color every 32 pts */
	 if(color==0)
	  color = 1;

	 r = sqrt(old.x*old.x + old.y*old.y);
	 new.x = sqrt(fabs((r + old.x)/2));
	 if (old.y < 0)
	    new.x = -new.x;

	 new.y = sqrt(fabs((r - old.x)/2));


	 switch (SecretExperimentalMode) {
	    case 0:			/* unmodified random walk */
	    default:
		if (rand() % 2)
		{
		   new.x = -new.x;
		   new.y = -new.y;
		}
		x = new.x * xfactor * zoom + xoff;
		y = new.y * yfactor * zoom + yoff;
		break;
	    case 1:		  	/* always go one direction */
		if (SaveC.y < 0)
		{
		   new.x = -new.x;
		   new.y = -new.y;
		}
		x = new.x * xfactor * zoom + xoff;
		y = new.y * yfactor * zoom + yoff;
		break;
	    case 2:			/* go one dir, draw the other */
		if (SaveC.y < 0)
		{
		   new.x = -new.x;
		   new.y = -new.y;
		}
		x = -new.x * xfactor * zoom + xoff;
		y = -new.y * yfactor * zoom + yoff;
		break;
	    case 4:			/* go negative if max color */
		x = new.x * xfactor * zoom + xoff;
		y = new.y * yfactor * zoom + yoff;
		if (c_getcolor(x, y) == colors - 1)
		{
		   new.x = -new.x;
		   new.y = -new.y;
		   x = new.x * xfactor * zoom + xoff;
		   y = new.y * yfactor * zoom + yoff;
		}
		break;
	    case 5:			/* go positive if max color */
		new.x = -new.x;
		new.y = -new.y;
		x = new.x * xfactor * zoom + xoff;
		y = new.y * yfactor * zoom + yoff;
		if (c_getcolor(x, y) == colors - 1)
		{
		   x = new.x * xfactor * zoom + xoff;
		   y = new.y * yfactor * zoom + yoff;
		}
		break;
	    case 7:
		if (SaveC.y < 0)
		{
		   new.x = -new.x;
		   new.y = -new.y;
		}
		x = -new.x * xfactor * zoom + xoff;
		y = -new.y * yfactor * zoom + yoff;
		if(iter > 10)
		{
		   if(mode == 0)			/* pixels  */
		      c_putcolor(x, y, color);
		   else if (mode & 1)            /* circles */
		   {
		      xbase = x;
		      ybase = y;
		      circle((int)(zoom*(xd >> 1)/iter),color);
		   }
		   if ((mode & 2) && x > 0 && y > 0 && old_x > 0 && old_y > 0)
		   {
		      draw_line(x, y, old_x, old_y, color);
		   }
		   old_x = x;
		   old_y = y;
		}
		x = new.x * xfactor * zoom + xoff;
		y = new.y * yfactor * zoom + yoff;
		break;
	    case 8:			/* go in long zig zags */
		if (rancnt >= 300)
		    rancnt = -300;
		if (rancnt < 0)
		{
		    new.x = -new.x;
		    new.y = -new.y;
		}
		x = new.x * xfactor * zoom + xoff;
		y = new.y * yfactor * zoom + yoff;
		break;
	    case 9:			/* "random run" */
		switch (randir) {
		    case 0:             /* go random direction for a while */
			if (rand() % 2)
			{
			    new.x = -new.x;
			    new.y = -new.y;
			}
			if (++rancnt > 1024)
			{
			    rancnt = 0;
			    if (rand() % 2)
				randir =  1;
			    else
				randir = -1;
			}
			break;
		    case 1:             /* now go negative dir for a while */
			new.x = -new.x;
			new.y = -new.y;
			/* fall through */
		    case -1:            /* now go positive dir for a while */
			if (++rancnt > 512)
			    randir = rancnt = 0;
			break;
		}
		x = new.x * xfactor * zoom + xoff;
		y = new.y * yfactor * zoom + yoff;
		break;
	 } /* end switch SecretMode (sorry about the indentation) */
	 } /* end if not MIIM */
      }
      else /* orbits */
      {
	 if(iter < maxit)
	 {
	    color = iter&(colors-1);
	    x = (old.x - init.x) * xfactor * 3 * zoom + xoff;
	    y = (old.y - init.y) * yfactor * 3 * zoom + yoff;
	    if(do_fractal_routines(cr, ci,ORBITCALC))
	       iter = maxit;
	    else
	       iter++;
	 }
	 else
	 {
	    x = y = -1;
	    actively_computing = 0;
	 }
      }
      if(which == ORBIT || iter > 10)
      {
	 if(mode == 0)			/* pixels  */
	    c_putcolor(x, y, color);
	 else if (mode & 1)            /* circles */
	 {
	    xbase = x;
	    ybase = y;
	    circle((int)(zoom*(xd >> 1)/iter),color);
	 }
	 if ((mode & 2) && x > 0 && y > 0 && old_x > 0 && old_y > 0)
	 {
	    draw_line(x, y, old_x, old_y, color);
	 }
	 old_x = x;
	 old_y = y;
      }
      old = new;
   } /* end while(still) */
finish:

/*
 * Msnyder code:
 * free MIIM queue
 */

   Free_Queue();
/*
 * end Msnyder code.
 */

   if(kbdchar != 's'&& kbdchar != 'S')
   {
      Cursor_Hide();
      if(windows == 0)
	 RestoreRect(xc,yc,xd,yd);
      else if(windows >= 2 )
      {
	 if(windows == 2)
	 {
	    fillrect(xdots, yc, xd-xdots, yd, color_dark);
	    fillrect(xc   , ydots, xdots, yd-ydots, color_dark);
	 }
	 else
	    fillrect(xc, yc, xd, yd, color_dark);
         if(windows == 3 && xd == sxdots) /* unhide */
         {
            RestoreRect(0, 0, xdots, ydots);
            windows = 2;
         }
	 Cursor_Hide();
	 savehasinverse = hasinverse;
	 hasinverse = 1;
	 SaveRect(0,0,xdots,ydots);
	 sxoffs = oldsxoffs;
	 syoffs = oldsyoffs;
	 RestoreRect(0,0,xdots,ydots);
	 hasinverse = savehasinverse;
      }
   }
   Cursor_Destroy();
#ifdef XFRACT
   Cursor_EndMouseTracking();
#endif
   delete(line_buff);
   if (memory)			/* done with memory, free it */
   {
      farmemfree(memory);
      memory = NULL;
   }

   lookatmouse = oldlookatmouse;
   using_jiim = 0;
   calctype = oldcalctype;

   helpmode = oldhelpmode;
   if(kbdchar == 's' || kbdchar == 'S')
   {
      viewwindow = viewxdots = viewydots = 0;
      viewreduction = 4.2;
      viewcrop = 1;
      finalaspectratio = screenaspect;
      xdots = sxdots;
      ydots = sydots;
      dxsize = xdots - 1;
      dysize = ydots - 1;
      sxoffs = 0;
      syoffs = 0;
      freetempmsg();
   }
   else
      cleartempmsg();
   if (file != NULL)
      {
      fclose(file);
      file = NULL;
      remove(scrnfile);
      }
   show_numbers = 0;
   ungetakey(kbdchar);
   EXIT_OVLY;
}
  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -