CodeTyphon Web Development Pas2JS, WASM, etc, discussions and problems
 Page:1

# TOPIC:

## Canvas Example in JS Web GUI Web Browser Application 3 years 1 month ago #16073

 Dan Eller Topic Author Offline New Member Posts: 5 Thank you received: 2 Hi, Not sure if anybody would want this, but I converted the classic Canvas drawing example to run as a JS GUI Web Brower Application in CT 7.5 . Enjoy! -Dan Eller unit Unit1; {\$mode objfpc}{\$H+} interface uses   JS, Classes, SysUtils, Graphics, Controls, Forms, Dialogs, WebCtrls,math; type   { TWForm1 }   TWForm1 = class(TWForm)     WTimer1: TWTimer;     procedure FormCreate(Sender: TObject);     procedure FormResize(Sender: TObject);     procedure WTimer1Timer(Sender: TObject);      procedure FormPaint();     procedure RotatePoints();   private   public   end;     type     TRPoint = record           X,Y:Real;     end; var   WForm1: TWForm1;    PointCount, MaxPoints:integer;    Rotation:Real;    Points: array [0..15] of TRPoint; implementation {\$R *.frm} { TWForm1 } procedure TWForm1.FormCreate(Sender: TObject); begin   Canvas.Pen.Color := clGreen;     Rotation := 0;         MaxPoints:=15;     PointCount := MaxPoints;          RotatePoints(); end; procedure TWForm1.FormResize(Sender: TObject); begin   Invalidate();   FormPaint(); end; procedure TWForm1.WTimer1Timer(Sender: TObject); begin   RotatePoints();   Invalidate();   FormPaint(); end; procedure TWForm1.RotatePoints(); var    M_2PI,StepAngle,j:Real;    i:integer; begin         M_2PI:=2 * PI;         StepAngle:=M_2PI / PointCount;         Rotation :=Rotation+ PI / 1024;         if Rotation > StepAngle then            begin              Rotation  :=-StepAngle;            end;       i:=0;       j:=Rotation;        while i

## Canvas Example in JS Web GUI Web Browser Application 3 years 4 weeks ago #16074

 Sternas Stefanos Offline Moderator Ex Pilot, M.Sc, Ph.D Posts: 4518 Thank you received: 1106 Thanks Sir if you want to put your code to CodeOcean, please attach the full project here PilotLogic Architect and Core Programmer Please Log in or Create an account to join the conversation.

## Canvas Example in JS Web GUI Web Browser Application 3 years 4 weeks ago #16075

• Dan Eller
• Topic Author
• Offline
• New Member
• Posts: 5

#### File Attachment:

File Name: ct_jsgui_canvas.7z
File Size:451 KB

Okay, here are the project files. Hope they can help someone in CodeOcean.
-Dan Eller

• Dan Eller
• Topic Author
• Offline
• New Member
• Posts: 5