Пример #1
0
void Screen::clearToEndOfLine()
{
  clearImage(loc(cuX,cuY),loc(columns-1,cuY),' ');
}
Пример #2
0
void Screen::clearToBeginOfScreen()
{
  clearImage(loc(0,0),loc(cuX,cuY),' ');
}
Пример #3
0
void Screen::helpAlign()
{
  clearImage(loc(0,0),loc(columns-1,lines-1),'E');
}
Пример #4
0
//this asnimation features a nice plasmaball emerging from the borg's center
//a hollowed sphere is drawn by altering a voxels color-brightness depending on it's distance to the sphere's radius
//the color brightness weakening, and thus the sphere's hull thickness, which is in fact a gradient, is tuned by PLASBALL_M_FILTER, see top of file
//in other words, voxels which are too distant from the sphere, are weakened till they reach zero, producing a nice sphere in the video ram
void plasmaBall()
{
	int32_t col, scale;
	int32_t x, y, z;
	int sqx, sqy, distCalc;
	unsigned int dist;
	color colRGB;
	int dingsVal;

	scale = 10*0x5000;
	dist = 0;
	ioffset = 0;
	
	while (!false)
	{
		//clear backbuffer
		clearImage(black);
		
		//move plasma "forward"
		ioffset += 48;

		//dist is the ball's radius
		dist = (ioffset / 128) % 80;

		for(x = 0; x < MAX_X; x++)
		{
			//cache squared X
			sqx = SQUARE(x-2) * 256;
	
			for(y = 0; y < MAX_Y; y++)
			{
				sqy = SQUARE(y-2) * 256;
				
				for(z = 0; z < MAX_Z; z++)
				{
					//calculate distance to center and check against desired distance
					distCalc = isqrt(sqx + sqy + (z-2)*(z-2)*256);
					
					//reset color;
					col = 0;
					
					//diagonal scrolling sine 
					col += plasmaDiag(x, y, z, scale, ioffset);
				
					//colorspace offset
					col += 0x8000 + (ioffset/32);

					//calculate a voxel brightness (?) weakening value based on the distance to the balls outer hull
					dingsVal = abs((int)dist - distCalc);
					dingsVal *= 255 / PLASBALL_M_FILTER;
					if (dingsVal > 255)
						continue;
					
					//get the voxels rgb color value
					colRGB = HtoRGB(col);
					//alter the voxels brightness (?), without uint overflows ;-)
					colRGB.r = max((int)colRGB.r - dingsVal, 0);
					colRGB.g = max((int)colRGB.g - dingsVal, 0);
					colRGB.b = max((int)colRGB.b - dingsVal, 0);
					
					//finally draw the voxel
					setVoxel((voxel) {x, y, z}, colRGB);			
				} 
			}
		}

		//show frame
		swapAndWait(10);
		
		if((ioffset) >= PLASBALL_ITERATIONS * 0x8000)
			break;
	}
}
Пример #5
0
void Screen::clearToEndOfScreen()
{
  clearImage(loc(cuX,cuY),loc(columns-1,lines-1),' ');
}
Пример #6
0
void Screen::eraseChars(int n)
{
  if (n == 0) n = 1; // Default
  int p = qMax(0,qMin(cuX+n-1,columns-1));
  clearImage(loc(cuX,cuY),loc(p,cuY),' ');
}
Пример #7
0
void
ClipObject::loadCaption(QString ct, QFont cf,
			QColor cc, QColor chc)
{
  m_captionText = ct;
  m_captionFont = cf;
  m_captionColor = cc;
  m_captionHaloColor = chc;

  if (m_captionText.isEmpty())
    {
      m_captionPresent = false;
      return;
    }

  QFontMetrics metric(m_captionFont);
  int mde = metric.descent();
  int fht = metric.height();
  int fwd = metric.width(m_captionText)+2;

  //-------------------
  QImage bImage = QImage(fwd, fht, QImage::Format_ARGB32);
  bImage.fill(0);
  {
    QPainter bpainter(&bImage);
    // we have image as ARGB, but we want RGBA
    // so switch red and blue colors here itself
    QColor penColor(m_captionHaloColor.blue(),
		    m_captionHaloColor.green(),
		    m_captionHaloColor.red());
    // do not use alpha(),
    // opacity will be modulated using clip-plane's opacity parameter  
    bpainter.setPen(penColor);
    bpainter.setFont(m_captionFont);
    bpainter.drawText(1, fht-mde, m_captionText);

    uchar *dbits = new uchar[4*fht*fwd];
    uchar *bits = bImage.bits();
    memcpy(dbits, bits, 4*fht*fwd);

    for(int i=2; i<fht-2; i++)
      for(int j=2; j<fwd-2; j++)
	{
	  for (int k=0; k<4; k++)
	    {
	      int sum = 0;
	      
	      for(int i0=-2; i0<=2; i0++)
		for(int j0=-2; j0<=2; j0++)
		  sum += dbits[4*((i+i0)*fwd+(j+j0)) + k];
	      
	      bits[4*(i*fwd+j) + k] = sum/25;
	    }
	}
    delete [] dbits;
  }
  //-------------------

  QImage cImage = QImage(fwd, fht, QImage::Format_ARGB32);
  cImage.fill(0);
  QPainter cpainter(&cImage);

  // first draw the halo image
  cpainter.drawImage(0, 0, bImage);


  // we have image as ARGB, but we want RGBA
  // so switch red and blue colors here itself
  QColor penColor(m_captionColor.blue(),
		  m_captionColor.green(),
		  m_captionColor.red());
  // do not use alpha(),
  // opacity will be modulated using clip-plane's opacity parameter  
  cpainter.setPen(penColor);
  cpainter.setFont(m_captionFont);
  cpainter.drawText(1, fht-mde, m_captionText);
  m_textureWidth = fwd;
  m_textureHeight = fht;
      
  unsigned char *image = new unsigned char[4*m_textureWidth*m_textureHeight];
  memcpy(image, cImage.bits(), 4*m_textureWidth*m_textureHeight); 

  if (m_imageTex)
    glDeleteTextures(1, &m_imageTex);
  glGenTextures(1, &m_imageTex);

  glActiveTexture(GL_TEXTURE0);
  glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_imageTex);
  glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 
  glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 
  glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexImage2D(GL_TEXTURE_RECTANGLE_ARB,
	       0,
	       4,
	       m_textureWidth,
	       m_textureHeight,
	       0,
	       GL_RGBA,
	       GL_UNSIGNED_BYTE,
	       image);
  glDisable(GL_TEXTURE_RECTANGLE_ARB);

  delete [] image;

  clearImage();

  m_captionPresent = true;
}
Пример #8
0
CachedImage::~CachedImage()
{
    clearImage();
}
Пример #9
0
void plasmaTest()
{
	int32_t col, scale;
	int32_t sqx, sqy, sqz;
	int32_t x, y, z;
	scale = 3*0x5100;
	ioffset = 0;
	
	while (1)
	{
		ioffset += 290; //700;
		
		for(x = 0; x < MAX_X; x++)
		{
			for(y = 0; y < MAX_Y; y++)
			{
				for(z = 0; z < MAX_Z; z++)
				{
					//reset color;
					col = 0;
					
					//diagonal scrolling sine 
					col += 0x2000 * Sine((-x * (0x8000*0x8000 / (MAX_X * scale))) + 
							               (y * (0x8000*0x8000 / (MAX_Y * scale))) + 
										   (-z * (0x8000*0x8000 / (MAX_Z * scale))) + 
										   ioffset
										   ) / 0x8000;
					
					//polar sine
					sqx  = x - 2;
					sqx *= sqx*0x8000;
					sqy  = y - 2;
					sqy *= sqy*0x8000;
					sqz  = z - 2;
					sqz *= sqz*0x8000;
					col += 0x8000/5 * Sine(
						isqrt(sqx + sqy + sqz)*SQRT0x8000/8 + ioffset + 
					    (x*y*z*0x8000*20)/(scale*(1+x+y+z))
				    ) / 0x8000;  //end of sine
					col +=  (
							  (0x3200 * Sine(( x * (0x8000*0x8000 / (MAX_X * scale))) + ioffset) / 0x8000) 
							+ (0x5300 * Sine((-y * (0x8000*0x8000 / (MAX_Y * scale))) + ioffset) / 0x8000)
							+ (0x4400 * Sine((-z * (0x8000*0x8000 / (MAX_Z * scale))) + ioffset) / 0x8000)
							) / (0x13000);
					
					//colorspace offset
					col += 0x2500 + (ioffset/32);

					setVoxelH(x,y,z,col);
				} 
				//printf("\n");
			}
			//printf("\n");
		}
		//printf("\n");
		
		fade(10,2);
		
		if ((ioffset) >= 4*0x8000)
			break;
	}
	clearImage(black);
	fade(15, 100);
}
Пример #10
0
/*============================================================================*/
ChandWriter::ChandWriter( Cdialog *parent, const Crect &rect, const std::string &model, int distance)
: Cimage( parent, rect, KEY_NONE, "", BORDER_NONE, 0, "")
, m_stroke(0)
, m_distance(1000)
, m_started(false)
, m_lastPoint(0,0)
, m_recognizer( NULL)
, m_character( NULL)
, m_result( NULL)
, m_minimum_distance(distance)
{
	//int options =SDL_SWSURFACE; //|SDL_NOFRAME;
	//options =SDL_SWSURFACE|SDL_NOFRAME;
    //Uint32 rmask, gmask, bmask, amask;

    //m_backgroundColour =Cgraphics::m_defaults.handwriting_background;
    m_background.setColours( Cgraphics::m_defaults.handwriting_background, Cgraphics::m_defaults.handwriting_background);
    /* SDL interprets each pixel as a 32-bit number, so our masks must depend
       on the endianness (byte order) of the machine */
	#if 0 //SDL_BYTEORDER ==SDL_BIG_ENDIAN
		rmask = 0xff000000;
		gmask = 0x00ff0000;
		bmask = 0x0000ff00;
		amask = 0x000000ff;
	#else
		//bmask = 0x000000ff;
		//gmask = 0x0000ff00;
		//rmask = 0x00ff0000;
		//amask = 0; //0xff000000;
	#endif

	if ( Cgraphics::m_defaults.handwriting_detection_enabled)
	{
#ifdef USE_SDL2
		assert(0);
		//m_surface =SDL_CreateTexture( m_graphics->m_renderer,
		//		                      SDL_PIXELFORMAT_ARGB8888,
		//							  SDL_TEXTUREACCESS_TARGET,
		//							  m_rect.width()*8, m_rect.height()*8);
#else
		m_surface =SDL_CreateRGBSurface( options, m_rect.width()*8, m_rect.height()*8,
										 ::m_mainGraph->bitsPerPixel(),
										 rmask, gmask, bmask, amask);
#endif
#ifdef USE_ZINNIA
		m_recognizer = zinnia_recognizer_new();

		if (!zinnia_recognizer_open( m_recognizer, model.c_str()))
		{
		    //"ChandWriter::ChandWriter  ERROR: %s\n", zinnia_recognizer_strerror( m_recognizer));
			return;
		}

		  m_character  = zinnia_character_new();
#endif
	 }
	 //zinnia_character_clear( m_character);
	 //zinnia_character_set_width( m_character, m_rect.width());
	 //zinnia_character_set_height( m_character, m_rect.height());
	 clearImage();
	 enablePainting(); //enableDrag();
}
BOOL AP_Win32Dialog_FormatFrame::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	WORD wNotifyCode = HIWORD(wParam);
	WORD wId = LOWORD(wParam);

	switch (wId)
	{			
		case AP_RID_DIALOG_FORMATFRAME_BMP_BOTTOM:		
		{
			bool bChecked;			
			bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_BOTTOM)==BST_CHECKED);							
			toggleLineType(AP_Dialog_FormatFrame::toggle_bottom, bChecked);				
			event_previewExposed();			
			return 1;
		}			
		
		case AP_RID_DIALOG_FORMATFRAME_BMP_TOP:		
		{
			bool bChecked;			
			bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_TOP)==BST_CHECKED);							
			toggleLineType(AP_Dialog_FormatFrame::toggle_top, bChecked);				
			event_previewExposed();			
			return 1;
		}	
		
		case AP_RID_DIALOG_FORMATFRAME_BMP_RIGHT:		
		{
			bool bChecked;			
			bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_RIGHT)==BST_CHECKED);							
			toggleLineType(AP_Dialog_FormatFrame::toggle_right, bChecked);				
			event_previewExposed();			
			return 1;
		}			
		
		case AP_RID_DIALOG_FORMATFRAME_BMP_LEFT:		
		{
			bool bChecked;			
			bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_LEFT)==BST_CHECKED);							
			toggleLineType(AP_Dialog_FormatFrame::toggle_left, bChecked);				
			event_previewExposed();			
			return 1;
		}	
		 
		 
		case AP_RID_DIALOG_FORMATFRAME_BTN_BORDERCOLOR:		
		{	
			CHOOSECOLORW cc;                
			static COLORREF acrCustClr[16];
			
			/* Initialize CHOOSECOLOR */
			ZeroMemory(&cc, sizeof(CHOOSECOLORW));
			cc.lStructSize = sizeof(CHOOSECOLORW);
			cc.hwndOwner = m_hDlg;
			cc.lpCustColors = (LPDWORD) acrCustClr;
			cc.rgbResult = 0;
			cc.Flags = CC_FULLOPEN | CC_RGBINIT;
		 
			if(ChooseColorW(&cc))			
			{
				setBorderColor(UT_RGBColor(GetRValue( cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult)));		
				m_borderButton.setColour(cc.rgbResult);

				/*Force redraw*/
				InvalidateRect(GetDlgItem(hWnd, AP_RID_DIALOG_FORMATFRAME_BTN_BORDERCOLOR), NULL, FALSE);
				event_previewExposed();	
			}

			return 1;
		}	
		
		
		case AP_RID_DIALOG_FORMATFRAME_BTN_BACKCOLOR:		
		{	
			CHOOSECOLORW cc;               
			static COLORREF acrCustClr2[16];
			
			/* Initialize CHOOSECOLOR */
			ZeroMemory(&cc, sizeof(CHOOSECOLORW));
			cc.lStructSize = sizeof(CHOOSECOLORW);
			cc.hwndOwner = m_hDlg;
			cc.lpCustColors = (LPDWORD) acrCustClr2;
			cc.rgbResult = 0;
			cc.Flags = CC_FULLOPEN | CC_RGBINIT;
		 
			if(ChooseColorW(&cc))			
			{
				setBGColor(UT_RGBColor(GetRValue( cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult)));						
				m_backgButton.setColour(cc.rgbResult);

				/*Force redraw*/
				InvalidateRect(GetDlgItem(hWnd, AP_RID_DIALOG_FORMATFRAME_BTN_BACKCOLOR), NULL, FALSE);
				event_previewExposed();	
			}

			return 1;
		}			

		case AP_RID_DIALOG_FORMATFRAME_CHK_TEXTWRAP:
		{
			bool bChecked;
			bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_CHK_TEXTWRAP)==BST_CHECKED);

			setWrapping(bChecked);

			// Not necessary now, but we may some day show
			// text wrapping in the preview.
			event_previewExposed();
			return 1;
		}

			
		case AP_RID_DIALOG_FORMATFRAME_BTN_CANCEL:			
			m_answer = AP_Dialog_FormatFrame::a_CLOSE;
			destroy();
			event_Close();
			EndDialog(hWnd,0);
			return 1;

		case AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS:
		{
			if (wNotifyCode == CBN_SELCHANGE)                       
			{
				int nSelected = getComboSelectedIndex (AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS);

				if (nSelected != CB_ERR)
				{
					UT_LocaleTransactor t(LC_NUMERIC, "C");					
					UT_Win32LocaleString thickness;
					UT_UTF8String thickness_utf8 = thickness.utf8_str ();
					getComboTextItem(AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS, nSelected, thickness);
					setBorderThicknessAll(thickness_utf8);					
					event_previewExposed();
				}
			}
			return 1;
		}

		case AP_RID_DIALOG_FORMATFRAME_BUTTON_SELIMAGE:
				askForGraphicPathName();
				return 1;

		case AP_RID_DIALOG_FORMATFRAME_BUTTON_NOIMAGE:
				clearImage();
				return 1;

		case AP_RID_DIALOG_FORMATFRAME_RADIO_PARA:
				setPositionMode(FL_FRAME_POSITIONED_TO_BLOCK);
				return 1;

		case AP_RID_DIALOG_FORMATFRAME_RADIO_COLUMN:
				setPositionMode(FL_FRAME_POSITIONED_TO_COLUMN);
				return 1;

		case AP_RID_DIALOG_FORMATFRAME_RADIO_PAGE:
				setPositionMode(FL_FRAME_POSITIONED_TO_PAGE);
				return 1;

		case AP_RID_DIALOG_FORMATFRAME_BTN_APPLY:
				applyChanges();
				return 1;

		
			
		default:							// we did not handle this notification 
			UT_DEBUGMSG(("WM_Command for id %ld\n",wId));
			return 0;						// return zero to let windows take care of it.
	}
}
Пример #12
0
ImageResource::~ImageResource()
{
    WTF_LOG(Timers, "~ImageResource %p", this);
    clearImage();
}
Пример #13
0
void ImageResource::clear()
{
    prune();
    clearImage();
    setEncodedSize(0);
}
Пример #14
0
 void SIFT_ADAPTER::clear()
 {
     clear_sift_model();
     clearImage();
 }
