Changeset 13 for trunk/Apps/UClock.pas


Ignore:
Timestamp:
Sep 25, 2017, 2:48:08 PM (7 years ago)
Author:
chronos
Message:
  • Added: Drawing relative to Canvas. In case of Window drawing relative to Window.
  • Modified: Use custom TPoint and TRectangle if possible.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Apps/UClock.pas

    r12 r13  
    66
    77uses
    8   Classes, SysUtils, UApp, dateutils, UKernel, UScheduler, UIPC;
     8  SysUtils, UApp, dateutils, UKernel, UScheduler, UIPC, UGraphics;
    99
    1010type
     
    3232  Message: TIPCMessage;
    3333  WindowId: Integer;
     34  CanvasId: Integer;
    3435  Angle: Double;
    3536begin
    3637  Message := TIPCMessage.Create;
    3738  WindowId := API.WindowCreate;
    38   API.WindowSetAttr(Point(300, 200), True);
     39  CanvasId := API.GetWindowCanvas(WindowId);
     40  API.WindowSetAttr(WindowId, TRectangle.Create(100, 50, 300, 200), True);
    3941  while not Task.Terminated do begin
    4042    API.WriteText('test');
    41     API.DrawRect(Rect(60, 60, 180, 180), $ffffff);
    42     API.DrawText(Point(10, 10), 'Text', 0);
     43    API.DrawRect(CanvasId, TRectangle.Create(60, 60, 180, 180), $ffffff);
     44    API.DrawText(CanvasId, TPoint.Create(10, 10), 'Text', 0);
    4345    Angle := Frac(Now / (10 * OneSecond)) * 2 * Pi;
    44     API.DrawLine(Point(120, 120), Point(Trunc(120 + Cos(Angle) * 60), Trunc(120 + Sin(Angle) * 60)), 0);
     46    API.DrawLine(CanvasId, TPoint.Create(120, 120), TPoint.Create(Trunc(120 + Cos(Angle) * 60), Trunc(120 + Sin(Angle) * 60)), 0);
    4547    API.Sleep(OneMillisecond * 10);
    4648    //API.ReadMessage(Message);
     
    6163  Message: TIPCMessage;
    6264  WindowId: Integer;
     65  CanvasId: Integer;
    6366  Angle: Double;
    6467begin
    6568  Message := TIPCMessage.Create;
    6669  WindowId := API.WindowCreate;
    67   API.WindowSetAttr(Point(300, 200), True);
     70  CanvasId := API.GetWindowCanvas(WindowId);
     71  API.WindowSetAttr(WindowId, TRectangle.Create(100, 100, 300, 200), True);
    6872  while not Task.Terminated do begin
    6973    API.WriteText('test2');
    70     API.DrawRect(Rect(260, 160, 380, 280), $ffff80);
    71     API.DrawText(Point(210, 110), 'Text', 0);
     74    API.DrawRect(CanvasId, TRectangle.Create(460, 160, 380, 280), $ffff80);
     75    API.DrawText(CanvasId, TPoint.Create(210, 110), 'Text', 0);
    7276    Angle := Frac(Now / (10 * OneSecond)) * 2 * Pi;
    73     API.DrawLine(Point(320, 220), Point(Trunc(320 + Cos(Angle) * 60), Trunc(220 + Sin(Angle) * 60)), 0);
     77    API.DrawLine(CanvasId, TPoint.Create(320, 220), TPoint.Create(Trunc(320 + Cos(Angle) * 120), Trunc(220 + Sin(Angle) * 120)), 0);
    7478    API.Sleep(OneMillisecond * 300);
    7579    //API.ReadMessage(Message);
Note: See TracChangeset for help on using the changeset viewer.