File tree Expand file tree Collapse file tree 2 files changed +31
-16
lines changed
samples/a8/graph_crossplatform Expand file tree Collapse file tree 2 files changed +31
-16
lines changed Original file line number Diff line number Diff line change 1
1
// Koch Snowflake
2
2
// https://en.wikipedia.org/wiki/Koch_snowflake
3
3
4
- // float16 186
5
- // real 197
6
- // single 237
4
+ // For every supported data type, a separate unit with the same code is used.
5
+ // Float16 186 ticks
6
+ // Real 197 ticks
7
+ // Single 237 ticks
7
8
9
+ // FPC does not have Float16
10
+ { $IFNDEF FPC}
11
+ { $DEFINE HAS_FLOAT16}
12
+ { $ENDIF}
8
13
9
14
uses crt, graph, sysutils,
15
+ { $IFDEF HAS_FLOAT16}
16
+ snowflake_unit_float16 in ' snowflake_unit_float16.pas' ,
17
+ { $ENDIF}
10
18
snowflake_unit_real in ' snowflake_unit_real.pas' ,
11
19
snowflake_unit_single in ' snowflake_unit_single.pas' ;
12
20
13
- procedure WaitForKey ;
14
- begin
15
- repeat
16
- until KeyPressed;
17
- ReadKey;
18
- repeat
19
- until not KeyPressed;
20
- end ;
21
-
22
21
procedure Snowflake ;
23
22
24
23
const FLOAT_TYPES : array of String = [
25
- { $IFDEF FLOAT16 } // TODO does not work yet
24
+ { $IFDEF HAS_FLOAT16 }
26
25
' Float16' ,
27
26
{ $ENDIF}
28
27
' Real' ,
@@ -45,20 +44,20 @@ procedure Snowflake;
45
44
ticks := GetTickCount;
46
45
47
46
floatType:=FLOAT_TYPES[i];
48
- { $IFDEF Float16 }
47
+ { $IFDEF HAS_FLOAT16 }
49
48
if floatType = ' Float16' then snowflake_unit_float16.CreateKochSnowflake;
50
49
{ $ENDIF}
51
50
if floatType = ' Real' then snowflake_unit_real.CreateKochSnowflake;
52
51
if floatType = ' Single' then snowflake_unit_single.CreateKochSnowflake;
53
52
54
53
ticks := GetTickCount - ticks;
55
54
56
- WaitForKey ;
55
+ ReadKey ;
57
56
58
57
WriteLn(' Koch Snowflake with type '' ' ,floatType,' '' .' );
59
58
Writeln(' Time required: ' , ticks,' ticks' );
60
59
WriteLn(' Press any key to continue.' );
61
- WaitForKey ;
60
+ ReadKey ;
62
61
63
62
end ;
64
63
Original file line number Diff line number Diff line change
1
+ unit snowflake_unit_float16;
2
+
3
+ interface
4
+
5
+ procedure CreateKochSnowflake ;
6
+
7
+ implementation
8
+
9
+ uses graph;
10
+
11
+ type
12
+ TFloat = Float16;
13
+
14
+ { $I snowflake_unit.inc}
15
+
16
+ end .
You can’t perform that action at this time.
0 commit comments