Раскрасила гидроплан

This commit is contained in:
Галина Федоренко 2023-09-23 12:02:28 +04:00
parent 02c51ae801
commit 755c0d2dd2
6 changed files with 67 additions and 137 deletions

View File

@ -21,19 +21,19 @@ namespace Hydroplane
/// </summary>
private int _pictureHeight;
/// <summary>
/// Левая координата прорисовки автомобиля
/// Левая координата прорисовки гидроплана
/// </summary>
private int _startPosX;
/// <summary>
/// Верхняя кооридната прорисовки автомобиля
/// Верхняя кооридната прорисовки гидроплана
/// </summary>
private int _startPosY;
/// <summary>
/// Ширина прорисовки автомобиля
/// Ширина прорисовки гидроплана
/// </summary>
private readonly int _planeWidth = 175;
/// <summary>
/// Высота прорисовки автомобиля
/// Высота прорисовки гидроплана
/// </summary>
private readonly int _planeHeight = 100;
/// <summary>
@ -43,8 +43,8 @@ namespace Hydroplane
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Цвет кузова</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="boat">Признак наличия обвеса</param>
/// <param name="bobber">Признак наличия антикрыла</param>
/// <param name="boat">Признак наличия надувной лодки</param>
/// <param name="bobber">Признак наличия поплавков</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
/// <returns>true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах</returns>
@ -126,119 +126,35 @@ namespace Hydroplane
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new
SolidBrush(EntityHydroplane.AdditionalColor);
/*
// обвесы
if (EntityHydroplane.BodyKit)
Brush additionalBrush = new SolidBrush(EntityHydroplane.AdditionalColor);
Brush bodyBrush = new SolidBrush(EntityHydroplane.BodyColor);
//раскраска основы
g.FillPolygon(bodyBrush, new[] {
new Point(_startPosX + 5, _startPosY),
new Point(_startPosX + 5, _startPosY + 55),
new Point(_startPosX + 130, _startPosY + 55),
new Point(_startPosX + 160, _startPosY + 40),
new Point(_startPosX + 130, _startPosY + 40),
new Point(_startPosX + 130, _startPosY + 25),
new Point(_startPosX + 55, _startPosY + 25) });
//раскраска ножек
g.FillRectangle(bodyBrush, _startPosX + 65, _startPosY + 55, 5, 15);
g.FillRectangle(bodyBrush, _startPosX + 125, _startPosY + 55, 5, 15);
//раскраска иллюминаторов
g.FillEllipse(additionalBrush, _startPosX + 40, _startPosY + 30, 10, 10);
g.FillEllipse(additionalBrush, _startPosX + 60, _startPosY + 30, 10, 10);
g.FillEllipse(additionalBrush, _startPosX + 80, _startPosY + 30, 10, 10);
//раскраска окна
g.FillPolygon(additionalBrush, new[]
{
g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20);
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20,
20);
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10,
20, 40);
g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15,
15);
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45,
15, 15);
g.FillEllipse(additionalBrush, _startPosX + 90,
_startPosY, 20, 20);
g.FillEllipse(additionalBrush, _startPosX + 90,
_startPosY + 40, 20, 20);
g.FillRectangle(additionalBrush, _startPosX + 90,
_startPosY + 10, 20, 40);
g.FillRectangle(additionalBrush, _startPosX + 90,
_startPosY + 1, 15, 15);
g.FillRectangle(additionalBrush, _startPosX + 90,
_startPosY + 45, 15, 15);
g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20);
g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20);
g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20,
40);
g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14,
15);
g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45,
14, 15);
g.FillEllipse(additionalBrush, _startPosX, _startPosY,
20, 20);
g.FillEllipse(additionalBrush, _startPosX, _startPosY +
40, 20, 20);
g.FillRectangle(additionalBrush, _startPosX + 1,
_startPosY + 10, 25, 40);
g.FillRectangle(additionalBrush, _startPosX + 5,
_startPosY + 1, 15, 15);
g.FillRectangle(additionalBrush, _startPosX + 5,
_startPosY + 45, 15, 15);
g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39,
15);
g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45,
39, 15);
g.FillRectangle(additionalBrush, _startPosX + 35,
_startPosY + 1, 40, 15);
g.FillRectangle(additionalBrush, _startPosX + 35,
_startPosY + 45, 40, 15);
}
//границы автомобиля
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20);
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20);
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20);
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20);
g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30);
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10,
30);
g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52);
//задние фары
Brush brRed = new SolidBrush(Color.Red);
g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20);
g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20,
20);
//передние фары
Brush brYellow = new SolidBrush(Color.Yellow);
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20,
20);
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20,
20);
//кузов
Brush br = new SolidBrush(EntityHydroplane.BodyColor);
g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30);
g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30);
g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50);
//стекла
Brush brBlue = new SolidBrush(Color.LightBlue);
g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 10, 5,
40);
g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 10, 5,
40);
g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 8, 35,
2);
g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 51, 35,
2);
//выделяем рамкой крышу
g.DrawRectangle(pen, _startPosX + 35, _startPosY + 10, 35,
40);
g.DrawRectangle(pen, _startPosX + 75, _startPosY + 15, 25,
30);
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 15, 15,
30);
// спортивная линия
if (EntityHydroplane.SportLine)
{
g.FillRectangle(additionalBrush, _startPosX + 75,
_startPosY + 23, 25, 15);
g.FillRectangle(additionalBrush, _startPosX + 35,
_startPosY + 23, 35, 15);
g.FillRectangle(additionalBrush, _startPosX + 10,
_startPosY + 23, 20, 15);
}
// крыло
if (EntityHydroplane.Wing)
{
g.FillRectangle(additionalBrush, _startPosX, _startPosY
+ 5, 10, 50);
g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10,
50);
}
*/
new Point(_startPosX + 160, _startPosY + 40),
new Point(_startPosX + 130, _startPosY + 40),
new Point(_startPosX + 130, _startPosY + 25) });
//основа
g.DrawRectangle(pen, _startPosX + 5, _startPosY + 25, 125, 30);
@ -265,22 +181,36 @@ _startPosY + 1, 15, 15);
g.DrawLine(pen, _startPosX + 125, _startPosY + 55, _startPosX + 125, _startPosY + 70);
g.DrawLine(pen, _startPosX + 130, _startPosY + 55, _startPosX + 130, _startPosY + 70);
//лодка или колеса
if (EntityHydroplane.Boat)
//поплавки(лыжи) или колеса
if (EntityHydroplane.Bobber)
{
g.DrawRectangle(pen, _startPosX + 55, _startPosY + 70, 100, 10);
g.DrawLine(pen, _startPosX + 155, _startPosY + 70, _startPosX + 175, _startPosY + 70);
g.DrawLine(pen, _startPosX + 175, _startPosY + 70, _startPosX + 155, _startPosY + 80);
g.FillPolygon(additionalBrush, new[]
{
new Point(_startPosX + 55, _startPosY + 70),
new Point(_startPosX + 55, _startPosY + 80),
new Point(_startPosX + 155, _startPosY + 80),
new Point(_startPosX + 175, _startPosY + 70) });
g.DrawPolygon(pen, new[]
{
new Point(_startPosX + 55, _startPosY + 70),
new Point(_startPosX + 55, _startPosY + 80),
new Point(_startPosX + 155, _startPosY + 80),
new Point(_startPosX + 175, _startPosY + 70) });
}
else
{
g.FillEllipse(additionalBrush, _startPosX + 60, _startPosY + 70, 15, 15);
g.FillEllipse(additionalBrush, _startPosX + 120, _startPosY + 70, 15, 15);
g.DrawEllipse(pen, _startPosX + 60, _startPosY + 70, 15, 15);
g.DrawEllipse(pen, _startPosX + 120, _startPosY + 70, 15, 15);
}
//поплавок
if (EntityHydroplane.Bobber)
//надувная лодка
if (EntityHydroplane.Boat)
{
g.FillEllipse(additionalBrush, _startPosX, _startPosY + 21, 32, 8);
g.DrawEllipse(pen, _startPosX, _startPosY + 21, 32, 8);
}
}

