コード例 #1
0
ファイル: LifeUnitFmx.cpp プロジェクト: FMXExpress/Firemonkey
//---------------------------------------------------------------------------
void __fastcall TLifeForm::PaintBox1Paint(TObject *Sender, TCanvas *Canvas)
{
	PaintBox1->Canvas->BeginScene();
	PaintBox1->Canvas->Stroke->Color = TAlphaColorRec::Gray;
	if(FLifeBoard.Length > 0) {
		for(int i = 0; i < FViewSize.X; i++) {
			for(int j = 0; j < FViewSize.Y; j++) {
				if(FLifeBoard[Min(FViewOffset.X + i, FLifeBoard.High)][Min(FViewOffset.Y + j, FLifeBoard[0].High)] != 0)
				{
					PaintBox1->Canvas->Fill->Color = TAlphaColorRec::Black;
					PaintBox1->Canvas->FillRect(TRectF(i * 10, j * 10, i * 10 + 11, j * 10 + 11), 0, 0, TCorners(), 100);
				}
				else {
					PaintBox1->Canvas->Fill->Color = this->Canvas->Fill->Color;
					PaintBox1->Canvas->DrawRect(TRectF(i * 10, j * 10, i * 10 + 11, j * 10 + 11), 0, 0, TCorners(), 100);
				}
			}
		}
	}
	int Scale = 1000000;
	while(Scale > 10) {
		if((FMaxGensPerSecond * 10) < Scale) {
			Scale = Scale / 10;
		}
		else  {
			break;
		}
		int Gens = MulDiv(FGensPerSecond, PaintBox1->Height, Scale);
		int Max =  MulDiv(FMaxGensPerSecond, PaintBox1->Height, Scale);
		PaintBox1->Canvas->Fill->Color = TAlphaColorRec::Green;
		PaintBox1->Canvas->FillRect(TRectF(PaintBox1->Width - 4, PaintBox1->Height - Gens, PaintBox1->Width, PaintBox1->Height),
			0,0, TCorners(), 100);
		PaintBox1->Canvas->Stroke->Color = TAlphaColorRec::Red;
		PaintBox1->Canvas->DrawLine(TPointF(PaintBox1->Width - 4, PaintBox1->Height - Max),
			TPointF(PaintBox1->Width, PaintBox1->Height - Max), 100);
	}
	PaintBox1->Canvas->EndScene();
}
コード例 #2
0
ファイル: MainForm.cpp プロジェクト: Appmethod/AppmethodDemos
void __fastcall TTestBedForm::PaintBoxPaint(TObject *Sender, TCanvas *Canvas)
{
  Canvas->BeginScene();
  __try
  {
	Canvas->Fill->Color = b2Color2TColor(b2Color(0.3, 0.3, 0.3, 1));
	TRectF rect = PaintBox->BoundsRect;
	Canvas->FillRect(rect, 0, 0, TCorners(), DEFAULT_OPACITY);

	if (test)
	{
	  g_debugDraw.Canvas = Canvas;
	  g_debugDraw.Canvas->Fill->Color = TAlphaColorRec::Yellow;
	  test->DrawTitle(entry->name);
	  g_debugDraw.Canvas->Fill->Color = TAlphaColorRec::Aqua;
	  test->Step(&settings);
	}
  }
  __finally
  {
	Canvas->EndScene();
  }
}