Changeset 10 for trunk/Apps


Ignore:
Timestamp:
Aug 29, 2016, 5:35:21 PM (8 years ago)
Author:
chronos
Message:
  • Added: Second clock task running in parallel.
  • Modified: Redraw screen only with maximum defined period. Not after each graphic operation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Apps/UClock.pas

    r9 r10  
    1313
    1414  TAppClock = class(TApp)
     15    procedure Run(Task: TTask); override;
     16    constructor Create; override;
     17  end;
     18
     19  { TAppClock2 }
     20
     21  TAppClock2 = class(TApp)
    1522    procedure Run(Task: TTask); override;
    1623    constructor Create; override;
     
    3643    Angle := Frac(Now / (10 * OneSecond)) * 2 * Pi;
    3744    API.DrawLine(Point(120, 120), Point(Trunc(120 + Cos(Angle) * 60), Trunc(120 + Sin(Angle) * 60)), 0);
    38     API.Sleep(OneMillisecond * 100);
     45    API.Sleep(OneMillisecond * 50);
    3946    //API.ReadMessage(Message);
    4047  end;
     
    4855end;
    4956
     57{ TAppClock2 }
     58
     59procedure TAppClock2.Run(Task: TTask);
     60var
     61  Message: TIPCMessage;
     62  WindowId: Integer;
     63  Angle: Double;
     64begin
     65  Message := TIPCMessage.Create;
     66  WindowId := API.WindowCreate;
     67  API.WindowSetAttr(300, 200, True);
     68  while not Task.Terminated do begin
     69    API.WriteText('test2');
     70    API.DrawRect(Rect(260, 160, 380, 280), $ffff80);
     71    API.DrawText(Point(210, 110), 'Text', 0);
     72    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);
     74    API.Sleep(OneMillisecond * 300);
     75    //API.ReadMessage(Message);
     76  end;
     77  Message.Free;
     78end;
     79
     80constructor TAppClock2.Create;
     81begin
     82  inherited Create;
     83  Name := 'Clock2';
     84end;
     85
    5086end.
    5187
Note: See TracChangeset for help on using the changeset viewer.