diff --git a/CodeExamples/Patterns/patterns-collection-matching1.pas b/CodeExamples/Patterns/patterns-collection-matching1.pas index f4f644c05..fb853ff88 100644 --- a/CodeExamples/Patterns/patterns-collection-matching1.pas +++ b/CodeExamples/Patterns/patterns-collection-matching1.pas @@ -36,8 +36,8 @@ begin // match .. with match a with - [1, 9, 8, _, 2]: print(1); - [.., var y, var x]: print(x + y); - [_, .., _]: print(3); + [1, 9, 8, _, 2]: Print(1); + [.., var y, var x]: Print(x + y); + [_, .., _]: Print(3); end; end. \ No newline at end of file diff --git a/CodeExamples/Patterns/patterns-collection-matching2.pas b/CodeExamples/Patterns/patterns-collection-matching2.pas index 8d4ce8724..ddbf84317 100644 --- a/CodeExamples/Patterns/patterns-collection-matching2.pas +++ b/CodeExamples/Patterns/patterns-collection-matching2.pas @@ -39,8 +39,8 @@ begin // match .. with match personArr with - [_, _, Person('Вася', age, _)]: print(age); - [var p, .., Person('Маша', _, _)]: print((p as Person).name); - [..]: print(1); + [_, _, Person('Вася', age, _)]: Print(age); + [var p, .., Person('Маша', _, _)]: Print((p as Person).name); + [..]: Print(1); end; end. \ No newline at end of file diff --git a/InstallerSamples/Games/Battle.pas b/InstallerSamples/Games/Battle.pas index 8e7c03bc5..27d6fc83c 100644 --- a/InstallerSamples/Games/Battle.pas +++ b/InstallerSamples/Games/Battle.pas @@ -1,4 +1,4 @@ -uses GraphABC; +uses GraphABC; const types = 3; //число типов рыб минус 1 rmax = 4; //радиус всех рыб diff --git a/InstallerSamples/Games/BookWorm/BookWormABCNET.pas b/InstallerSamples/Games/BookWorm/BookWormABCNET.pas index df73f6178..287a36821 100644 --- a/InstallerSamples/Games/BookWorm/BookWormABCNET.pas +++ b/InstallerSamples/Games/BookWorm/BookWormABCNET.pas @@ -1,4 +1,4 @@ -uses GraphABC,ABCObjects,ABCButtons,Events; +uses GraphABC,ABCObjects,ABCButtons; const /// Примерная частота повторяемости букв diff --git a/InstallerSamples/Games/KillThem.pas b/InstallerSamples/Games/KillThem.pas index 0ed3a4842..29ce53a0f 100644 --- a/InstallerSamples/Games/KillThem.pas +++ b/InstallerSamples/Games/KillThem.pas @@ -1,4 +1,4 @@ -uses ABCObjects,GraphABC,Timers; +uses ABCObjects,GraphABC,Timers; const clPlayer = Color.BurlyWood; diff --git a/InstallerSamples/Graphics/ABCObjects/gr_All_Brown.pas b/InstallerSamples/Graphics/ABCObjects/gr_All_Brown.pas index fe170930f..383cc3d79 100644 --- a/InstallerSamples/Graphics/ABCObjects/gr_All_Brown.pas +++ b/InstallerSamples/Graphics/ABCObjects/gr_All_Brown.pas @@ -1,4 +1,4 @@ -// Изменение свойств графических объектов +// Изменение свойств графических объектов // Броуновское движение графических объектов uses ABCObjects,GraphABC; diff --git a/InstallerSamples/Graphics/ABCObjects/gr_Move_Param.pas b/InstallerSamples/Graphics/ABCObjects/gr_Move_Param.pas index 1b2c1f8c4..8364f08c8 100644 --- a/InstallerSamples/Graphics/ABCObjects/gr_Move_Param.pas +++ b/InstallerSamples/Graphics/ABCObjects/gr_Move_Param.pas @@ -1,4 +1,4 @@ -// Движение по траектории +// Движение по траектории uses ABCObjects,GraphABC; const diff --git a/InstallerSamples/Graphics/WPFObjects/gr_All_Brown_WPF.pas b/InstallerSamples/Graphics/WPFObjects/gr_All_Brown_WPF.pas index f75eedf02..d29409dc4 100644 --- a/InstallerSamples/Graphics/WPFObjects/gr_All_Brown_WPF.pas +++ b/InstallerSamples/Graphics/WPFObjects/gr_All_Brown_WPF.pas @@ -1,6 +1,6 @@ // Изменение свойств графических объектов // Броуновское движение графических объектов -uses WPFObjects,GraphWPF; +uses WPFObjects; procedure MoveAll(a,b: integer); begin @@ -9,25 +9,23 @@ begin end; begin -// LockDrawingObjects; Window.Title := 'Броуновское движение объектов'; - var sq := new SquareWPF(30,5,90,Colors.SkyBlue); sq.WithBorder; - var r := new RectangleWPF(10,10,100,180,RGB(255,100,100)); r.WithBorder; - var rr := new RoundRectWPF(200,180,180,50,20,RandomColor); rr.WithBorder; - var rsq:= new RoundSquareWPF(20,180,80,10,RandomColor); rsq.WithBorder; + var sq := new SquareWPF(30,5,90,Colors.SkyBlue,1); + var r := new RectangleWPF(10,10,100,180,RGB(255,100,100),1); + var rr := new RoundRectWPF(200,180,180,50,20,RandomColor,1); + var rsq:= new RoundSquareWPF(20,180,80,10,RandomColor,1); var c := new CircleWPF(160,55,70,Colors.Green); - var z := new StarWPF(200,150,70,135,5,EmptyColor); z.WithBorder; //z.Filled := False; - var el := new EllipseWPF(5,55,65,50,RandomColor); //el.Bordered := False; - var t := new TextWPF(100,170,'Hello, WPFObjects!'); // - t.BackgroundColor := Colors.Yellow; - //var br := new BoardWPF(200,20,7,5,20,20); - //br.Filled := False; - z.Height := 200; - //z.Radius := 70; - sq.Width := 120; + var z := new StarWPF(200,150,70,135,5,EmptyColor,1); + var el := new EllipseWPF(5,55,65,50,RandomColor,2,RandomColor); + var t := new TextWPF(100,170,40,'Hello, WPFObjects!'); // t.BackgroundColor := Colors.Yellow; t.FontName := 'Times New Roman'; - t.FontSize := 40; + //var br := new BoardWPF(200,20,7,5,20,20); + //br.Filled := False; + z.Height := 220; + z.Radius := 160; + sq.Width := 120; + //t.FontSize := 40; c.Height := 50; c.Scale(2); MoveAll(160,110); @@ -35,7 +33,7 @@ begin while True do begin for var j:=0 to Objects.Count-1 do - Objects[j].moveOn(Random(-1,1),Random(-1,1)); + Objects[j].MoveOn(Random(-1,1),Random(-1,1)); Sleep(10); end; end. diff --git a/InstallerSamples/Graphics/WPFObjects/gr_IntersectWPF.pas b/InstallerSamples/Graphics/WPFObjects/gr_IntersectWPF.pas index bda221465..d6d5134dc 100644 --- a/InstallerSamples/Graphics/WPFObjects/gr_IntersectWPF.pas +++ b/InstallerSamples/Graphics/WPFObjects/gr_IntersectWPF.pas @@ -10,13 +10,12 @@ end; begin Window.SetSize(640,480); Window.Title := 'Разрушитель: метод Intersect пересечения объектов'; - for var i:=1 to 500 do + loop 500 do new RectangleWPF(Random(Window.Width.Round-200)+100,Random(Window.Height.Round-100),Random(200),Random(200),clRandom); - Destroyer := new CircleWPF(10,Window.Height.Round div 2,100,Colors.Black); - Destroyer.FontColor := Colors.Yellow; - Destroyer.Text := 'Destroyer'; + Destroyer := new CircleWPF(10,Window.Height / 2,100,Colors.Black); + Destroyer.SetText('Destroyer',30,'Arial',Colors.Yellow); - for var i:=1 to 900 do + loop 900 do begin Destroyer.MoveOn(1,0); CheckPulyaIntersects; diff --git a/InstallerSamples/Graphics/WPFObjects/gr_Move_Param_WPF.pas b/InstallerSamples/Graphics/WPFObjects/gr_Move_Param_WPF.pas new file mode 100644 index 000000000..bae294ea3 --- /dev/null +++ b/InstallerSamples/Graphics/WPFObjects/gr_Move_Param_WPF.pas @@ -0,0 +1,70 @@ +// Движение по траектории +uses WPFObjects,GraphWPF; + +const +/// Шаг по параметру кривой + step = 0.02; +/// Задержка по времени, мс + delay = 5; + +type + PointR = record + x,y: real; + end; + +function Position(t: real): PointR; // астроида +begin + var si := sin(1.7 * t); + var co := cos(1.5 * t); + Result.x := si*si*si; + Result.y := co*co*co; +end; + +function Position1(t: real): PointR; // фигура Лиссажу +begin + Result.x := cos(4*t); + Result.y := cos(2.97221*t + 2*Pi/3); +end; + +function LogicalToScreen(p: PointR): GPoint; +begin + var ww := Window.Width / 2; + var hh := Window.Height / 2; + Result.x := Round((ww - 50) * p.x + ww); + Result.y := Round((hh - 50) * p.y + hh); +end; + +procedure InitScreen; +begin + Brush.Color := Colors.LightGreen; + Rectangle(10,10,Window.Width-20,Window.Height-20); + var p := LogicalToScreen(Position1(0)); + MoveTo(p.x,p.y); +end; + +begin + //Window.IsFixedSize := True; + Window.Title := 'Движение по траектории'; + Window.SetSize(640,480); + Window.CenterOnScreen; + + InitScreen; + var c := new CircleWPF(200,200,25,Colors.Green); + var d := new StarWPF(200,200,40,20,5,Colors.Yellow); + + var t: real := 0; + while True do + begin + c.Center := LogicalToScreen(Position1(t)); + d.Center := LogicalToScreen(Position(t)); + if t<20*Pi then + LineTo(c.Center.x,c.Center.y) + else + begin + t := 0; + InitScreen; + end; + t += step; + Sleep(delay); + end; +end. diff --git a/InstallerSamples/Graphics/WPFObjects/gr_MovingObjectsWPF.pas b/InstallerSamples/Graphics/WPFObjects/gr_MovingObjectsWPF.pas index 163999bc7..90ea8a77b 100644 --- a/InstallerSamples/Graphics/WPFObjects/gr_MovingObjectsWPF.pas +++ b/InstallerSamples/Graphics/WPFObjects/gr_MovingObjectsWPF.pas @@ -29,7 +29,7 @@ end; procedure CreateAll; begin - for var i:=1 to Count do + loop Count do begin var m: ObjectWPF := NewRandomABC; repeat @@ -47,11 +47,11 @@ end; begin Window.Title := 'Движущиеся объекты'; - Invoke(CreateAll); + Redraw(CreateAll); var k := 1; while True do begin - Invoke(MoveAll); + Redraw(MoveAll); k += 1; Window.Title := Format('{0,5:f2}',k/Milliseconds*1000)+' кадров в секунду'; end; diff --git a/InstallerSamples/Graphics/WPFObjects/gr_ObjectsAsSeq.pas b/InstallerSamples/Graphics/WPFObjects/gr_ObjectsAsSeq.pas index 2847d2b2f..63a34434f 100644 --- a/InstallerSamples/Graphics/WPFObjects/gr_ObjectsAsSeq.pas +++ b/InstallerSamples/Graphics/WPFObjects/gr_ObjectsAsSeq.pas @@ -20,6 +20,6 @@ begin match o with CircleWPF(c): c.Radius += 10; EllipseWPF(e): e.AnimMoveOn(Random(-50,50),Random(-50,50),1); - RegularPolygonWPF(r) when r.Count<6: r.WithBorder; + RegularPolygonWPF(r) when r.Count<6: r.SetBorder; end end. \ No newline at end of file diff --git a/InstallerSamples/Graphics/WPFObjects/gr_RealNumber_WPF.pas b/InstallerSamples/Graphics/WPFObjects/gr_RealNumber_WPF.pas new file mode 100644 index 000000000..7f0f50755 --- /dev/null +++ b/InstallerSamples/Graphics/WPFObjects/gr_RealNumber_WPF.pas @@ -0,0 +1,20 @@ +uses WPFObjects, GraphWPF; + +const + /// отступ по оси x + zx = 100; + /// отступ по оси y + zy = 50; + +begin + //Window.IsFixedSize := True; + Window.Title := 'Секундомер'; + var r := new RoundRectWPF(zx, zy, Window.Width - 2 * zx, Window.Height - 2 * zy, 100, Colors.LightGreen, 5, Colors.Green); + r.FontSize := 200; + for var i := 1 to 1000 do + begin + r.RealNumber := i/10; + Sleep(100); + end; +end. + diff --git a/InstallerSamples/Graphics/WPFObjects/gr_Star_Rotate1_WPF.pas b/InstallerSamples/Graphics/WPFObjects/gr_Star_Rotate1_WPF.pas new file mode 100644 index 000000000..6fcb8e8f0 --- /dev/null +++ b/InstallerSamples/Graphics/WPFObjects/gr_Star_Rotate1_WPF.pas @@ -0,0 +1,12 @@ +// Изменение свойств объекта StarWPF +uses WPFObjects; + +begin + var z := new StarWPF(Window.Width / 2, Window.Height / 2, Window.Height / 2 - 5, Window.Height / 4 + 16, 6, Colors.Red); + loop 20 do + begin + Sleep(100); + z.Count += 1; + end; + z.AnimRotate(200,2); +end. diff --git a/InstallerSamples/Graphics/WPFObjects/gr_Star_Rotate_WPF.pas b/InstallerSamples/Graphics/WPFObjects/gr_Star_Rotate_WPF.pas new file mode 100644 index 000000000..a871cf690 --- /dev/null +++ b/InstallerSamples/Graphics/WPFObjects/gr_Star_Rotate_WPF.pas @@ -0,0 +1,16 @@ +// Изменение свойств объекта StarWPF +uses WPFObjects, GraphWPF; + +begin + var z := new StarWPF(Window.Width / 2, Window.Height / 2, Window.Height / 2 - 5, Window.Height / 4 + 16, 6, Colors.Red); + loop 20 do + begin + Sleep(100); + z.Count += 1; + end; + loop 200 do + begin + Sleep(10); + z.Rotate(1); + end; +end. diff --git a/bin/Lib/GraphWPF.pas b/bin/Lib/GraphWPF.pas index af588892c..5d9e44d63 100644 --- a/bin/Lib/GraphWPF.pas +++ b/bin/Lib/GraphWPF.pas @@ -344,7 +344,7 @@ function ColorBrush(c: Color): GBrush; /// Возвращает однотонное цветное перо, заданное цветом function ColorPen(c: Color): GPen; /// Процедура синхронизации вывода графики -procedure Invoke(d: ()->()); +procedure Redraw(d: ()->()); // ----------------------------------------------------- @@ -503,7 +503,7 @@ procedure __FinalizeModule__; implementation -procedure Invoke(d: ()->()) := app.Dispatcher.Invoke(d); +procedure Redraw(d: ()->()) := app.Dispatcher.Invoke(d); function getApp: Application := app; function RGB(r,g,b: byte) := Color.Fromrgb(r, g, b); diff --git a/bin/Lib/WPFObjects.pas b/bin/Lib/WPFObjects.pas index 90b51ba02..4c705f6f0 100644 --- a/bin/Lib/WPFObjects.pas +++ b/bin/Lib/WPFObjects.pas @@ -80,7 +80,7 @@ function Rect(x,y,w,h: real): GRect; function ColorBrush(c: Color): GBrush; //{{{--doc: Конец секции 1 }}} -procedure Invoke(p: ()->()); +procedure Redraw(p: ()->()); //{{{doc: Начало секции 2 }}} type @@ -185,6 +185,8 @@ type property Text: string read InvokeString(()->t.Text) write Invoke(procedure->t.Text := value); virtual; /// Целое число, выводимое в центре графического объекта. Используется свойство Text property Number: integer read Text.ToInteger(0) write Text := Value.ToString; + /// Вещественное число, выводимое в центре графического объекта. Используется свойство Text + property RealNumber: real read Text.ToReal(0.0) write Text := string.Format('{0:f1}',Value).Replace(',','.'); private procedure WTA(value: Alignment); begin @@ -268,7 +270,8 @@ type procedure Rotate(a: real) := RotateAngle += a; /// Масштабирует графический объект в r раз относительно текущего размера procedure Scale(r: real) := ScaleFactor *= r; - + + private procedure AnimMoveOnP(a,b,sec: real); begin var ax := new DoubleAnimation(a + transl.X, System.TimeSpan.FromSeconds(sec)); @@ -276,9 +279,10 @@ type transl.BeginAnimation(TranslateTransform.XProperty, ax, HandoffBehavior.Compose); transl.BeginAnimation(TranslateTransform.YProperty, ay, HandoffBehavior.Compose); end; + public /// Анимирует перемещение графического объекта на вектор (a,b) в течение sec секунд procedure AnimMoveOn(a,b: real; sec: real := 1) := Invoke(AnimMoveOnP,a,b,sec); - + private procedure AnimMoveToP(x,y,sec: real); begin var ax := new DoubleAnimation(x, System.TimeSpan.FromSeconds(sec)); @@ -286,9 +290,10 @@ type transl.BeginAnimation(TranslateTransform.XProperty, ax, HandoffBehavior.Compose); transl.BeginAnimation(TranslateTransform.YProperty, ay, HandoffBehavior.Compose); end; + public /// Анимирует перемещение графического объекта к точке (x,y) в течение sec секунд procedure AnimMoveTo(x,y: real; sec: real := 1) := Invoke(AnimMoveToP,x,y,sec); - + private procedure AnimMoveEndP; begin var animation := new DoubleAnimation(); @@ -296,23 +301,26 @@ type transl.BeginAnimation(TranslateTransform.XProperty, animation); transl.BeginAnimation(TranslateTransform.YProperty, animation); end; + public /// Завершает анимацию перемещения procedure AnimMoveEnd := Invoke(AnimMoveEndP); - + private procedure AnimRotateP(a,sec: real); begin var an := new DoubleAnimation(a, System.TimeSpan.FromSeconds(sec)); rot.BeginAnimation(RotateTransform.AngleProperty, an, HandoffBehavior.Compose); end; + public /// Анимирует вращение графического объекта на угол a в течение sec секунд procedure AnimRotate(a: real; sec: real := 1) := Invoke(AnimRotateP,a,sec); - + private procedure AnimScaleP(a,sec: real); begin var an := new DoubleAnimation(a, System.TimeSpan.FromSeconds(sec)); sca.BeginAnimation(ScaleTransform.ScaleXProperty, an, HandoffBehavior.Compose); sca.BeginAnimation(ScaleTransform.ScaleYProperty, an, HandoffBehavior.Compose); end; + public /// Анимирует масштабирование графического объекта на величину a в течение sec секунд procedure AnimScale(a: real; sec: real := 1) := Invoke(AnimScaleP,a,sec); @@ -334,7 +342,7 @@ type /// Определяет, пересекается ли объект с объектом ob function Intersects(ob: ObjectWPF): boolean; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): ObjectWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): ObjectWPF; begin Text := txt; FontSize := size; @@ -343,7 +351,7 @@ type Result := Self; end; /// Декоратор поворота объекта - function WithRotate(da: real): ObjectWPF; + function SetRotate(da: real): ObjectWPF; begin Rotate(da); Result := Self; @@ -371,7 +379,7 @@ type if Element.Stroke = nil then Element.Stroke := new SolidColorBrush(Colors.Black) end; - function WithNoBorderP: BoundedObjectWPF; + function RemoveBorderP: BoundedObjectWPF; begin Element.Stroke := nil; Result := Self; @@ -393,16 +401,17 @@ type read InvokeReal(()->Element.StrokeThickness) write Invoke(EST,value); /// Декоратор включения границы объекта - function WithBorder(w: real := -1): BoundedObjectWPF; + function SetBorder(w: real := 1; c: GColor := Colors.Black): BoundedObjectWPF; begin - BorderColor := BorderColor; - if (w>=0) then - BorderWidth := w; + //if c<>BorderColor then + BorderColor := c; + //if w<>BorderWidth then + BorderWidth := w; Result := Self; end; /// Декоратор выключения границы объекта - function WithNoBorder: BoundedObjectWPF - := Invoke&(WithNoBorderP); + function RemoveBorder: BoundedObjectWPF + := Invoke&(RemoveBorderP); end; // ----------------------------------------------------- @@ -416,18 +425,22 @@ type public /// Создает эллипс размера (w,h) заданного цвета с координатами левого верхнего угла (x,y) constructor (x,y,w,h: real; c: GColor) := Invoke(InitOb2,x,y,w,h,c); - /// Создает эллипс размера (w,h) заданного цвета с координатами левого верхнего угла, задаваемыми точкой + /// Создает эллипс размера (w,h) заданного цвета с координатами левого верхнего угла (x,y), с границей ширины borderWidth и цвета borderColor + constructor (x,y,w,h: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,x,y,w,h,c); SetBorder(borderWidth,borderColor); end; + /// Создает эллипс размера (w,h) заданного цвета с координатами левого верхнего угла, задаваемыми точкой p constructor (p: Point; w,h: real; c: GColor) := Invoke(InitOb2,p.x,p.y,w,h,c); + /// Создает эллипс размера (w,h) заданного цвета с координатами левого верхнего угла, задаваемыми точкой p, с границей ширины borderWidth и цвета borderColor + constructor (p: Point; w,h: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,p.x,p.y,w,h,c); SetBorder(borderWidth,borderColor); end; /// Декоратор включения границы объекта - function WithBorder(w: real := -1) := inherited WithBorder(w) as EllipseWPF; + function SetBorder(w: real := 1; c: GColor := Colors.Black) := inherited SetBorder(w,c) as EllipseWPF; /// Декоратор выключения границы объекта - function WithNoBorder := inherited WithNoBorder as EllipseWPF; + function RemoveBorder := inherited RemoveBorder as EllipseWPF; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): EllipseWPF - := inherited WithText(txt,size,fontname,c) as EllipseWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): EllipseWPF + := inherited SetText(txt,size,fontname,c) as EllipseWPF; /// Декоратор поворота объекта - function WithRotate(da: real): EllipseWPF - := inherited WithRotate(da) as EllipseWPF; + function SetRotate(da: real): EllipseWPF + := inherited SetRotate(da) as EllipseWPF; end; // ----------------------------------------------------- @@ -463,6 +476,10 @@ type constructor (x,y,r: real; c: GColor) := Invoke(InitOb2,x,y,r,c); /// Создает круг радиуса r заданного цвета с центром p constructor (p: Point; r: real; c: GColor) := Invoke(InitOb2,p.x,p.y,r,c); + /// Создает круг радиуса r заданного цвета с координатами центра (x,y), с границей ширины borderWidth и цвета borderColor + constructor (x,y,r: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,x,y,r,c); SetBorder(borderWidth,borderColor); end; + /// Создает круг радиуса r заданного цвета с центром p, с границей ширины borderWidth и цвета borderColor + constructor (p: Point; r: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,p.x,p.y,r,c); SetBorder(borderWidth,borderColor); end; /// Ширина круга property Width: real read InvokeReal(()->ob.Width) @@ -476,14 +493,14 @@ type read InvokeReal(()->ob.Height/2) write Invoke(Rad,Value); /// Декоратор включения границы объекта - function WithBorder(w: real := -1) := inherited WithBorder(w) as CircleWPF; + function SetBorder(w: real := 1; c: GColor := Colors.Black) := inherited SetBorder(w,c) as CircleWPF; /// Декоратор выключения границы объекта - function WithNoBorder := inherited WithNoBorder as CircleWPF; + function RemoveBorder := inherited RemoveBorder as CircleWPF; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): CircleWPF - := inherited WithText(txt,size,fontname,c) as CircleWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): CircleWPF + := inherited SetText(txt,size,fontname,c) as CircleWPF; /// Декоратор поворота объекта - function WithRotate(da: real): CircleWPF := inherited WithRotate(da) as CircleWPF; + function SetRotate(da: real): CircleWPF := inherited SetRotate(da) as CircleWPF; end; // ----------------------------------------------------- @@ -501,17 +518,21 @@ type public /// Создает прямоугольник размера (w,h) заданного цвета с координатами левого верхнего угла (x,y) constructor (x,y,w,h: real; c: GColor) := Invoke(InitOb2,x,y,w,h,c); - /// Создает прямоугольник размера (w,h) заданного цвета с координатами левого верхнего угла, задаваемыми точкой + /// Создает прямоугольник размера (w,h) заданного цвета с координатами левого верхнего угла, задаваемыми точкой p constructor (p: Point; w,h: real; c: GColor) := Invoke(InitOb2,p.x,p.y,w,h,c); + /// Создает прямоугольник размера (w,h) заданного цвета с координатами левого верхнего угла (x,y), с границей ширины borderWidth и цвета borderColor + constructor (x,y,w,h: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,x,y,w,h,c); SetBorder(borderWidth,borderColor); end; + /// Создает прямоугольник размера (w,h) заданного цвета с координатами левого верхнего угла, задаваемыми точкой p, с границей ширины borderWidth и цвета borderColor + constructor (p: Point; w,h: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,p.x,p.y,w,h,c); SetBorder(borderWidth,borderColor); end; /// Декоратор включения границы объекта - function WithBorder(w: real := -1) := inherited WithBorder(w) as RectangleWPF; + function SetBorder(w: real := 1; c: GColor := Colors.Black) := inherited SetBorder(w,c) as RectangleWPF; /// Декоратор выключения границы объекта - function WithNoBorder := inherited WithNoBorder as RectangleWPF; + function RemoveBorder := inherited RemoveBorder as RectangleWPF; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): RectangleWPF - := inherited WithText(txt,size,fontname,c) as RectangleWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): RectangleWPF + := inherited SetText(txt,size,fontname,c) as RectangleWPF; /// Декоратор поворота объекта - function WithRotate(da: real): RectangleWPF := inherited WithRotate(da) as RectangleWPF; + function SetRotate(da: real): RectangleWPF := inherited SetRotate(da) as RectangleWPF; end; // ----------------------------------------------------- @@ -525,18 +546,22 @@ type public /// Создает квадрат со стороной w заданного цвета с координатами левого верхнего угла (x,y) constructor (x,y,w: real; c: GColor) := Invoke(InitOb2,x,y,w,c); - /// Создает квадрат со стороной w заданного цвета с координатами левого верхнего угла, задаваемыми точкой + /// Создает квадрат со стороной w заданного цвета с координатами левого верхнего угла, задаваемыми точкой p constructor (p: Point; w: real; c: GColor) := Invoke(InitOb2,p.x,p.y,w,c); + /// Создает квадрат со стороной w заданного цвета с координатами левого верхнего угла (x,y), с границей ширины borderWidth и цвета borderColor + constructor (x,y,w: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,x,y,w,c); SetBorder(borderWidth,borderColor); end; + /// Создает квадрат со стороной w заданного цвета с координатами левого верхнего угла, задаваемыми точкой p, с границей ширины borderWidth и цвета borderColor + constructor (p: Point; w: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,p.x,p.y,w,c); SetBorder(borderWidth,borderColor); end; /// Декоратор включения границы объекта - function WithBorder(w: real := -1) := inherited WithBorder(w) as SquareWPF; + function SetBorder(w: real := 1; c: GColor := Colors.Black) := inherited SetBorder(w,c) as SquareWPF; /// Декоратор выключения границы объекта - function WithNoBorder := inherited WithNoBorder as SquareWPF; + function RemoveBorder := inherited RemoveBorder as SquareWPF; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): SquareWPF - := inherited WithText(txt,size,fontname,c) as SquareWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): SquareWPF + := inherited SetText(txt,size,fontname,c) as SquareWPF; /// Декоратор поворота объекта - function WithRotate(da: real): SquareWPF - := inherited WithRotate(da) as SquareWPF; + function SetRotate(da: real): SquareWPF + := inherited SetRotate(da) as SquareWPF; end; // ----------------------------------------------------- @@ -556,17 +581,21 @@ type public /// Создает прямоугольник со скругленными краями размера (w,h) с радиусом скругления r заданного цвета с координатами левого верхнего угла (x,y) constructor (x,y,w,h,r: real; c: GColor) := Invoke(InitOb2,x,y,w,h,r,c); - /// Создает прямоугольник со скругленными краями размера (w,h) с радиусом скругления r заданного цвета с координатами левого верхнего угла, задаваемыми точкой + /// Создает прямоугольник со скругленными краями размера (w,h) с радиусом скругления r заданного цвета с координатами левого верхнего угла, задаваемыми точкой p constructor (p: Point; w,h,r: real; c: GColor) := Invoke(InitOb2,p.x,p.y,w,h,r,c); + /// Создает прямоугольник со скругленными краями размера (w,h) с радиусом скругления r заданного цвета с координатами левого верхнего угла (x,y), с границей ширины borderWidth и цвета borderColor + constructor (x,y,w,h,r: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,x,y,w,h,r,c); SetBorder(borderWidth,borderColor); end; + /// Создает прямоугольник со скругленными краями размера (w,h) с радиусом скругления r заданного цвета с координатами левого верхнего угла, задаваемыми точкой p, с границей ширины borderWidth и цвета borderColor + constructor (p: Point; w,h,r: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,p.x,p.y,w,h,r,c); SetBorder(borderWidth,borderColor); end; /// Декоратор включения границы объекта - function WithBorder(w: real := -1) := inherited WithBorder(w) as RoundRectWPF; + function SetBorder(w: real := 1; c: GColor := Colors.Black) := inherited SetBorder(w,c) as RoundRectWPF; /// Декоратор выключения границы объекта - function WithNoBorder := inherited WithNoBorder as RoundRectWPF; + function RemoveBorder := inherited RemoveBorder as RoundRectWPF; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): RoundRectWPF - := inherited WithText(txt,size,fontname,c) as RoundRectWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): RoundRectWPF + := inherited SetText(txt,size,fontname,c) as RoundRectWPF; /// Декоратор поворота объекта - function WithRotate(da: real): RoundRectWPF := inherited WithRotate(da) as RoundRectWPF; + function SetRotate(da: real): RoundRectWPF := inherited SetRotate(da) as RoundRectWPF; /// Радиус скругления property RoundRadius: real read InvokeReal(()->(ob as Rectangle).RadiusX) @@ -591,20 +620,24 @@ type public /// Создает квадрат со скругленными краями со стороной w с радиусом скругления r заданного цвета с координатами левого верхнего угла (x,y) constructor (x,y,w,r: real; c: GColor) := Invoke(InitOb2,x,y,w,r,c); - /// Создает квадрат со скругленными краями со стороной w с радиусом скругления r заданного цвета с координатами левого верхнего угла, задаваемыми точкой + /// Создает квадрат со скругленными краями со стороной w с радиусом скругления r заданного цвета с координатами левого верхнего угла, задаваемыми точкой p constructor (p: Point; w,r: real; c: GColor) := Invoke(InitOb2,p.x,p.y,w,r,c); + /// Создает квадрат со скругленными краями со стороной w с радиусом скругления r заданного цвета с координатами левого верхнего угла (x,y), с границей ширины borderWidth и цвета borderColor + constructor (x,y,w,r: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,x,y,w,r,c); SetBorder(borderWidth,borderColor); end; + /// Создает квадрат со скругленными краями со стороной w с радиусом скругления r заданного цвета с координатами левого верхнего угла, задаваемыми точкой p, с границей ширины borderWidth и цвета borderColor + constructor (p: Point; w,r: real; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,p.x,p.y,w,r,c); SetBorder(borderWidth,borderColor); end; /// Декоратор включения границы объекта - function WithBorder(w: real := -1): RoundSquareWPF - := inherited WithBorder(w) as RoundSquareWPF; + function SetBorder(w: real := 1; c: GColor := Colors.Black): RoundSquareWPF + := inherited SetBorder(w,c) as RoundSquareWPF; /// Декоратор выключения границы объекта - function WithNoBorder: RoundSquareWPF - := inherited WithNoBorder as RoundSquareWPF; + function RemoveBorder: RoundSquareWPF + := inherited RemoveBorder as RoundSquareWPF; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): RoundSquareWPF - := inherited WithText(txt,size,fontname,c) as RoundSquareWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): RoundSquareWPF + := inherited SetText(txt,size,fontname,c) as RoundSquareWPF; /// Декоратор поворота объекта - function WithRotate(da: real): RoundSquareWPF - := inherited WithRotate(da) as RoundSquareWPF; + function SetRotate(da: real): RoundSquareWPF + := inherited SetRotate(da) as RoundSquareWPF; end; MyText = class(FrameworkElement) @@ -644,9 +677,9 @@ type private function Element := ob as MyText; - procedure InitOb2(x,y: real; txt: string; c: GColor); + procedure InitOb2(x,y,sz: real; txt: string; c: GColor); begin - var rr := new MyText(txt,'Arial',16,c); + var rr := new MyText(txt,'Arial',sz,c); InitOb(x,y,rr.Width,rr.Height,rr); end; function GetInternalGeometry: Geometry; override; @@ -655,8 +688,10 @@ type Result := new RectangleGeometry(r); end; public - /// Создает прямоугольник размера (w,h) заданного цвета с координатами левого верхнего угла (x,y) - constructor (x,y: real; txt: string; c: GColor := Colors.Black) := Invoke(InitOb2,x,y,txt,c); + /// Создает текст заданного цвета с координатами левого верхнего угла (x,y) + constructor (x,y: real; txt: string; c: GColor := Colors.Black) := Invoke(InitOb2,x,y,16,txt,c); + /// Создает текст заданного цвета с координатами левого верхнего угла (x,y) и размером шрифта sz + constructor (x,y,sz: real; txt: string; c: GColor := Colors.Black) := begin Invoke(InitOb2,x,y,sz,txt,c); FontSize := sz; end; /// Размер шрифта property FontSize: real read InvokeReal(()->Self.Element.sz) write Invoke(procedure->begin Self.Element.sz := value; Self.Element.RecreateFormText; Width := Self.Element.Width; Height := Self.Element.Height; ob.InvalidateVisual; end); override; @@ -673,7 +708,7 @@ type property Text: string read InvokeString(()->Element.Text) write Invoke(procedure->begin Self.Element.Text := value; Self.Element.RecreateFormText; Width := Self.Element.Width; Height := Self.Element.Height; ob.InvalidateVisual end); override; /// Декоратор поворота объекта - function WithRotate(da: real): TextWPF := inherited WithRotate(da) as TextWPF; + function SetRotate(da: real): TextWPF := inherited SetRotate(da) as TextWPF; end; // ----------------------------------------------------- @@ -774,13 +809,13 @@ type Invoke(procedure->begin gr1.Height := value; end); end; override; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): LineWPF - := inherited WithText(txt,size,fontname,c) as LineWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): LineWPF + := inherited SetText(txt,size,fontname,c) as LineWPF; /// Декоратор поворота объекта - function WithRotate(da: real): LineWPF - := inherited WithRotate(da) as LineWPF; + function SetRotate(da: real): LineWPF + := inherited SetRotate(da) as LineWPF; /// Декоратор ширины линии отрезка - function WithLineWidth(lw: real): LineWPF; + function SetLineWidth(lw: real): LineWPF; begin LineWidth := lw; Result := Self; @@ -827,8 +862,12 @@ type public /// Создает правильный многоугольник заданного цвета с координатами центра (x,y) и радиусом описанной окружности r constructor (x,y,r: real; n: integer; c: GColor) := Invoke(InitOb2,x,y,r,n,c); - /// Создает правильный многоугольник заданного цвета с центром в заданной точке и радиусом описанной окружности r + /// Создает правильный многоугольник заданного цвета с центром в заданной точке p и радиусом описанной окружности r constructor (p: Point; r: real; n: integer; c: GColor) := Create(p.X,p.Y,r,n,c); + /// Создает правильный многоугольник заданного цвета с координатами центра (x,y) и радиусом описанной окружности r, с границей ширины borderWidth и цвета borderColor + constructor (x,y,r: real; n: integer; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,x,y,r,n,c); SetBorder(borderWidth,borderColor); end; + /// Создает правильный многоугольник заданного цвета с центром в заданной точке p и радиусом описанной окружности r, с границей ширины borderWidth и цвета borderColor + constructor (p: Point; r: real; n: integer; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,p.x,p.y,r,n,c); SetBorder(borderWidth,borderColor); end; /// Ширина объекта property Width: real read InvokeReal(()->gr.Width) @@ -846,17 +885,17 @@ type read InvokeInteger(()->n) write Invoke(Cnt,Value); /// Декоратор включения границы объекта - function WithBorder(w: real := -1): RegularPolygonWPF - := inherited WithBorder(w) as RegularPolygonWPF; + function SetBorder(w: real := 1; c: GColor := Colors.Black): RegularPolygonWPF + := inherited SetBorder(w,c) as RegularPolygonWPF; /// Декоратор выключения границы объекта - function WithNoBorder: RegularPolygonWPF - := inherited WithNoBorder as RegularPolygonWPF; + function RemoveBorder: RegularPolygonWPF + := inherited RemoveBorder as RegularPolygonWPF; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): RegularPolygonWPF - := inherited WithText(txt,size,fontname,c) as RegularPolygonWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): RegularPolygonWPF + := inherited SetText(txt,size,fontname,c) as RegularPolygonWPF; /// Декоратор поворота объекта - function WithRotate(da: real): RegularPolygonWPF - := inherited WithRotate(da) as RegularPolygonWPF; + function SetRotate(da: real): RegularPolygonWPF + := inherited SetRotate(da) as RegularPolygonWPF; end; // ----------------------------------------------------- @@ -913,6 +952,16 @@ type end; /// Создает звезду заданного цвета c центром в точке p, радиусом описанной окружности r и внутренним радиусом rinternal constructor (p: Point; r,rinternal: real; n: integer; c: GColor) := Create(p.X,p.Y,r,rinternal,n,c); + /// Создает звезду заданного цвета с координатами центра (x,y), радиусом описанной окружности r и внутренним радиусом rinternal, с границей ширины borderWidth и цвета borderColor + constructor (x,y,r,rinternal: real; n: integer; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black); + begin + if rinternalgr.Height/2) @@ -926,17 +975,17 @@ type read InvokeInteger(()->n) write Invoke(Cnt,Value); /// Декоратор включения границы объекта - function WithBorder(w: real := -1): StarWPF - := inherited WithBorder(w) as StarWPF; + function SetBorder(w: real := 1; c: GColor := Colors.Black): StarWPF + := inherited SetBorder(w,c) as StarWPF; /// Декоратор выключения границы объекта - function WithNoBorder: StarWPF - := inherited WithNoBorder as StarWPF; + function RemoveBorder: StarWPF + := inherited RemoveBorder as StarWPF; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): StarWPF - := inherited WithText(txt,size,fontname,c) as StarWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): StarWPF + := inherited SetText(txt,size,fontname,c) as StarWPF; /// Декоратор поворота объекта - function WithRotate(da: real): StarWPF - := inherited WithRotate(da) as StarWPF; + function SetRotate(da: real): StarWPF + := inherited SetRotate(da) as StarWPF; end; PointsArray = array of Point; @@ -970,6 +1019,8 @@ type function Element := ob as System.Windows.Shapes.Polygon; /// Создает многоугольник заданного цвета с координатами вершин, заданными массивом точек pp constructor (pp: array of Point; c: GColor) := Invoke(InitOb2,pp,c); + /// Создает многоугольник заданного цвета с координатами вершин, заданными массивом точек pp, с границей ширины borderWidth и цвета borderColor + constructor (pp: array of Point; c: GColor; borderWidth: real; borderColor: GColor := Colors.Black) := begin Invoke(InitOb2,pp,c); SetBorder(borderWidth,borderColor); end; /// Массив вершин property Points: array of Point read Invoke&(GetPointsArrayP) @@ -987,17 +1038,17 @@ type Invoke(procedure -> ob1.Points := new PointCollection(a)); end; /// Декоратор включения границы объекта - function WithBorder(w: real := -1): PolygonWPF - := inherited WithBorder(w) as PolygonWPF; + function SetBorder(w: real := 1; c: GColor := Colors.Black): PolygonWPF + := inherited SetBorder(w,c) as PolygonWPF; /// Декоратор выключения границы объекта - function WithNoBorder: PolygonWPF - := inherited WithNoBorder as PolygonWPF; + function RemoveBorder: PolygonWPF + := inherited RemoveBorder as PolygonWPF; /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): PolygonWPF - := inherited WithText(txt,size,fontname,c) as PolygonWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): PolygonWPF + := inherited SetText(txt,size,fontname,c) as PolygonWPF; /// Декоратор поворота объекта - function WithRotate(da: real): PolygonWPF - := inherited WithRotate(da) as PolygonWPF; + function SetRotate(da: real): PolygonWPF + := inherited SetRotate(da) as PolygonWPF; end; // ----------------------------------------------------- @@ -1043,10 +1094,10 @@ type /// Создает рисунок из файла fname с координатой левого верхнего угла, заданной точкой p, и размерами (w,h) constructor (p: Point; w,h: real; fname: string) := Invoke(InitOb3,p.x,p.y,w,h,fname); /// Декоратор текста объекта - function WithText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): PictureWPF - := inherited WithText(txt,size,fontname,c) as PictureWPF; + function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): PictureWPF + := inherited SetText(txt,size,fontname,c) as PictureWPF; /// Декоратор поворота объекта - function WithRotate(da: real): PictureWPF := inherited WithRotate(da) as PictureWPF; + function SetRotate(da: real): PictureWPF := inherited SetRotate(da) as PictureWPF; end; // ----------------------------------------------------- @@ -1117,7 +1168,7 @@ function Pnt(x,y: real) := new Point(x,y); function Rect(x,y,w,h: real) := new System.Windows.Rect(x,y,w,h); function ColorBrush(c: Color) := new SolidColorBrush(c); -procedure Invoke(p: ()->()) := GraphWPFBase.Invoke(p); +procedure Redraw(p: ()->()) := GraphWPFBase.Invoke(p); procedure SetLeft(Self: UIElement; l: integer) := Self.SetLeft(l); procedure SetTop(Self: UIElement; t: integer) := Self.SetTop(t); diff --git a/bin/PT4/loadpabc.dat b/bin/PT4/loadpabc.dat index f3483920d..dfd01b9fd 100644 --- a/bin/PT4/loadpabc.dat +++ b/bin/PT4/loadpabc.dat @@ -12,6 +12,7 @@ loadver=4 ==cc| |19 ==mix| |10 ==p| |10 +==ps| |10 ==pp| |8 =DM| ||%f.pas|uses Drawman;%#%#begin%# Task('%t%n');%#%#end. ==a| |6