Exemple #1
0
bool IGraphics::DrawRect(const IColor* pColor, IRECT* pR)
{
  bool rc = DrawHorizontalLine(pColor, pR->T, pR->L, pR->R);
  rc &= DrawHorizontalLine(pColor, pR->B, pR->L, pR->R);
  rc &= DrawVerticalLine(pColor, pR->L, pR->T, pR->B);
  rc &= DrawVerticalLine(pColor, pR->R, pR->T, pR->B);
  return rc;
}
Exemple #2
0
void Viewport2D::DrawLine(int pX0, int pY0, int pX1, int pY1, MR_UInt8 pColor)
{
	int lTemp;

	if(pY0 == pY1) {
		// Horizontal line
		DrawHorizontalLine(pY0, pX0, pX1, pColor);
	}
	else {
		if(pY0 > pY1) {
			lTemp = pY0;
			pY0 = pY1;
			pY1 = lTemp;

			lTemp = pX0;
			pX0 = pX1;
			pX1 = lTemp;
		}

		// Return if the line is not on screen

		if((pY1 < 0) || (pY0 >= mYRes) || ((pX0 < 0) && (pX1 < 0)) || ((pX0 >= mXRes) && (pX1 >= mXRes))
		) {
			return;
		}

		int lDXDY = ((pX1 - pX0) << 8) / (pY1 - pY0);
		int lXS = pX0 << 8;
		int lXE = lXS + lDXDY / 2;
		int lY = pY0;

		while(lY < pY1) {
			int lXStart = lXS >> 8;
			int lXEnd = lXE >> 8;

			if(lXEnd > lXStart) {
				lXEnd--;
			}
			else if(lXEnd < lXStart) {
				lXEnd++;
			}

			DrawHorizontalLine(lY, lXStart, lXEnd, pColor);

			// Prepare the next line;
			lXS = lXE;
			lXE += lDXDY;
			lY++;
		}

		// Draw the last line
		DrawHorizontalLine(lY, lXS >> 8, pX1, pColor);

	}
}
	void FillTexture( LockedTexture& texture )
	{
		const SFloatRGBAColor base_color = m_BaseColor;
		const SFloatRGBAColor line_color = m_LineColor;

		// Fill the texture with the base color
		texture.Clear( base_color );

		const int w = texture.GetWidth();
		const int h = texture.GetHeight();
		const int num_rows    = m_NumRows;
		const int num_columns = m_NumColumns;
		const unsigned int row_height   = h / num_rows;
		const unsigned int column_width = w / num_columns;

		const int line_width = m_LineWidth;
		const int line_width_at_tex_border
			= m_DoubleLineWidthAtTextureBorders ? line_width * 2 : line_width;

		// Draw the horizontal lines
		for( int y=0; y<line_width_at_tex_border/2; y++ )
			DrawHorizontalLine( y, texture );

		for( int i=1; i<num_rows-1; i++ )
		{
			for( int y=0; y<line_width; y++ )
				DrawHorizontalLine( i * row_height - line_width/2 + y, texture );
		}

		for( int y=0; y<line_width_at_tex_border/2; y++ )
			DrawHorizontalLine( h - 1 - y, texture );

		// Draw the vertical lines
		for( int x=0; x<line_width_at_tex_border/2; x++ )
			DrawVerticalLine( x, texture );

		for( int i=1; i<num_columns-1; i++ )
		{
			for( int x=0; x<line_width; x++ )
				DrawVerticalLine( i * column_width - line_width/2 + x, texture );
		}

		for( int x=0; x<line_width_at_tex_border/2; x++ )
			DrawVerticalLine( w - 1 - x, texture );
	}
