FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Pas2JS-WebGL/Matrix.pas at master · genericptr/Pas2JS-WebGL · GitHub
genericptr
/
Pas2JS-WebGL
Public
Notifications
You must be signed in to change notification settings
Fork
8
Star
15
Code
Issues
2
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Pas2JS-WebGL
/
Matrix.pas
Copy path
More file actions
More file actions
Latest commit
History
History
History
71 lines (59 loc) · 1.24 KB
Breadcrumbs
Pas2JS-WebGL
/
Matrix.pas
Copy path
File metadata and controls
71 lines (59 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
unit
Matrix;
interface
uses
JS;
type
TMatrix =
class
public
constructor
Create (w, h: integer);
procedure
SetValue
(x, y: integer;
value
: JSValue);
function
GetValue
(x, y: integer): JSValue;
procedure
Show
;
function
GetWidth
: integer;
function
GetHeight
: integer;
//
NOTE: no indexers yet?
//
property Indexer[const x,y:integer]:JSValue read GetValue write SetValue; default;
private
table: TJSArray;
width: integer;
height: integer;
function
IndexFor
(x, y: integer): integer;
end
;
implementation
constructor
TMatrix.Create (w, h: integer);
begin
width := w;
height := h;
table := TJSArray.new(width * height);
end
;
procedure
TMatrix.SetValue
(x, y: integer;
value
: JSValue);
begin
table[IndexFor(x, y)] :=
value
;
end
;
function
TMatrix.GetValue
(x, y: integer): JSValue;
begin
result := table[IndexFor(x, y)];
end
;
function
TMatrix.IndexFor
(x, y: integer): integer;
begin
result := x + y * height;
end
;
procedure
TMatrix.Show
;
var
x, y: integer;
begin
for
x :=
0
to
width -
1
do
for
y :=
0
to
height -
1
do
begin
writeln(x,
'
,
'
,y,
'
:
'
, GetValue(x, y));
end
;
end
;
function
TMatrix.GetWidth
: integer;
begin
result := width;
end
;
function
TMatrix.GetHeight
: integer;
begin
result := height;
end
;
end
.
Back
|
FazBrowse Home
|
New Git URL