interface у Turtle.pas

Команда изменения цвета и ширины
This commit is contained in:
Mikhalkovich Stanislav 2025-08-04 12:51:30 +03:00
parent 59ed71f459
commit bf3ba7d288
6 changed files with 81 additions and 12 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3"; public const string Major = "3";
public const string Minor = "11"; public const string Minor = "11";
public const string Build = "0"; public const string Build = "0";
public const string Revision = "3647"; public const string Revision = "3649";
public const string MainVersion = Major + "." + Minor; public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=11 %MINOR%=11
%REVISION%=3647 %REVISION%=3649
%COREVERSION%=0 %COREVERSION%=0
%MAJOR%=3 %MAJOR%=3

View file

@ -1 +1 @@
3.11.0.3647 3.11.0.3649

View file

@ -1 +1 @@
!define VERSION '3.11.0.3647' !define VERSION '3.11.0.3649'

View file

@ -35,8 +35,10 @@ begin
Result := Self; Result := Self;
end; end;
const InitialPenWidth = 1.4;
var var
CurrentPen := ColorPen(Colors.Black,1.4); // Для LineTo CurrentPen := ColorPen(Colors.Black,InitialPenWidth); // Для LineTo
CurrentFontFace := new Typeface('Arial'); CurrentFontFace := new Typeface('Arial');

View file

@ -1,10 +1,10 @@
/// Исполнитель Черепаха /// Исполнитель Черепаха
unit Turtle; unit Turtle;
interface
uses GraphWPFBase; uses GraphWPFBase;
uses GraphWPF; uses GraphWPF;
uses System.Threading.Tasks;
uses Coords;
type type
Colors = GraphWPF.Colors; Colors = GraphWPF.Colors;
@ -14,6 +14,70 @@ var
tp: Point; // текущая точка Черепахи (экранная, но сделаем её логической) tp: Point; // текущая точка Черепахи (экранная, но сделаем её логической)
angle: real; // Угол поворота Черепахи angle: real; // Угол поворота Черепахи
dr := False; // Опущен хвост Черепахи или нет dr := False; // Опущен хвост Черепахи или нет
function Window: WindowTypeWPF;
/// Продвигает Черепаху вперед на расстояние r
procedure Forw(r: real);
/// Продвигает Черепаху назад на расстояние r
procedure Back(r: real);
/// Поворачивает Черепаху на угол da по часовой стрелке
procedure Turn(da: real);
/// Поворачивает Черепаху на угол da по часовой стрелке
procedure TurnRight(da: real);
/// Поворачивает Черепаху на угол da против часовой стрелки
procedure TurnLeft(da: real);
/// Опускает хвост Черепахи
procedure Down;
/// Поднимает хвост Черепахи
procedure Up;
/// Перемещает Черепаху в точку (x,y)
procedure ToPoint(x,y: real);
/// Рисует окружность указанного радиуса
procedure Circle(r: real);
/// Рисует окружность указанного радиуса и цвета
procedure Circle(r: real; color: GColor);
/// Рисует точку заданным цветом заданного размера
procedure DrawPoint(x,y: real; color: GColor := Colors.Black; PointRadius: real := 2);
/// Рисует точки заданным цветом заданного размера
procedure DrawPoints(points: array of Point; color: GColor; PointRadius: real := -1);
/// Рисует точки следующим цветом в палитре цветов
procedure DrawPoints(points: array of Point; PointRadius: real := -1);
/// Рисует точки заданным цветом
procedure DrawPoints(xx,yy: array of real; color: GColor; PointRadius: real := -1);
/// Рисует точки следующим цветом в палитре цветов
procedure DrawPoints(xx,yy: array of real; PointRadius: real := -1);
/// Устанавливает ширину линии Черепахи
procedure SetWidth(w: real);
/// Устанавливает цвет линии Черепахи
procedure SetColor(c: GColor);
/// Устанавливает положение начала координат
procedure SetOrigin(x,y: real);
{$endregion}
implementation
uses System.Threading.Tasks;
uses Coords;
procedure MoveToReal(x,y: real); procedure MoveToReal(x,y: real);
begin begin
@ -239,23 +303,24 @@ begin
end; end;
/// Рисует точку заданным цветом /// Рисует точку заданным цветом
procedure DrawPoint(x,y: real; color: GColor := Colors.Black; PointRadius: real := 2) := Coords.DrawPoint(x,y,color,PointRadius); procedure DrawPoint(x,y: real; color: GColor; PointRadius: real) := Coords.DrawPoint(x,y,color,PointRadius);
/// Рисует точки заданным цветом /// Рисует точки заданным цветом
procedure DrawPoints(points: array of Point; color: GColor; PointRadius: real := -1) := Coords.DrawPoints(points,color,PointRadius); procedure DrawPoints(points: array of Point; color: GColor; PointRadius: real) := Coords.DrawPoints(points,color,PointRadius);
/// Рисует точки следующим цветом в палитре цветов /// Рисует точки следующим цветом в палитре цветов
procedure DrawPoints(points: array of Point; PointRadius: real := -1) := Coords.DrawPoints(points,PointRadius); procedure DrawPoints(points: array of Point; PointRadius: real) := Coords.DrawPoints(points,PointRadius);
/// Рисует точки заданным цветом /// Рисует точки заданным цветом
procedure DrawPoints(xx,yy: array of real; color: GColor; PointRadius: real := -1) := Coords.DrawPoints(xx,yy,color,PointRadius); procedure DrawPoints(xx,yy: array of real; color: GColor; PointRadius: real) := Coords.DrawPoints(xx,yy,color,PointRadius);
/// Рисует точки следующим цветом в палитре цветов /// Рисует точки следующим цветом в палитре цветов
procedure DrawPoints(xx,yy: array of real; PointRadius: real := -1) := Coords.DrawPoints(xx,yy,PointRadius); procedure DrawPoints(xx,yy: array of real; PointRadius: real) := Coords.DrawPoints(xx,yy,PointRadius);
/// Устанавливает ширину линии Черепахи /// Устанавливает ширину линии Черепахи
procedure SetWidth(w: real); procedure SetWidth(w: real);
begin begin
AddCommand(new SetWidthC(w));
CurrentPen := ColorPen(Pen.Color,w); CurrentPen := ColorPen(Pen.Color,w);
Pen.Width := w; Pen.Width := w;
end; end;
@ -263,6 +328,7 @@ end;
/// Устанавливает цвет линии Черепахи /// Устанавливает цвет линии Черепахи
procedure SetColor(c: GColor); procedure SetColor(c: GColor);
begin begin
AddCommand(new SetColorC(c));
CurrentPen := ColorPen(c,Pen.Width); CurrentPen := ColorPen(c,Pen.Width);
Pen.Color := c; Pen.Color := c;
end; end;
@ -282,6 +348,7 @@ begin
tp := (0,0); tp := (0,0);
angle := 90; angle := 90;
MoveToReal(tp.X,tp.Y); MoveToReal(tp.X,tp.Y);
CurrentPen := ColorPen(Colors.Black,InitialPenWidth);
dr := False; dr := False;
end; end;