示例#1
0
		public bool RenderAll(GBuffer gbDest, IRect rectDest) {//, DPoint pOrigin, double rScale, double rSetSeed) {
			bool bGood=false;
			try {
				//int xDest=rectDest.Left;
				//int yDest=rectDest.Top;
				pOrigin.Set((double)xCenterAtPixel,(double)yCenterAtPixel);
				//double rScale=rPixelsPerUnit;//rPixelsPerUnit is formerly rScale
				
				int xEnder=rectDest.X+rectDest.Width;
				int yEnder=rectDest.Y+rectDest.Height;
				double rUnitsPerPixel=1.0/rPixelsPerUnit;
				double xSrcStart=-(pOrigin.X*rUnitsPerPixel);
				double xSrc;
				double rSpeed;
				double ySrc=-(pOrigin.Y*rUnitsPerPixel);
				for (int yDest=rectDest.Y; yDest<yEnder; yDest++) {
					xSrc=xSrcStart;
					for (int xDest=rectDest.X; xDest<xEnder; xDest++) {
						//rSpeed=;
						//this.SetPixelHSVA(xDest,yDest,RMath.SafeAngle360(RMath.THETAOFXY_RAD(xSrc,ySrc))/360.0f,1.0,1.0,1.0);
						double rFractalness=(double)(ResultMandelbrot(xSrc,ySrc,(double)rSeed)%256)/255.0; //RMath.SafeAngle360(ResultMandelbrot(xSrc,ySrc,(double)rSeed))/360.0;
						gbDest.SetPixelHsva(xDest,yDest,rFractalness,1.0,rFractalness,1.0);
						xSrc+=rUnitsPerPixel;
					}
					ySrc+=rUnitsPerPixel;
				}
				bGood=true;
			}
			catch (Exception exn) {	
				bGood=false;
				RReporting.ShowExn(exn,"Fractal RenderAll");
			}
			if (bGood) iFramesRendered++;
			return bGood;
		}//end RenderAll
示例#2
0
		public bool RenderIncrement(GBuffer gbDest, IRect rectDest) {
			bool bGood=true;
			try {
				gbFractal.SetPixelArgb(400,300, 255,255,0,0);//debug only
				if (!FinishedRenderingAll()) {
					iTickStartPrev=iTickStart;
					iTickStart=PlatformNow.TickCount;
					if (iTickStartPrev!=-1) {//&&iTickStart!=-1) {
						iTicksPerFrame=iTickStart-iTickStartPrev;
						//if (iTicksPerFrame>iMaxUsableTicksPerFrame_ElseIgnoreFrameRate) {
							//TODO: fix this: //FRACTALREAL rPerformanceScaler=(FRACTALREAL)iMaxUsableTicksPerFrame_ElseIgnoreFrameRate/(FRACTALREAL)iTicksPerFrame;
							//TODO: fix this: iMaxPPF=(int)((FRACTALREAL)iMaxPPF*rPerformanceScaler);
							if (iMaxPPF<1) iMaxPPF=1;
						//}
					}
					int iPixelRel=0;
					while (iPixelRel<iMaxPPF&&iPixelsRendered<gbFractal.iPixelsTotal) {
						//xSrc+=rPassUnitsPerChunk;
						if (xDest>=gbFractal.Width) {
							xDest=0;
							yDest+=iPassPixelsPerChunk;
							xSrc=xSrcStart;
							//ySrc+=rPassUnitsPerChunk;
						}
						xSrc=XPixelToUnitLocation(xDest);
						ySrc=YPixelToUnitLocation(yDest);
						
						if (yDest<gbFractal.Height) {
							//gbFractal.SetPixelRgb(xDest,yDest, 255,0,0);//debug only
	
							//float rFractalness=(float)(ResultMandelbrot((float)xSrc,(float)ySrc)%255)/255.0f;
							//TODO: finish this--use rSeed
							//double rFractalness=(double)(ResultMandelbrot((double)xSrc,(double)ySrc)%255)/255.0;
							
							//if (RMath.Dist(RMath.IRound(gbFractal.Width/2),RMath.IRound(gbFractal.Height/2),xDest,yDest)<iDetailRadius) {
							if (iPass==1||RMath.Dist((double)(gbFractal.Width/2.0),(double)(gbFractal.Height/2.0),(double)xDest,(double)yDest)<(double)iDetailRadius) {
								FRACTALREAL rFractalness=(FRACTALREAL)(ResultMandelbrot((FRACTALREAL)xSrc,(FRACTALREAL)ySrc)%255)/fr255;
								if (iPassPixelsPerChunk>1) {
									GBuffer.SetBrushHsva(rFractalness,1.0,rFractalness,1.0);
									gbFractal.DrawRectCroppedFilled(xDest,yDest,iPassPixelsPerChunk,iPassPixelsPerChunk);
								}
								else gbFractal.SetPixelHsva(xDest,yDest,rFractalness,1.0,rFractalness,1.0);
								//xSrc+=rPassUnitsPerChunk;
							}
							
							iPixelsRendered++;
							iPixelRel++;
						}//end if yDest<gbFractal.Height
						else break;//finished rendering frame
						xDest+=iPassPixelsPerChunk;
					}//end while iPixelRel<iMaxPPF
					
					//TODO: finish this
					if (FinishedRenderingFrame()) {
						iPass++;//must be incremented BEFORE ResetLocations (before OnSetPass)
						ResetLocations();//DOES OnStartPass
						iFramesRendered++;
					}
				}//end if !FinishedRenderingAll
				//gbFractal.SetPixelArgb(400,300, 255,0,255,0);//debug only
				if (!gbDest.Draw(rectDest,gbFractal)) {
					bGood=false;
					RReporting.Warning("Couldn't draw Fractal buffer to destination.","{gbFractal:"+GBuffer.VariableMessage(gbFractal)+"; gbDest:"+GBuffer.VariableMessage(gbDest)+"; rectDest:"+rectDest.Description()+"}");
				}
			}
			catch (Exception exn) {
				bGood=false;
				RReporting.ShowExn(exn,"Fractal RenderIncrement","rendering fractal increment");
			}
			return bGood;
		}//end RenderIncrement