Testowałem funkcje graficzne w Visual C++ 2008 i przy okazji w pamięci dokonałem przekształceń symetrycznych linii i figur. Rezultatem działania jest taka kolorystyczna kompozycja kalejdoskopowa:
Jeśli się komuś przyda to kod do takiej zabawy:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Graphics^ graf=panel1->CreateGraphics();
SolidBrush^ pedzel1=gcnew SolidBrush(System::Drawing::Color::DarkViolet);
SolidBrush^ pedzel2=gcnew SolidBrush(System::Drawing::Color::Orange);
SolidBrush^ pedzel3=gcnew SolidBrush(System::Drawing::Color::DarkBlue);
SolidBrush^ pedzel4=gcnew SolidBrush(System::Drawing::Color::SkyBlue);
SolidBrush^ pedzel5=gcnew SolidBrush(System::Drawing::Color::Chocolate);
Pen^ pen1=gcnew Pen(System::Drawing::Color::Green);
Pen^ pen2=gcnew Pen(System::Drawing::Color::Red);
Pen^ pen3=gcnew Pen(System::Drawing::Color::Blue);
Pen^ pen4=gcnew Pen(System::Drawing::Color::Brown);
Pen^ pen5=gcnew Pen(System::Drawing::Color::Black);
Pen^ pen6=gcnew Pen(System::Drawing::Color::DarkKhaki);
Pen^ pen7=gcnew Pen(System::Drawing::Color::Chartreuse);
System::Drawing::Font^ font1=gcnew
System::Drawing::Font(System::Drawing::FontFamily::GenericSansSerif,10,FontStyle::Underline);
int srodek_x,srodek_y,dl_x,dl_y,margines;
srodek_x=panel1->Width/2;
srodek_y=panel1->Height/2;
dl_x=panel1->Width;
dl_y=panel1->Height;
margines=5;
pen1->StartCap=System::Drawing::Drawing2D::LineCap::RoundAnchor;
pen1->EndCap=System::Drawing::Drawing2D::LineCap::ArrowAnchor;
pen1->Width=5;
graf->DrawLine(pen1,margines,dl_y-margines,dl_x-margines,margines);
graf->DrawLine(pen1,dl_x-margines,dl_y-margines,margines,margines);
pen2->DashStyle=System::Drawing::Drawing2D::DashStyle::Dot;
pen2->Width=3;
graf->DrawLine(pen2,margines,srodek_y,dl_x-margines,srodek_y);
graf->DrawLine(pen2,srodek_x,margines,srodek_x,dl_y-margines);
pen3->Width=4;
graf->DrawRectangle(pen3,srodek_x-150,srodek_y-150,300,300);
pen4->Width=4;
graf->DrawEllipse(pen4,srodek_x-100,srodek_y-100,200,200);
pen5->Width=4;
graf->DrawEllipse(pen5,srodek_x-200,srodek_y-200,100,100);
graf->DrawEllipse(pen5,srodek_x+100,srodek_y-200,100,100);
graf->DrawEllipse(pen5,srodek_x-200,srodek_y+100,100,100);
graf->DrawEllipse(pen5,srodek_x+100,srodek_y+100,100,100);
pen6->Width=4;
pen6->DashStyle=System::Drawing::Drawing2D::DashStyle::Dash;
pen6->DashCap=System::Drawing::Drawing2D::DashCap::Triangle;
graf->DrawLine(pen6,margines,srodek_y,srodek_x,margines);
graf->DrawLine(pen6,srodek_x,margines,dl_x-margines,srodek_y);
graf->DrawLine(pen6,dl_x-margines,srodek_y,srodek_x,dl_y-margines);
graf->DrawLine(pen6,srodek_x,dl_y-margines,margines,srodek_y);
pen7->Width=3;
graf->DrawRectangle(pen7,srodek_x-40,srodek_y-40,80,80);
graf->FillRectangle(pedzel1,margines+20,margines+20,75,75);
graf->FillRectangle(pedzel1,dl_x-(margines+20+75),margines+20,75,75);
graf->FillRectangle(pedzel1,margines+20,dl_y-(margines+20+75),75,75);
graf->FillRectangle(pedzel1,dl_x-(margines+20+75),dl_y-(margines+20+75),75,75);
graf->FillRectangle(pedzel2,srodek_x-(150+25),srodek_y-25,50,50);
graf->FillRectangle(pedzel2,srodek_x+(150-25),srodek_y-25,50,50);
graf->FillRectangle(pedzel2,srodek_x-25,srodek_y-(150+25),50,50);
graf->FillRectangle(pedzel2,srodek_x-25,srodek_y+(150-25),50,50);
graf->FillEllipse(pedzel3,srodek_x-25,srodek_y-25,50,50);
graf->FillEllipse(pedzel4,srodek_x-15,margines+55,30,30);
graf->FillEllipse(pedzel4,srodek_x-15,dl_y-(margines+85),30,30);
graf->FillEllipse(pedzel4,margines+55,srodek_y-15,30,30);
graf->FillEllipse(pedzel4,dl_x-(margines+85),srodek_y-15,30,30);
graf->DrawString("Graph of Functions in Visual C++",font1,pedzel5,srodek_x+15,margines);
}