Exemple #4
0
void wxStdRenderer::DrawFrameWithoutLabel(wxDC& dc,
                                          const wxRect& rectFrame,
                                          const wxRect& rectLabel)
{
    // draw left, bottom and right lines entirely
    DrawVerticalLine(dc, rectFrame.GetLeft(),
                     rectFrame.GetTop(), rectFrame.GetBottom() - 2);
    DrawHorizontalLine(dc, rectFrame.GetBottom() - 1,
                       rectFrame.GetLeft(), rectFrame.GetRight());
    DrawVerticalLine(dc, rectFrame.GetRight() - 1,
                     rectFrame.GetTop(), rectFrame.GetBottom() - 1);

    // and 2 parts of the top line
    DrawHorizontalLine(dc, rectFrame.GetTop(),
                       rectFrame.GetLeft() + 1, rectLabel.GetLeft());
    DrawHorizontalLine(dc, rectFrame.GetTop(),
                       rectLabel.GetRight(), rectFrame.GetRight() - 2);
}
Exemple #5
0
void CBitmapCache::FillSolidRect(COLORREF rgb, const RECT* lprc)
{
   DrawHorizontalLine(lprc->left, lprc->top, lprc->right, rgb, lprc->bottom - lprc->top);
/* LPBYTE lpPixels = m_lpPixels;
   const DWORD dwBmpBytes     = m_dibSize.cx * m_dibSize.cy;
   rgb = RGB2DIB(rgb);

   //TODO: MMX or SSE化
   __asm {
      mov edi, dword ptr [lpPixels]
      mov ecx, dword ptr [dwBmpBytes]
      mov eax, dword ptr [rgb]
      cld
      rep stosd
   }*/
// DWORD* p = (DWORD*)m_lpPixels;
// DWORD* const pend = p + dwBmpBytes;
// while (p < pend) {
//    *p++ = rgb;
// }
}
Exemple #6
0
bool IGraphics::DrawHorizontalLine(const IColor* pColor, IRECT* pR, float y)
{
  y = BOUNDED(y, 0.0f, 1.0f);
  int yi = pR->B - int(y * (float) (pR->B - pR->T));
  return DrawHorizontalLine(pColor, yi, pR->L, pR->R);
}
Exemple #7
0
void Menu_Draw(Bitmap* b){

	//Create Background
	DrawFilledRectangle(b, borderX, borderY, SCREEN_X - 2 * borderX, SCREEN_Y - 2 * borderY, RGB(0,0,0));
	//Inner red Border
	DrawRectangle(b, borderX + rectBorder, borderY + rectBorder ,
	 (SCREEN_X - 2 * borderX) - 2 * rectBorder , (SCREEN_Y - 2 * borderY ) - 2 * rectBorder, RGB(193,0,0));

	//Column Header
	char *itemHeader;
	asprintf(&itemHeader, "Itemname    SPD  SPW   INV    PRZ");
	DrawText(b, itemHeader, listEdgeX + 0 * colWidth, listEdgeY - rowHeight -2);
	free(itemHeader);

	//Items
	for(int i = 0 ; i < maxListRows ; i++){
		itemIndex = i + menuSelectedItem - 4;
		if (itemIndex >= 0 && itemIndex <= itemCount){
			//Mark Items you can't afford
			if(itemList[itemIndex]->prize > p1.money){
				DrawFilledCircle(b, listEdgeX +circleRadius , listEdgeY + rowHeight * i + circleRadius + 1, circleRadius ,RGB(255,0,0));
			}	
			//Item Owned
			if(listCount(&p1.inventory, (Item*)itemList[itemIndex]) >= 1){
				DrawFilledCircle(b, listEdgeX +circleRadius , listEdgeY + rowHeight * i + circleRadius + 1, circleRadius ,RGB(0,255,0));
			}
			//Item name
			char *itemName;
			asprintf(&itemName, itemList[itemIndex]->name);
			DrawText(b, itemName, listEdgeX + 0 * colWidth, listEdgeY + rowHeight * i);
			free(itemName);

			//Item Dig-Speed
			char *itemSPD;
			asprintf(&itemSPD, "% 3d", itemList[itemIndex]->speedDigMod);
			DrawText(b, itemSPD, listEdgeX + 6 * colWidth, listEdgeY + rowHeight * i);
			free(itemSPD);

			//Item Walk-Speed
			char *itemSPW;
			asprintf(&itemSPW, "% 2d", itemList[itemIndex]->speedWalkMod);
			DrawText(b, itemSPW, listEdgeX + 9 * colWidth, listEdgeY + rowHeight * i);
			free(itemSPW);	

			//Item Inventory size
			char *itemINV;
			asprintf(&itemINV, "% 4d", itemList[itemIndex]->inventorySizeTaken);
			DrawText(b, itemINV, listEdgeX + 11 * colWidth, listEdgeY + rowHeight * i);
			free(itemINV);		

			//Item Prize
			char *itemPRZ;
			asprintf(&itemPRZ, "% 5d", itemList[itemIndex]->prize);
			DrawText(b, itemPRZ, listEdgeX + 14 * colWidth, listEdgeY + rowHeight * i);
			free(itemPRZ);
			setFont(fontwhite8);
		}else{
			// dunno
		}
	}
	//Draw Border around current selection
	DrawRectangle(b, listEdgeX , listEdgeY + 4 * rowHeight -2, SCREEN_X - (2 * borderX + 2 * 2 * rectBorder + 2), rowHeight + 2 * 1, RGB(128, 0, 0));

	//Separate ItemList from Character Infos
	DrawHorizontalLine(b, listEdgeX , listEdgeY + 10 * rowHeight + 2 , SCREEN_X - (2 * 2 * rectBorder + 2 * borderX + 2), RGB(255,255,255));

	//Draw Player Info (Cash / Free Space)
	setFont(fontwhite16);
	char *playerCash;
	asprintf(&playerCash, "$:%3d Inv:%3d", p1.money, getFreeInvSpace(&p1));
	DrawText(b, playerCash, listEdgeX , listEdgeY + rowHeight * 11);
	free(playerCash);
	setFont(fontwhite8);	


	//Draw Players Minerals
	//Coal
	DrawRLEBitmap(b,sprt_coal,listEdgeX + 1 * colWidth,listEdgeY + rowHeight * 13);
	//Iron
	DrawRLEBitmap(b,sprt_treasure1,listEdgeX + 5 * colWidth,listEdgeY + rowHeight * 13);
	//Gold
	DrawRLEBitmap(b,sprt_gold,listEdgeX + 9 * colWidth,listEdgeY + rowHeight * 13);
	//Diamonds
	DrawRLEBitmap(b,sprt_diam_red,listEdgeX + 13 * colWidth,listEdgeY + rowHeight * 13);

	char *playerMinerals;
	asprintf(&playerMinerals, "     % 3d     % 3d     % 3d     % 3d",
		getMineralAmount(&p1, MIN_COAL),
		getMineralAmount(&p1, MIN_IRON),
		getMineralAmount(&p1, MIN_GOLD),
		getMineralAmount(&p1, MIN_DIAMOND));
	DrawText(b, playerMinerals, listEdgeX - colWidth / 2, listEdgeY + rowHeight * 13.5);
	free(playerMinerals);	


}