sobota, 28 kwietnia 2018

Using recursion to draw (Visual C++)




pragma endregion
private: System::Void Drawing(Graphics^ temp_Graph,Pen^ temp_Pen,int x, int y, int z)
{
int step=5;
if(x>0)
{
temp_Graph->DrawLine(temp_Pen,y+x,z,y+x,z+x);
temp_Graph->DrawLine(temp_Pen,y+step,z+x,y+step,z+step);
Drawing(temp_Graph,temp_Pen,x-(2*step),y+step,z+step);
}
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
 
Graphics^ graph_Panel=panel1->CreateGraphics();
Pen^ pen_Panel1=gcnew Pen(System::Drawing::Color::Blue);
pen_Panel1->Width=3;
Pen^ pen_Panel2=gcnew Pen(System::Drawing::Color::Green);
pen_Panel2->Width=3;
Pen^ pen_Panel3=gcnew Pen(System::Drawing::Color::Violet);
pen_Panel3->Width=3;
Pen^ pen_Panel4=gcnew Pen(System::Drawing::Color::Brown);
pen_Panel4->Width=3;
int centr_X=panel1->Width/2;
int centr_Y=centr_X;
Drawing(graph_Panel,pen_Panel1,centr_X/2,centr_X/2,centr_Y);
Drawing(graph_Panel,pen_Panel2,centr_X/2,centr_X,centr_Y);
Drawing(graph_Panel,pen_Panel3,centr_X/2,centr_X,centr_Y/2);
Drawing(graph_Panel,pen_Panel4,centr_X/2,centr_X/2,centr_Y/2);
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
Close();
}
};
}


Brak komentarzy:

Prześlij komentarz