Пример #15
0
void Screen::clearToBeginOfLine()
{
  clearImage(loc(0,cuY),loc(cuX,cuY),' ');
}
Пример #16
0
void plasmaWave() {
	unsigned short data[5][5], l;
	unsigned char j, k, z, r, g ,b;
	int dingsVal, borgDiameter, sqy, sqx;
	unsigned int i;
	color colRGB;
	
	ioffset = 0;
	borgDiameter = BORGDIAMETER;
	
	//clear screen and backbuffer
	clearScreen(black);

	for (i = 0; i < WAVES_ITERATIONS; i++)
    {
        //advance plasma
        ioffset += WAVES_PLASMASPEED;
        
        //clear backbuffer
        clearImage(black);
        
        //calc z positions for one corner
        // x x x x x
        // 0 0 0 0 x
        // 0 0 0 0 x
        // 0 0 0 0 x
        // 0 0 0 0 x       
		for (j = 0; j < 5; j++) {
			l = Sine(j * (0x8000 / (MAX_Z-1)) + (i*WAVES_ANIMSPEED)) + 0x8000;
			data[j][0] = l;
			data[0][j] = l;
		}
		
		//multiplex data over whole plane
		for (j = 1; j < 5; j++) {
			for (k = 1; k < 5; k++) {
				data[j][k] = (data[j-1][k] + data[j][k-1] + data[j-1][k-1])/3;
			}
		}
        		
		//z-anti-aliasing
		for (j = 0; j < 5; j++)
        {
            sqy = ISQPY(j);
			for (k = 0; k < 5; k++)
            {   
                sqx = ISQPX(k);
                          
                //scale value (distcalc)
                data[j][k] = (data[j][k] * MAX_Z * WAVES_ZDIST_RESSCALE) / 0xFFFF;
                
 		        //walk the z-range and see if we have to light up the pixel
                //see plasmaball for this technique
                for(z = 0; z < MAX_Z; z++)
                {
                    unsigned int col;
                    //calc plasma
                    //strange glitches happen here..
                    col = ((plasmaPolar(sqx, sqy, ISQPZ(2*z), 12, borgDiameter, ioffset) + 0x8000) * 49152) / 0xFFFF;
                    col = (col*49152)/32768;
                    
                    colRGB = HtoRGB(col);
                                      
                    dingsVal = abs((int)data[j][k] - (z * WAVES_ZDIST_RESSCALE));
                    dingsVal = (dingsVal * 255) / WAVES_M_FILTER;
                    if (dingsVal > 255)
                    	continue;                                   		
                    
                    //alter the voxels brightness (?), without uint overflows ;-)
                    r = max((int)colRGB.r - dingsVal, 0);
                    g = max((int)colRGB.g - dingsVal, 0);
                    b = max((int)colRGB.b - dingsVal, 0);
                    
                    //finally draw the voxel
                    setVoxel((voxel){j, k, z}, (color){r, g, b});					
                }
			}
		}
		
		swapAndWait(8);
	}
}
Пример #17
0
void Screen::clearEntireLine()
{
  clearImage(loc(0,cuY),loc(columns-1,cuY),' ');
}
Пример #18
0
void plasmaSea()
{
	int32_t col, scale, tmpR, tmpG, tmpB;
	int32_t x, y, z, i;
	int sqx, sqy, dingsVal, borgDiameter, distCalc;
	color colRGB;
    plasmaSeaWaveList dummy;
	plasmaSeaWaveList *head = &dummy, *runner;
	
	//drops
	plasmaSeaDrop drops[PLASSEA_MAXDROPS];

	scale = 16;
	borgDiameter = BORGDIAMETER_XY;
	ioffset = 0;
	dummy.next = NULL;

	//iqnit all drops as "fallen", so they'll get initialized by the usual pseudorandomness
	for(i = 0; i < PLASSEA_MAXDROPS; i++)
	{	
        drops[i].vPos.x = (MAX_X - 1) / 2;
        drops[i].vPos.y = (MAX_Y - 1) / 2;
		drops[i].zDist = PLASSEA_ZDISTMAX + 16; //overshoot zdistmax, to be sure
	}
	
	while(!false)
	{
		//clear backbuffer
		clearImage(black);
		
		//move plasma "forward"
		ioffset += PLASSEA_PLASMASPEED;

		//advance the drops
		for(i = 0; i < PLASSEA_MAXDROPS; i++)
		{
            //is the drop in z=0 and has spawned no effect yet?
            if(!drops[i].spawnFlag && (drops[i].zDist > (PLASSEA_ZDISTMAX - PLASSEA_ZDIST_RESSCALE)))
            {
                drops[i].spawnFlag = 1;
                
            	//add a new wave to the list
				for(runner = head; runner->next != NULL; runner = runner->next);
				runner->next = (plasmaSeaWaveList *)malloc(sizeof(plasmaSeaWaveList));
				runner = runner->next;
				runner->next = NULL;
				
				runner->element.center.x = drops[i].vPos.x;
			    runner->element.center.y = drops[i].vPos.y;
				runner->element.center.z = 0;
				runner->element.pDist = 0;			
				//set a custom offset for the plasma colors
				runner->element.myIOff = 0;//rnd32;
		        runner->element.speed = drops[i].speed;
            }
			//is the drop already fallen?
			else if(drops[i].zDist > PLASSEA_ZDISTMAX)
			{
				//yes, spawn a new drop			
				drops[i].vPos.x = easyRandom() % MAX_X;
				drops[i].vPos.y = easyRandom() % MAX_Y;
				drops[i].speed = (easyRandom() % 2) + 1;
				//put drop somewehere in the non-visible range
				drops[i].zDist = easyRandom() % (PLASSEA_Z_HEADROOM * PLASSEA_ZDIST_RESSCALE);
				drops[i].spawnFlag = 0;
			}
			else
			{
				//no, add speed 
				drops[i].zDist += drops[i].speed;
			}
		}

		//advance and recycle waves
		for(runner = head; runner->next != NULL; runner = runner->next)
		{
            plasmaSeaWaveList *ltmp = (plasmaSeaWaveList *)runner->next;
            if(ltmp->element.pDist > PLASSEA_PDISTMAX)
            {
                //recycle
                runner->next = ltmp->next;
                free(ltmp);
                
                if(runner->next == NULL)
                    break;
            }
            else
    		{
                //add speed, but half as fast
                if(ioffset % (2*PLASSEA_PLASMASPEED) == 0)
                   ltmp->element.pDist += ltmp->element.speed;
            }
        }

		for(x = 0; x < MAX_X; x++)
		{
			//z = 0
			for(y = 0; y < MAX_Y; y++)
			{
                tmpR = 0; tmpG = 0; tmpB = 0;
                
                //for all waves
                for(runner = head; runner != NULL; runner = runner->next)
		        {                 
                    if((runner != head) && (runner->element.pDist <= PLASSEA_PDISTMAX))
                    {
                        //modified calculation with custom centerpoint
                        sqx = SQUARE(x - runner->element.center.x);
         				sqy = SQUARE(y - runner->element.center.y);
         				
         				//calculate distance to wave center
	                    distCalc = isqrt(sqx*SQUARE(PLASSEA_ZDIST_RESSCALE) + sqy*SQUARE(PLASSEA_ZDIST_RESSCALE));

        				//reset color;
        				col = 0;
        				
        				//diagonal scrolling sine 
        				col += plasmaPolarFlat(sqx, sqy, scale, borgDiameter, ioffset + runner->element.myIOff);
        			
        				//colorspace offset
        				col += 0x8000;
        				//col  = (col * 49152) / 0xFFFF;
        				
        				//some mystic scaling stolen from setVoxelH, this removes yet another color clipping effect
        				col = (col*49152)/32768;
        				
        				//calculate a voxel brightness (?) weakening value based on the distance to the balls outer hull
    					dingsVal = abs((int)runner->element.pDist - distCalc);
    					dingsVal *= 255 / PLASSEA_M_FILTER;
    					if (dingsVal > 255)
    						continue;
						
        				//get new voxels color
        				colRGB = HtoRGB(col);
        				//alter the voxels brightness (?), without uint overflows ;-)
                        colRGB.r = max((int)colRGB.r - dingsVal, 0);
         				colRGB.g = max((int)colRGB.g - dingsVal, 0);
		                colRGB.b = max((int)colRGB.b - dingsVal, 0);
        				
        				//finally add the new color
        				tmpR += colRGB.r; tmpG += colRGB.g; tmpB += colRGB.b;
                    }
                }
                
                //draw the voxel
                tmpR /= 2; tmpG /= 2; tmpB /= 2;
                colRGB.r = min(tmpR, 255);
                colRGB.g = min(tmpG, 255);
                colRGB.b = min(tmpB, 255);
                setVoxel((voxel) {x, y, 0}, colRGB);
                
                //normalize();
                    
				//for all drops
				for(i = 0; i < PLASSEA_MAXDROPS; i++)
				{                                     	
					//check if this drop is in our z-column
					if((drops[i].vPos.x == x) && (drops[i].vPos.y == y))
					{
						//if so, walk the z-range and see if we have to light up the pixel
						//see plasmaball for this technique
						for(z = 0; z < MAX_Z; z++)
						{
							dingsVal = abs((int)drops[i].zDist - ((4 - z + PLASSEA_Z_HEADROOM) * PLASSEA_ZDIST_RESSCALE));
							dingsVal *= 255 / PLASSEA_M_FILTER;
							if (dingsVal > 255)
								continue;
							
							//if(z == 0)
							//{
                                // colRGB.r = 0;
							   //  colRGB.g = 128;
							 //    colRGB.b = 255;
                            //}
                            //else
                            //{
    							//alter the voxels brightness (?), without uint overflows ;-)
    							colRGB.r = 0;//max(0 - dingsVal, 0);
    							colRGB.g = max(128 - dingsVal, 0);
    							colRGB.b = max(255 - dingsVal, 0);
                            //}
							
							//finally draw the voxel
							drops[i].vPos.z = z;
							setVoxel(drops[i].vPos, colRGB);					
						}
					}
				}
			}
		}

		//show frame
		swapAndWait(10);
		
		if((ioffset) >= PLASSEA_ITERATIONS * 0x8000)
			break;
	}
}
Пример #19
0
void funkyBeat() {
	beat beats[31] = {// erster Takt
					  {chess,      White,   8}, 
				  	  {chessInv,   C2,     12},
					  {all,        Black,   4},
					  {blockDiagonal,        Red,     6},
					  {all,        Black,  10},	
					  {chess,      C1,     12},
					  {fade1,      Yellow, 16},
					  {chessInv,   C2,      8},
					  {chess,      Black,   8},
					  {blockDiagonal,   Red,     8},
					  {blockDown,       White,   8},
					  {smallCube,  Red,    12},
					  {chessInv,   Blue,    4},  
					  {all,        Green,   6},
					  {all,        Black,   2},
					  {chess,      Yellow,  8}, 
					  // zeiter Takt
					  {all,        Black,   8},
					  {smallCube,  White,  10},
					  {chess,      Black,   6},
					  {chessInv,   C3,      2},
					  {blockDiagonal,        Green,   8},
					  {smallCube,  Black,   8},
					  {chess,      Red,     8},
					  {all,        Black,   8},
					  {smallCube,  Yellow,  8},
					  {all,        Black,   8},
					  {fade1,       C2,     16},
					  {smallCube,  White,   4},
					  {chessInv,   Red,     6},
					  {blockUp,    Green,   2},
					  {chess,      C1,      8}
					};
	unsigned char i, j, b, x, y, z;
	color curColor;
	uint32_t *im;
	
	for (j = 0; j < 10; j++) {
		for (b = 0; b < 31; b++) {
			clearImage(black);
			switch (beats[b].bC) {
				case Black:
					curColor = black;
					break;
				case White:
					curColor = white;
					break;
				case Red:
					curColor = red;
					break;
				case Green:
					curColor = green;
					break;
				case Blue:
					curColor = blue;
					break;
				case Yellow:
					curColor = (color) {255, 255, 102};
					break;
				case C1:
					curColor = (color) {102, 102, 255};
					break;
				case C2:
					curColor = (color) {102, 102, 255};
					break;
				case C3:
					curColor = (color) {113, 120, 204};
					break;
			}
			switch (beats[b].pP) {
				case fade1:
				case all:
					clearImage(curColor);
					break;
					
				case chess:
					im = (uint32_t *) imag;
					for (i = 0; i < MAX_Z*MAX_Y*MAX_X; i++) {
						if (i & 1) {
							*im++ = curColor.r;
							*im++ = curColor.g;
							*im++ = curColor.b;
						} else {
							im += 3;
						}
					}	
					break;
					
				case chessInv:
					im = (uint32_t *) imag;
					for (i = 0; i < MAX_Z*MAX_Y*MAX_X; i++) {
						if (!(i & 1)) {
							*im++ = curColor.r;
							*im++ = curColor.g;
							*im++ = curColor.b;
						} else {
							im += 3;
						}
					}
					break;
					
				case smallCube:
					for (z = 1; z < 4; z++) {
						for (y = 1; y < 4; y++) {
							for (x = 1; x < 4; x++) {
								setVoxel((voxel) {x, y, z}, curColor);
							}
						}
					}
					break;
					
				case blockUp:
					for (z = 2; z < 5; z++) {
						for (y = 0; y < 5; y++) {
							for (x = 0; x < 5; x++) {
								setVoxel((voxel) {x, y, z}, curColor);
							}
						}
					}
					break;	
				
				case blockDown:
					for (z = 0; z < 3; z++) {
						for (y = 0; y < 5; y++) {
							for (x = 0; x < 5; x++) {
								setVoxel((voxel) {x, y, z}, curColor);
							}
						}
					}
					break;
					
				case blockRight:
					for (z = 0; z < 5; z++) {
						for (y = 2; y < 5; y++) {
							for (x = 0; x < 5; x++) {
								setVoxel((voxel) {x, y, z}, curColor);
							}
						}
					}
					break;
					
				case blockDiagonal:
					for (z = 0; z < 5; z++) {
						for (y = 0; y < 5; y++) {
							for (x = 0; x < 5; x++) {
								if ((x + y + z) < 6)
									setVoxel((voxel) {x, y, z}, curColor);
							}
						}
					}
					break;
			}
			
			if (beats[b].pP == fade1)
				fade(16, beats[b].time);
			else 
				swapAndWait(beats[b].time*16);
		}
	}
}
Пример #20
0
bool
ClipObject::processCommand(QString cmd)
{
  bool ok;
  cmd = cmd.toLower();
  QStringList list = cmd.split(" ", QString::SkipEmptyParts);
  
  if (list[0] == "mop")
    {
      if (list.size() == 2 && list[1] == "clip")
	{
	  m_mopClip = true;
	  return true;
	}
      else
	return false;
    }
  else if (list[0] == "tfset")
    {
      int tf = 1000;
      if (list.size() == 2) tf = qMax(0, list[1].toInt());
      m_tfset = tf;
      return true;
    }
  else if (list[0] == "reorientcamera")
    {
      m_reorientCamera = true;
      return true;
    }
  else if (list[0] == "color")
    {
      QColor dcolor = QColor::fromRgbF(m_color.x,
				       m_color.y,
				       m_color.z);
      QColor color = DColorDialog::getColor(dcolor);
      if (color.isValid())
	{
	  float r = color.redF();
	  float g = color.greenF();
	  float b = color.blueF();
	  m_color = Vec(r,g,b);
	}
    }
  else if (list[0] == "solidcolor")
    {
      if (list.size() == 2 &&
	  list[1] == "no")
	m_solidColor = false;
      else
	m_solidColor = true;
      return true;
    }
  else if (list[0] == "savesliceimage")
    {
      m_resliceSubsample = 1;
      m_saveSliceImage = true;
      if (list.size() == 2) m_resliceSubsample = qMax(1, list[1].toInt(&ok));
      return true;
    }
  else if (list[0] == "reslice")
    {
      m_resliceSubsample = 1;
      m_resliceTag = -1;
      m_resliceVolume = true;
      if (list.size() > 1) m_resliceSubsample = qMax(1, list[1].toInt(&ok));
      if (list.size() > 2) m_resliceTag = list[2].toInt(&ok);
      return true;
    }
  else if (list[0] == "grid")
    {
      if (list.size() == 1)
	{
	  m_gridX = m_gridY = 10;
	}
      else if (list.size() == 2 && list[1] == "no")
	{
	  m_gridX = m_gridY = 0;
	}
      else if (list.size() == 3)
	{
	  m_gridX = list[1].toInt();
	  m_gridY = list[2].toInt();
	}
      return true;
    }
  else if (list[0] == "image")
    {
      if (list.size() == 2 &&
	  list[1] == "no")
	clearImage();
      else
	loadImage();
      return true;
    }
  else if (list[0] == "imageframe")
    {
      if (list.size() == 2)
	{
	  int frm = list[1].toInt(&ok);
	  if (frm >= 0)
	    {
	      loadImage(m_imageName, frm);
	    }
	  else
	    QMessageBox::information(0, "Error",
				     "ImageFrame not changed.  Positive values required");
	}
      else
	QMessageBox::information(0, "Error",
				 "Please specify ImageFrame number for the clipplane");
      return true;
    }
  else if (list[0] == "caption")
    {
      if (list.count() == 2 &&
	  list[1] == "no")
	clearCaption();
      else
	loadCaption();

      return true;
    }
  else if (list[0] == "vscale" ||
	   list[0] == "scale")
    {
      if (list.size() > 1)
	{
	  float scl1, scl2;
	  if (list.size() == 2)
	    {
	      scl1 = list[1].toFloat(&ok);
	      scl2 = scl1;
	    }
	  else
	    {
	      scl1 = list[1].toFloat(&ok);
	      scl2 = list[2].toFloat(&ok);
	    }
	  if (list[0] == "scale")
	    {
	      m_scale1 = -qAbs(scl1);
	      m_scale2 = -qAbs(scl2);
	    }
	  else
	    {
	      m_scale1 = scl1;
	      m_scale2 = scl2;
	    }
	}
      else
	QMessageBox::information(0, "Error",
				 "Please specify both scalings for the clipplane");
      return true;
    }
  else if (list[0] == "opacity")
    {
      if (list.size() == 2)
	{
	  float scl = list[1].toFloat(&ok);
	  if (scl >= 0 && scl <= 1)
	    {
	      m_opacity = scl;
	      m_opacity = qMax(0.02f, qMin(1.0f, m_opacity));
	    }
	  else
	    QMessageBox::information(0, "Error",
				     "Opacity not changed.  Value between 0 and 1 required");
	}
      else
	QMessageBox::information(0, "Error",
				 "Please specify opacity for the clipplane");
      return true;
    }
  else if (list[0] == "translate" ||
	   list[0] == "translatex" ||
	   list[0] == "translatey" ||
	   list[0] == "translatez" ||
	   list[0] == "move" ||
	   list[0] == "movex" ||
	   list[0] == "movey" ||
	   list[0] == "movez")
    {
      Vec pos;
      float x=0,y=0,z=0;

      if (list[0] == "translate" || list[0] == "move")
	{
	  if (list.size() > 1) x = list[1].toFloat(&ok);
	  if (list.size() > 2) y = list[2].toFloat(&ok);
	  if (list.size() > 3) z = list[3].toFloat(&ok);
	  pos = Vec(x,y,z);
	}
      else
	{
	  float v=0;
	  if (list.size() > 1) v = list[1].toFloat(&ok);
	  if (list[0] == "translatex" || list[0] == "movex")
	    pos = Vec(v,0,0);
	  else if (list[0] == "translatey" || list[0] == "movey")
	    pos = Vec(0,v,0);
	  else if (list[0] == "translatez" || list[0] == "movez")
	    pos = Vec(0,0,v);
	}

      if (list[0].contains("move"))
	{
	  Vec cpos = position();
	  pos = pos + cpos;
	}
      setPosition(pos);
      return true;
    }
  else if (list[0] == "rotatea" ||
	   list[0] == "rotateb" ||
	   list[0] == "rotatec")
    {
      float angle = 0;
      if (list.size() > 1)
	{
	  angle = list[1].toFloat(&ok);
	  if (list[0] == "rotatea") rotate(m_xaxis, angle);
	  if (list[0] == "rotateb") rotate(m_yaxis, angle);
	  if (list[0] == "rotatec") rotate(m_tang, angle);
	}
      else
	{
	  QMessageBox::information(0, "", "No angle specified");
	}       
      return true;
    }
  else if (list[0] == "movea" ||
	   list[0] == "moveb" ||
	   list[0] == "movec")
    {
      float shift = 0;
      if (list.size() > 1)
	{
	  shift = list[1].toFloat(&ok);
	  if (list[0] == "movea") translate(shift*m_xaxis);
	  if (list[0] == "moveb") translate(shift*m_yaxis);
	  if (list[0] == "movec") translate(shift*m_tang);
	}
      else
	{
	  QMessageBox::information(0, "", "No distance specified");
	}       
      return true;
    }
  else if (list[0] == "rotate" ||
	   list[0] == "rotatex" ||
	   list[0] == "rotatey" ||
	   list[0] == "rotatez" ||
	   list[0] == "addrotation" ||
	   list[0] == "addrotationx" ||
	   list[0] == "addrotationy" ||
	   list[0] == "addrotationz")
    {
      Quaternion rot;
      float x=0,y=0,z=0,a=0;
      if (list[0] == "rotate" || list[0] == "addrotation")
	{
	  if (list.size() > 1) x = list[1].toFloat(&ok);
	  if (list.size() > 2) y = list[2].toFloat(&ok);
	  if (list.size() > 3) z = list[3].toFloat(&ok);
	  if (list.size() > 4) a = list[4].toFloat(&ok);
	  rot = Quaternion(Vec(x,y,z), DEG2RAD(a));
	}
      else
	{
	  float a=0;
	  if (list.size() > 1) a = list[1].toFloat(&ok);
	  if (list[0] == "rotatex" || list[0] == "addrotationx")
	    rot = Quaternion(Vec(1,0,0), DEG2RAD(a));
	  else if (list[0] == "rotatey" || list[0] == "addrotationy")
	    rot = Quaternion(Vec(0,1,0), DEG2RAD(a));
	  else if (list[0] == "rotatez" || list[0] == "addrotationz")
	    rot = Quaternion(Vec(0,0,1), DEG2RAD(a));
	}

      if (list[0].contains("addrotation"))
	{
	  Quaternion orot = orientation();
	  rot = rot*orot;
	}
      setOrientation(rot);
      return true;
    }
  else
    QMessageBox::information(0, "Error",
			     QString("Cannot understand the command : ") +
			     cmd);

  return false;
}