View File

@ -33,18 +33,18 @@ namespace Hydroplane
/// </summary>
public bool Bobber { get; private set; }
/// <summary>
/// Шаг перемещения автомобиля
/// Шаг перемещения гидроплана
/// </summary>
public double Step => (double)Speed * 100 / Weight;
/// <summary>
/// Инициализация полей объекта-класса спортивного автомобиля
/// Инициализация полей объекта-класса гидроплана
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес автомобиля</param>
/// <param name="weight">Вес гидроплана</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="boat">Признак наличия обвеса</param>
/// <param name="bobber">Признак наличия антикрыла</param>
/// <param name="boat">Признак наличия надувной лодки</param>
/// <param name="bobber">Признак наличия поплавков</param>
public void Init(int speed, double weight, Color bodyColor, Color
additionalColor, bool boat, bool bobber)
{

View File

@ -1,6 +1,6 @@
namespace Hydroplane
{
partial class Form1
partial class FormHydroplane
{
/// <summary>
/// Required designer variable.
@ -106,7 +106,7 @@
buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += buttonMove_Click;
//
// Form1
// FormHydroplane
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
@ -117,7 +117,7 @@
Controls.Add(buttonUp);
Controls.Add(buttonCreate);
Controls.Add(pictureBoxHydroplane);
Name = "Form1";
Name = "FormHydroplane";
StartPosition = FormStartPosition.CenterScreen;
Text = "Hydroplane";
((System.ComponentModel.ISupportInitialize)pictureBoxHydroplane).EndInit();

View File

@ -1,18 +1,18 @@
namespace Hydroplane
{
public partial class Form1 : Form
public partial class FormHydroplane : Form
{
/// <summary>
/// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà
/// </summary>
private DrawningHydroplane? _drawningHydroplane;
public Form1()
public FormHydroplane()
{
InitializeComponent();
}
/// <summary>
/// Ìåòîä ïðîðèñîâêè ìàøèíû
/// Ìåòîä ïðîðèñîâêè ãèäðîïëàíà
/// </summary>
private void Draw()
{

View File

@ -11,7 +11,7 @@ namespace Hydroplane
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(new FormHydroplane());
}
}
}