lab3 #3

Closed
asoc1al wants to merge 8 commits from lab3 into main
2 changed files with 19 additions and 11 deletions
Showing only changes of commit 992a9c2271 - Show all commits

View File

@ -81,7 +81,7 @@ namespace DumpTruck
}
public void DrawTransport(Graphics g, Color bodyColor, Color additionalColor)
public void DrawTransport(Graphics g, Color bodyColor, Color additionalColor, bool threeWheels, bool Dump)
{
if (EntityTruck == null)
{
@ -96,13 +96,16 @@ namespace DumpTruck
g.FillRectangle(brBodyRandom, _startPosX, _startPosY + 30, 100, 5);
Brush brBlack = new SolidBrush(Color.Black);
g.FillEllipse(brBlack, _startPosX, _startPosY + 35, 20, 20);
g.FillEllipse(brBlack, _startPosX + 22, _startPosY + 35, 20, 20);
if (threeWheels)
g.FillEllipse(brBlack, _startPosX + 22, _startPosY + 35, 20, 20);
g.FillEllipse(brBlack, _startPosX + 80, _startPosY + 35, 20, 20);
Brush brWhite = new SolidBrush(Color.White);
g.FillEllipse(brWhite, _startPosX + 5, _startPosY + 40, 10, 10);
g.FillEllipse(brWhite, _startPosX + 27, _startPosY + 40, 10, 10);
if (threeWheels)
g.FillEllipse(brWhite, _startPosX + 27, _startPosY + 40, 10, 10);
g.FillEllipse(brWhite, _startPosX + 85, _startPosY + 40, 10, 10);
Pen pen = new Pen(Color.Black);
@ -110,15 +113,20 @@ namespace DumpTruck
g.DrawRectangle(pen, _startPosX + 80, _startPosY, 20, 30);
g.DrawRectangle(pen, _startPosX, _startPosY + 30, 100, 5);
g.DrawEllipse(pen, _startPosX, _startPosY + 35, 20, 20);
g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20);
if (threeWheels)
g.DrawEllipse(pen, _startPosX + 22, _startPosY + 35, 20, 20);
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20);
//Brush brBody = new SolidBrush(EntityTruck?.AdditionalColor ?? Color.Red);
Brush brBodyAdditional = new SolidBrush(additionalColor);
g.FillRectangle(brBodyAdditional, _startPosX + 0, _startPosY, 70, 30);
Pen pen1 = new Pen(Color.Black);
g.DrawRectangle(pen1, _startPosX + 0, _startPosY, 70, 30);
if (Dump)
{
Brush brBodyAdditional = new SolidBrush(additionalColor);
g.FillRectangle(brBodyAdditional, _startPosX + 0, _startPosY, 70, 30);
Pen pen1 = new Pen(Color.Black);
g.DrawRectangle(pen1, _startPosX + 0, _startPosY, 70, 30);
}
}

View File

@ -27,7 +27,7 @@ namespace DumpTruck
Bitmap bmp = new(pictureBoxTruck.Width,
pictureBoxTruck.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningTruck.DrawTransport(gr, Color.FromArgb(0,255,128),Color.FromArgb(255,0,0));
_drawningTruck.DrawTransport(gr, Color.FromArgb(0,255,128),Color.FromArgb(255,0,0), false, true);
pictureBoxTruck.Image = bmp;
}
@ -40,7 +40,7 @@ namespace DumpTruck
{
Random random = new();
_drawningTruck = new DrawingTruck();
_drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256)), Color.FromArgb(random.Next(0,256)), pictureBoxTruck.Width, pictureBoxTruck.Height);
_drawningTruck.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256)), Color.FromArgb(random.Next(0,256)), pictureBoxTruck.Width, pictureBoxTruck.Height, Convert.ToBoolean(random.Next(2)), Convert.ToBoolean(random.Next(2)));
_drawningTruck.SetPosition(random.Next(1, 100), random.Next(1, 100));
Draw();
}