Source Code (Use browser search to find items of interest.)

Class Index

ksirtet'FEPieceInfo (./kdegames/ksirtet/fe_piece.h:25)

class FEPieceInfo : public GPieceInfo
{
 public:
	FEPieceInfo() {}

	uint nbBlocks() const { return FE_NB_BLOCKS; }
	uint nbForms()  const { return FE_NB_FORMS;  }
	uint nbTypes()  const { return FE_NB_TYPES;  }

	const int *i(uint form) const { return FE_FORMS[form].i; }
	const int *j(uint form) const { return FE_FORMS[form].j; }
	uint value(uint type, uint n) const
		{ return (n%2 ? type/4 : type%4); }
	uint form(uint) const         { return 0; }
	uint nbConfigurations(uint type) const
		{ return ((type%4)==(type/4) ? 2 : 4);}

	QPixmap *drawPixmap(uint blockWidth, uint blockHeight,
						uint blockType, uint blockMode, bool lighted) const;
	
	uint nbBlockTypes() const { return FE_NB_BLOCK_TYPES; }
	uint nbBlockModes() const { return FE_NB_BLOCK_MODES; }
	uint garbageType() const  { return FE_NB_BLOCK_TYPES-1; }
};

ksirtet'FEPieceInfo::drawPixmap() (./kdegames/ksirtet/fe_piece.cpp:18)

QPixmap *FEPieceInfo::drawPixmap(uint blockWidth, uint blockHeight,
								 uint blockType, uint blockMode,
								 bool lighted) const
{
	ASSERT( blockWidth==blockHeight ); // drawing code assumes that
	uint w = blockWidth;
	QPixmap *pix = new QPixmap(w, w);

	QColor col = FE_COLORS[blockType];
	if (lighted) col = col.light();

	// base mode
	double d = (sqrt(2)-2./3)*w;
	QRect cr = QRect(0, 0, d, d);
	cr.moveCenter(QPoint(w/2, w/2));
	QPainter p(pix);
	p.setBrush(col);
	p.setPen( QPen(Qt::NoPen) );
	p.drawEllipse(cr);

	if ( blockMode==0 ) return pix;
	
	// special mode
	double a  = w/(3*sqrt(2));
	double ra = 2*w/3+1;
	cr = QRect(0, 0, ra, ra);
	
	// first drawing with egg color
	p.setBrush(col);
	p.setPen( QPen(Qt::NoPen) );
	if ( blockMode & FE_UP    ) p.drawRect(    a,     0, w-2*a+1,       a);
	if ( blockMode & FE_RIGHT ) p.drawRect(w-a+1,     a,       a, w-2*a+1);
	if ( blockMode & FE_DOWN  ) p.drawRect(    a, w-a+1, w-2*a+1,       a);
	if ( blockMode & FE_LEFT  ) p.drawRect(    0,     a,       a, w-2*a+1);

	// second drawing with background color
	p.setBrush(Qt::black);
	if ( (blockMode & FE_UP) || (blockMode & FE_LEFT) ) {
		cr.moveCenter(QPoint(0, 0));
		p.drawPie(cr, 16*-90, 16*90);
	}
	if ( (blockMode & FE_RIGHT) || (blockMode & FE_UP) ) {
		cr.moveCenter(QPoint(w-1, 0));
		p.drawPie(cr, 16*180, 16*90);
	}
	if ( (blockMode & FE_DOWN) || (blockMode & FE_RIGHT) ) {
		cr.moveCenter(QPoint(w-1, w-1));
		p.drawPie(cr, 16* 90, 16*90);
	}
	if ( (blockMode & FE_LEFT) || (blockMode & FE_DOWN) ) {
		cr.moveCenter(QPoint(0, w-1));
		p.drawPie(cr, 16*  0, 16*90);
	}

	return pix;
}

ksirtet'FEPieceInfo::garbageType() (./kdegames/ksirtet/fe_piece.h:47)

	uint garbageType() const  { return FE_NB_BLOCK_TYPES-1; }
};