You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: v0.3/handbook/libraries/stdlib.md
+97-40Lines changed: 97 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
layout: default
3
3
title: "Standard Library"
4
4
---
5
+
{% raw %}
5
6
6
7
# Standard Library
7
8
@@ -655,6 +656,10 @@ bind
655
656
<ul>
656
657
<li><strong>element</strong> - (optional) - the element to be monitored; includes clicks on any children within the element</li>
657
658
<li><strong>target</strong> - (optional) - the exact element to be monitored; does not include any children</li>
659
+
<li><strong>page-x</strong> - (optional) - the x-coordinate of the mouse pointer relative to the page</li>
660
+
<li><strong>page-y</strong> - (optional) - the y-coordinate of the mouse pointer relative to the page</li>
661
+
<li><strong>window-x</strong> - (optional) - the x-coordinate of the mouse pointer relative to the window</li>
662
+
<li><strong>window-y</strong> - (optional) - the y-coordinate of the mouse pointer relative to the page</li>
658
663
<li><strong>button</strong> - (optional) - the mouse button whose click is monitored; options are:
659
664
<ul>
660
665
<li>“left” - left mouse button; if no button argument is provided, this is the default</li>
@@ -814,11 +819,11 @@ The canvas library is an interface for drawing graphics in the browser using the
814
819
815
820
<tr>
816
821
<td>
817
-
<ui>
822
+
<ul>
818
823
<li><strong>width</strong> - the width of the canvas in pixels</li>
819
824
<li><strong>height</strong> - the height of the canvas in pixels</li>
820
825
<li><strong>children</strong> - (optional) - paths are written as child records; while optional, without any children, the canvas will be blank</li>
821
-
</ui>
826
+
</ul>
822
827
</td>
823
828
<td><code>// creates a canvas tagged #my-canvas that is 160 pixels wide by 90 pixel tall
824
829
```
@@ -838,7 +843,7 @@ commit
838
843
839
844
<tr>
840
845
<td>
841
-
<ui>
846
+
<ul>
842
847
<li><strong>fillStyle</strong> - (optional) - sets the color, gradient, or pattern used to fill the drawing; if undefined, the default is black</li>
843
848
<li><strong>strokeStyle</strong> - (optional) - sets the color, gradient, or pattern used for the strokes; if undefined, the path will default to a black fill style</li>
844
849
<li><strong>lineWidth</strong> - (optional) - sets the width of strokes in pixels; if undefined, the default is 1px</li>
@@ -857,7 +862,7 @@ commit
857
862
</ul>
858
863
</li>
859
864
<li><strong>children</strong> - (optional) - each individual operation in the path is written as a child record; while optional, without any children, the canvas will be blank</li>
860
-
</ui>
865
+
</ul>
861
866
</td>
862
867
<td><code>// adds a #canvas/path to #my-canvas with a black stroke, a line width of 2 pixels and beveled corners
863
868
```
@@ -884,10 +889,10 @@ commit
884
889
885
890
<tr>
886
891
<td>
887
-
<ui>
892
+
<ul>
888
893
<li><strong>x</strong> - the horizontal coordinate to move to, in pixels</li>
889
894
<li><strong>y</strong> - the vertical coordinate to move to, in pixels</li>
890
-
</ui>
895
+
</ul>
891
896
</td>
892
897
<td><code>// creates a 100x100 canvas and moves the path 20 pixels right and 15 pixels down from the top left corner of the canvas without drawing a line
893
898
```
@@ -909,10 +914,10 @@ commit
909
914
910
915
<tr>
911
916
<td>
912
-
<ui>
917
+
<ul>
913
918
<li><strong>x</strong> - the horizontal coordinate to move to, in pixels</li>
914
919
<li><strong>y</strong> - the vertical coordinate to move to, in pixels</li>
915
-
</ui>
920
+
</ul>
916
921
</td>
917
922
<td><code>// draws a black line from the top left corner of a 100x100 canvas to the center
918
923
```
@@ -934,14 +939,14 @@ commit
934
939
935
940
<tr>
936
941
<td>
937
-
<ui>
942
+
<ul>
938
943
<li><strong>cp1x</strong> - the x coordinate of the first control point</li>
939
944
<li><strong>cp1y</strong> - the y coordinate of the first control point</li>
940
945
<li><strong>cp2x</strong> - the x coordinate of the second control point</li>
941
946
<li><strong>cp2y</strong> - the y coordinate of the second control point</li>
942
947
<li><strong>x</strong> - the x coordinate of the end point</li>
943
948
<li><strong>y</strong> - the y coordinate of the end point</li>
944
-
</ui>
949
+
</ul>
945
950
</td>
946
951
<td><code>// draws a red Bézier curve starting at (20, 25) and ending at (40, 50)
947
952
```
@@ -964,12 +969,12 @@ commit
964
969
965
970
<tr>
966
971
<td>
967
-
<ui>
972
+
<ul>
968
973
<li><strong>cpx</strong> - the x coordinate of the control point</li>
969
974
<li><strong>cpy</strong> - the y coordinate of the control point</li>
970
975
<li><strong>y</strong> - the x coordinate of the end point</li>
971
976
<li><strong>y</strong> - the y coordinate of the end point</li>
972
-
</ui>
977
+
</ul>
973
978
</td>
974
979
<td><code></code>
975
980
</td>
@@ -985,14 +990,14 @@ commit
985
990
986
991
<tr>
987
992
<td>
988
-
<ui>
993
+
<ul>
989
994
<li><strong>y</strong> - the x coordinate of the center of the curve</li>
990
995
<li><strong>y</strong> - the y coordinate of the center of the curve</li>
991
996
<li><strong>radius</strong> - the radius of the curve in pixels</li>
992
997
<li><strong>startAngle</strong> - the starting angle of the curve in radians</li>
993
998
<li><strong>endAngle</strong> - the ending angle of the curve in radians</li>
994
999
<li><strong>anticlockwise</strong> - (optional) - values can be true or false; true draws the arc counterclockwise, false draws the arc clockwise</li>
995
-
</ui>
1000
+
</ul>
996
1001
</td>
997
1002
<td><code>// draws an arc that circumscribes ¾ of a 40 pixel-wide circle in the middle of the canvas
998
1003
```
@@ -1014,13 +1019,13 @@ commit
1014
1019
1015
1020
<tr>
1016
1021
<td>
1017
-
<ui>
1022
+
<ul>
1018
1023
<li><strong>x1</strong> - the x coordinate of the starting point of the curve</li>
1019
1024
<li><strong>y1</strong> - the y coordinate of the starting point of the curve</li>
1020
1025
<li><strong>x2</strong> - the x coordinate of the ending point of the curve</li>
1021
1026
<li><strong>y2</strong> - the y coordinate of the ending point of the curve</li>
1022
1027
<li>radius - the radius of the curve in pixels</li>
1023
-
</ui>
1028
+
</ul>
1024
1029
</td>
1025
1030
<td><code>// draws an arc that connects two perpendicular lines with a circular curve
1026
1031
```
@@ -1044,7 +1049,7 @@ commit
1044
1049
1045
1050
<tr>
1046
1051
<td>
1047
-
<ui>
1052
+
<ul>
1048
1053
<li><strong>y</strong> - the x coordinate of the center of the curve</li>
1049
1054
<li><strong>y</strong> - the y coordinate of the center of the curve</li>
1050
1055
<li><strong>radiusX</strong> - the horizontal radius of the curve</li>
@@ -1053,7 +1058,7 @@ commit
1053
1058
<li><strong>startAngle</strong> - the starting angle of the curve in radians</li>
1054
1059
<li><strong>endAngle</strong> - the ending angle of the curve in radians</li>
1055
1060
<li><strong>anticlockwise</strong> - (optional) - values can be true or false; true draws the arc counterclockwise, false draws the arc clockwise</li>
1056
-
</ui>
1061
+
</ul>
1057
1062
</td>
1058
1063
<td><code>// draws a green oval in the center of the canvas that is 20 pixels wide and 30 pixels high
1059
1064
```
@@ -1075,12 +1080,12 @@ commit
1075
1080
1076
1081
<tr>
1077
1082
<td>
1078
-
<ui>
1083
+
<ul>
1079
1084
<li><strong>y</strong> - the x coordinate of the upper left corner of the rectangle</li>
1080
1085
<li><strong>y</strong> - the y coordinate of the upper left corner of the rectangle</li>
1081
1086
<li><strong>width</strong> - the width of the rectangle in pixels</li>
1082
1087
<li><strong>height</strong> - the height of the rectangle in pixels</li>
1083
-
</ui>
1088
+
</ul>
1084
1089
</td>
1085
1090
<td><code>// draws a blue square with black borders in the middle of the canvas
1086
1091
```
@@ -1102,9 +1107,9 @@ commit
1102
1107
1103
1108
<tr>
1104
1109
<td>
1105
-
<ui>
1110
+
<ul>
1106
1111
<li>No arguments</li>
1107
-
</ui>
1112
+
</ul>
1108
1113
</td>
1109
1114
<td><code>// returns the path to (10, 10) from (20, 40) to create a triangle
1110
1115
```
@@ -1135,7 +1140,7 @@ The UI library provides a shorthand for adding standard HTML elements, as well a
1135
1140
1136
1141
<tr>
1137
1142
<td>
1138
-
<ui>
1143
+
<ul>
1139
1144
<li>the <code>#ui</code> tag supports the following html elements:
1140
1145
<ul>
1141
1146
<li><code>#ui/row</code></li>
@@ -1162,7 +1167,7 @@ The UI library provides a shorthand for adding standard HTML elements, as well a
1162
1167
<li><strong>#</strong> - (optional) - any other tags on the record will be applied to the element as classes</li>
1163
1168
<li><strong>class</strong> - (optional) defines one or more classes for the element</li>
1164
1169
<li>Other attributes - (optional) - other attribute-value pairs will be applied directly to the element for integration with existing JS libraries or debugging</li>
1165
-
</ui>
1170
+
</ul>
1166
1171
</td>
1167
1172
<td><code>// commits a div in the browser with the text “Hello world!”
1168
1173
```
@@ -1182,14 +1187,14 @@ commit
1182
1187
1183
1188
<tr>
1184
1189
<td>
1185
-
<ui>
1190
+
<ul>
1186
1191
<li><strong>children</strong> - (optional) - the children contained within the column or row</li>
1187
1192
<li><strong>style</strong> - (optional) - specific CSS styles can be defined, but must be entered as a subrecord</li>
1188
1193
<li><strong>text</strong> - (optional) - defines text within the column or row</li>
1189
1194
<li><strong>#</strong> - (optional) - any other tags on the record will be applied to the column or row as classes</li>
1190
1195
<li><strong>class</strong> - (optional) defines one or more classes for the element</li>
1191
1196
<li>Other attributes - (optional) - other attribute-value pairs will be applied directly to the column or row for integration with existing JS libraries or debugging</li>
1192
-
</ui>
1197
+
</ul>
1193
1198
</td>
1194
1199
<td><code>// creates 3 very wise divs in the browser stacked on top of one another
1195
1200
```
@@ -1212,7 +1217,7 @@ commit
1212
1217
1213
1218
<tr>
1214
1219
<td>
1215
-
<ui>
1220
+
<ul>
1216
1221
<li> - (optional) - preset options for class are:
1217
1222
<ul>
1218
1223
<li>“inset” - an inset button style</li>
@@ -1225,7 +1230,7 @@ commit
1225
1230
<li><strong>text</strong> - (optional) - defines text in the button</li>
1226
1231
<li><strong>#</strong> - (optional) - any other tags on the record will be applied to the button as classes</li>
1227
1232
<li>Other attributes - (optional) - other attribute-value pairs will be applied directly to the button for integration with existing JS libraries or debugging</li>
1228
-
</ui>
1233
+
</ul>
1229
1234
</td>
1230
1235
<td><code></code>
1231
1236
</td>
@@ -1241,15 +1246,15 @@ commit
1241
1246
1242
1247
<tr>
1243
1248
<td>
1244
-
<ui>
1249
+
<ul>
1245
1250
<li><strong>completion</strong> - the list of possible responses, given as a subrecord with the attribute “text” whose value is the list; requires the use of a pipe in the #ui record if matching against multiple search records for one autocomplete field</li>
1246
1251
<li><strong>Note</strong>: Once an autocomplete option has been selected, #ui/autocomplete automatically gains a <strong>selected</strong> attribute whose value is the completion record; in the case of the example shown here, the <strong>selected</strong> attribute would be whichever <code>#state</code> record was chosen</li>
1247
1252
<li><strong>placeholder</strong> - (optional) - the placeholder text for the input field</li>
1248
1253
<li><strong>style</strong> - (optional) - specific CSS styles can be defined, but must be entered as a subrecord</li>
1249
1254
<li><strong>#</strong> - (optional) - any other tags on the record will be applied to the autocomplete as classes</li>
1250
1255
<li><strong>class</strong> - (optional) defines one or more classes for the autocomplete</li>
1251
1256
<li>Other attributes - (optional) - other attribute-value pairs will be applied directly to the autocomplete for integration with existing JS libraries or debugging</li>
1252
-
</ui>
1257
+
</ul>
1253
1258
</td>
1254
1259
<td><code>// creates an autocomplete form with the class “birth-state” and the placeholder “Which state were you born in?”, where the autocomplete options are the names of any #state records found
1255
1260
```
@@ -1277,9 +1282,9 @@ commit
1277
1282
1278
1283
<tr>
1279
1284
<td>
1280
-
<ui>
1285
+
<ul>
1281
1286
<li><strong>autocomplete</strong> - the autocomplete element to clear</li>
1282
-
</ui>
1287
+
</ul>
1283
1288
</td>
1284
1289
<td><code>// clears an autocomplete field if it loses focus
1285
1290
```
@@ -1303,9 +1308,9 @@ commit
1303
1308
1304
1309
<tr>
1305
1310
<td>
1306
-
<ui>
1311
+
<ul>
1307
1312
<li><strong>autocomplete</strong> - the autocomplete being opened</li>
1308
-
</ui>
1313
+
</ul>
1309
1314
</td>
1310
1315
<td><code>// changes the font color of the autocomplete input to red when the list is opened; the color will not revert once the menu is closed unless another block is specifically written to do so
1311
1316
```
@@ -1330,9 +1335,9 @@ commit
1330
1335
1331
1336
<tr>
1332
1337
<td>
1333
-
<ui>
1338
+
<ul>
1334
1339
<li><strong>autocomplete</strong> - the autocomplete being closed</li>
1335
-
</ui>
1340
+
</ul>
1336
1341
</td>
1337
1342
<td><code>// changes the font color of the autocomplete input to black when the list is closed; reverts the change in the example for #ui/event/open
1338
1343
```
@@ -1357,9 +1362,9 @@ commit
1357
1362
1358
1363
<tr>
1359
1364
<td>
1360
-
<ui>
1365
+
<ul>
1361
1366
<li><strong>autocomplete</strong> - the autocomplete being closed</li>
1362
-
</ui>
1367
+
</ul>
1363
1368
</td>
1364
1369
<td><code>// as a follow-up to the #ui/autocomplete example, this waits for the user to pick a birth state, then creates a new autocomplete tagged #birth-county to ask which county within that particular state the user was born in
1365
1370
```
@@ -1384,9 +1389,9 @@ commit
1384
1389
1385
1390
<tr>
1386
1391
<td>
1387
-
<ui>
1392
+
<ul>
1388
1393
<li><strong>autocomplete</strong> - the autocomplete whose input field changed</li>
1389
-
</ui>
1394
+
</ul>
1390
1395
</td>
1391
1396
<td><code>// when an autocomplete asking what the magic word is changes to the correct answer, adds the tag #magic-word to the autocomplete
1392
1397
```
@@ -1400,3 +1405,55 @@ bind
1400
1405
</td>
1401
1406
</tr>
1402
1407
</table>
1408
+
1409
+
## System
1410
+
1411
+
The system library provides various system-level utilities for Eve.
1412
+
1413
+
<table class="libitem">
1414
+
<tr>
1415
+
<td colspan="2">
1416
+
<b>#system/timer</b> - starts a timer at the specified resolution
1417
+
</td>
1418
+
</tr>
1419
+
1420
+
<tr>
1421
+
<td>
1422
+
<ul>
1423
+
<li><strong>resolution</strong> - the frequency in milliseconds of the timer.</li>
1424
+
<li><strong>year</strong> - (optional) - the current year</li>
1425
+
<li><strong>month</strong> - (optional) - the current month (1 - 12)</li>
1426
+
<li><strong>day</strong> - (optional) - the current day of the month (1 - 31)</li>
1427
+
<li><strong>weekday</strong> - (optional) - the current day of the week (1 - 7, where 1 is Sunday)</li>
1428
+
<li><strong>hour</strong> - (optional) - the current hour (0 - 23)</li>
1429
+
<li><strong>minute</strong> - (optional) - the current minute (0 - 59)</li>
1430
+
<li><strong>second</strong> - (optional) - the current second (0 - 59)</li>
1431
+
<li><strong>millisecond</strong> - (optional) - the current millisecond (0 - 999)</li>
1432
+
<li><strong>timestamp</strong> - (optional) - the current time represented as the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC</li>
1433
+
<li><strong>tick</strong> - (optional) - the number of ticks of the timer since it was created</li>
1434
+
</ul>
1435
+
</td>
1436
+
<td>
1437
+
<code>
1438
+
Commits a timer that ticks every 1000 milliseconds
0 commit comments