Skip to content

Commit 8c33057

Browse files
authored
Merge pull request #11 from cmontella/add/system
Document timer
2 parents c99f5f0 + deba498 commit 8c33057

File tree

3 files changed

+103
-45
lines changed

3 files changed

+103
-45
lines changed

_layouts/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ <h1><img alt="EVE" src="https://witheve.github.io/assets/images/wordmark.svg" />
6969
<li><a href="{{ site.url }}/v0.3/handbook/libraries/stdlib/#html">HTML</a></li>
7070
<li><a href="{{ site.url }}/v0.3/handbook/libraries/stdlib/#canvas">Canvas</a></li>
7171
<li><a href="{{ site.url }}/v0.3/handbook/libraries/stdlib/#ui">UI</a></li>
72+
<li><a href="{{ site.url }}/v0.3/handbook/libraries/stdlib/#system">System</a></li>
7273

7374

7475
</ul>

v0.3/handbook/libraries/stdlib.md

Lines changed: 97 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: default
33
title: "Standard Library"
44
---
5+
{% raw %}
56

67
# Standard Library
78

@@ -655,6 +656,10 @@ bind
655656
<ul>
656657
<li><strong>element</strong> - (optional) - the element to be monitored; includes clicks on any children within the element</li>
657658
<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>
658663
<li><strong>button</strong> - (optional) - the mouse button whose click is monitored; options are:
659664
<ul>
660665
<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
814819
815820
<tr>
816821
<td>
817-
<ui>
822+
<ul>
818823
<li><strong>width</strong> - the width of the canvas in pixels</li>
819824
<li><strong>height</strong> - the height of the canvas in pixels</li>
820825
<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>
822827
</td>
823828
<td><code>// creates a canvas tagged #my-canvas that is 160 pixels wide by 90 pixel tall
824829
```
@@ -838,7 +843,7 @@ commit
838843
839844
<tr>
840845
<td>
841-
<ui>
846+
<ul>
842847
<li><strong>fillStyle</strong> - (optional) - sets the color, gradient, or pattern used to fill the drawing; if undefined, the default is black</li>
843848
<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>
844849
<li><strong>lineWidth</strong> - (optional) - sets the width of strokes in pixels; if undefined, the default is 1px</li>
@@ -857,7 +862,7 @@ commit
857862
</ul>
858863
</li>
859864
<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>
861866
</td>
862867
<td><code>// adds a #canvas/path to #my-canvas with a black stroke, a line width of 2 pixels and beveled corners
863868
```
@@ -884,10 +889,10 @@ commit
884889
885890
<tr>
886891
<td>
887-
<ui>
892+
<ul>
888893
<li><strong>x</strong> - the horizontal coordinate to move to, in pixels</li>
889894
<li><strong>y</strong> - the vertical coordinate to move to, in pixels</li>
890-
</ui>
895+
</ul>
891896
</td>
892897
<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
893898
```
@@ -909,10 +914,10 @@ commit
909914
910915
<tr>
911916
<td>
912-
<ui>
917+
<ul>
913918
<li><strong>x</strong> - the horizontal coordinate to move to, in pixels</li>
914919
<li><strong>y</strong> - the vertical coordinate to move to, in pixels</li>
915-
</ui>
920+
</ul>
916921
</td>
917922
<td><code>// draws a black line from the top left corner of a 100x100 canvas to the center
918923
```
@@ -934,14 +939,14 @@ commit
934939
935940
<tr>
936941
<td>
937-
<ui>
942+
<ul>
938943
<li><strong>cp1x</strong> - the x coordinate of the first control point</li>
939944
<li><strong>cp1y</strong> - the y coordinate of the first control point</li>
940945
<li><strong>cp2x</strong> - the x coordinate of the second control point</li>
941946
<li><strong>cp2y</strong> - the y coordinate of the second control point</li>
942947
<li><strong>x</strong> - the x coordinate of the end point</li>
943948
<li><strong>y</strong> - the y coordinate of the end point</li>
944-
</ui>
949+
</ul>
945950
</td>
946951
<td><code>// draws a red Bézier curve starting at (20, 25) and ending at (40, 50)
947952
```
@@ -964,12 +969,12 @@ commit
964969
965970
<tr>
966971
<td>
967-
<ui>
972+
<ul>
968973
<li><strong>cpx</strong> - the x coordinate of the control point</li>
969974
<li><strong>cpy</strong> - the y coordinate of the control point</li>
970975
<li><strong>y</strong> - the x coordinate of the end point</li>
971976
<li><strong>y</strong> - the y coordinate of the end point</li>
972-
</ui>
977+
</ul>
973978
</td>
974979
<td><code></code>
975980
</td>
@@ -985,14 +990,14 @@ commit
985990
986991
<tr>
987992
<td>
988-
<ui>
993+
<ul>
989994
<li><strong>y</strong> - the x coordinate of the center of the curve</li>
990995
<li><strong>y</strong> - the y coordinate of the center of the curve</li>
991996
<li><strong>radius</strong> - the radius of the curve in pixels</li>
992997
<li><strong>startAngle</strong> - the starting angle of the curve in radians</li>
993998
<li><strong>endAngle</strong> - the ending angle of the curve in radians</li>
994999
<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>
9961001
</td>
9971002
<td><code>// draws an arc that circumscribes ¾ of a 40 pixel-wide circle in the middle of the canvas
9981003
```
@@ -1014,13 +1019,13 @@ commit
10141019
10151020
<tr>
10161021
<td>
1017-
<ui>
1022+
<ul>
10181023
<li><strong>x1</strong> - the x coordinate of the starting point of the curve</li>
10191024
<li><strong>y1</strong> - the y coordinate of the starting point of the curve</li>
10201025
<li><strong>x2</strong> - the x coordinate of the ending point of the curve</li>
10211026
<li><strong>y2</strong> - the y coordinate of the ending point of the curve</li>
10221027
<li>radius - the radius of the curve in pixels</li>
1023-
</ui>
1028+
</ul>
10241029
</td>
10251030
<td><code>// draws an arc that connects two perpendicular lines with a circular curve
10261031
```
@@ -1044,7 +1049,7 @@ commit
10441049
10451050
<tr>
10461051
<td>
1047-
<ui>
1052+
<ul>
10481053
<li><strong>y</strong> - the x coordinate of the center of the curve</li>
10491054
<li><strong>y</strong> - the y coordinate of the center of the curve</li>
10501055
<li><strong>radiusX</strong> - the horizontal radius of the curve</li>
@@ -1053,7 +1058,7 @@ commit
10531058
<li><strong>startAngle</strong> - the starting angle of the curve in radians</li>
10541059
<li><strong>endAngle</strong> - the ending angle of the curve in radians</li>
10551060
<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>
10571062
</td>
10581063
<td><code>// draws a green oval in the center of the canvas that is 20 pixels wide and 30 pixels high
10591064
```
@@ -1075,12 +1080,12 @@ commit
10751080
10761081
<tr>
10771082
<td>
1078-
<ui>
1083+
<ul>
10791084
<li><strong>y</strong> - the x coordinate of the upper left corner of the rectangle</li>
10801085
<li><strong>y</strong> - the y coordinate of the upper left corner of the rectangle</li>
10811086
<li><strong>width</strong> - the width of the rectangle in pixels</li>
10821087
<li><strong>height</strong> - the height of the rectangle in pixels</li>
1083-
</ui>
1088+
</ul>
10841089
</td>
10851090
<td><code>// draws a blue square with black borders in the middle of the canvas
10861091
```
@@ -1102,9 +1107,9 @@ commit
11021107
11031108
<tr>
11041109
<td>
1105-
<ui>
1110+
<ul>
11061111
<li>No arguments</li>
1107-
</ui>
1112+
</ul>
11081113
</td>
11091114
<td><code>// returns the path to (10, 10) from (20, 40) to create a triangle
11101115
```
@@ -1135,7 +1140,7 @@ The UI library provides a shorthand for adding standard HTML elements, as well a
11351140
11361141
<tr>
11371142
<td>
1138-
<ui>
1143+
<ul>
11391144
<li>the <code>#ui</code> tag supports the following html elements:
11401145
<ul>
11411146
<li><code>#ui/row</code></li>
@@ -1162,7 +1167,7 @@ The UI library provides a shorthand for adding standard HTML elements, as well a
11621167
<li><strong>#</strong> - (optional) - any other tags on the record will be applied to the element as classes</li>
11631168
<li><strong>class</strong> - (optional) defines one or more classes for the element</li>
11641169
<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>
11661171
</td>
11671172
<td><code>// commits a div in the browser with the text “Hello world!”
11681173
```
@@ -1182,14 +1187,14 @@ commit
11821187
11831188
<tr>
11841189
<td>
1185-
<ui>
1190+
<ul>
11861191
<li><strong>children</strong> - (optional) - the children contained within the column or row</li>
11871192
<li><strong>style</strong> - (optional) - specific CSS styles can be defined, but must be entered as a subrecord</li>
11881193
<li><strong>text</strong> - (optional) - defines text within the column or row</li>
11891194
<li><strong>#</strong> - (optional) - any other tags on the record will be applied to the column or row as classes</li>
11901195
<li><strong>class</strong> - (optional) defines one or more classes for the element</li>
11911196
<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>
11931198
</td>
11941199
<td><code>// creates 3 very wise divs in the browser stacked on top of one another
11951200
```
@@ -1212,7 +1217,7 @@ commit
12121217
12131218
<tr>
12141219
<td>
1215-
<ui>
1220+
<ul>
12161221
<li> - (optional) - preset options for class are:
12171222
<ul>
12181223
<li>“inset” - an inset button style</li>
@@ -1225,7 +1230,7 @@ commit
12251230
<li><strong>text</strong> - (optional) - defines text in the button</li>
12261231
<li><strong>#</strong> - (optional) - any other tags on the record will be applied to the button as classes</li>
12271232
<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>
12291234
</td>
12301235
<td><code></code>
12311236
</td>
@@ -1241,15 +1246,15 @@ commit
12411246
12421247
<tr>
12431248
<td>
1244-
<ui>
1249+
<ul>
12451250
<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>
12461251
<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>
12471252
<li><strong>placeholder</strong> - (optional) - the placeholder text for the input field</li>
12481253
<li><strong>style</strong> - (optional) - specific CSS styles can be defined, but must be entered as a subrecord</li>
12491254
<li><strong>#</strong> - (optional) - any other tags on the record will be applied to the autocomplete as classes</li>
12501255
<li><strong>class</strong> - (optional) defines one or more classes for the autocomplete</li>
12511256
<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>
12531258
</td>
12541259
<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
12551260
```
@@ -1277,9 +1282,9 @@ commit
12771282
12781283
<tr>
12791284
<td>
1280-
<ui>
1285+
<ul>
12811286
<li><strong>autocomplete</strong> - the autocomplete element to clear</li>
1282-
</ui>
1287+
</ul>
12831288
</td>
12841289
<td><code>// clears an autocomplete field if it loses focus
12851290
```
@@ -1303,9 +1308,9 @@ commit
13031308
13041309
<tr>
13051310
<td>
1306-
<ui>
1311+
<ul>
13071312
<li><strong>autocomplete</strong> - the autocomplete being opened</li>
1308-
</ui>
1313+
</ul>
13091314
</td>
13101315
<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
13111316
```
@@ -1330,9 +1335,9 @@ commit
13301335
13311336
<tr>
13321337
<td>
1333-
<ui>
1338+
<ul>
13341339
<li><strong>autocomplete</strong> - the autocomplete being closed</li>
1335-
</ui>
1340+
</ul>
13361341
</td>
13371342
<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
13381343
```
@@ -1357,9 +1362,9 @@ commit
13571362
13581363
<tr>
13591364
<td>
1360-
<ui>
1365+
<ul>
13611366
<li><strong>autocomplete</strong> - the autocomplete being closed</li>
1362-
</ui>
1367+
</ul>
13631368
</td>
13641369
<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
13651370
```
@@ -1384,9 +1389,9 @@ commit
13841389
13851390
<tr>
13861391
<td>
1387-
<ui>
1392+
<ul>
13881393
<li><strong>autocomplete</strong> - the autocomplete whose input field changed</li>
1389-
</ui>
1394+
</ul>
13901395
</td>
13911396
<td><code>// when an autocomplete asking what the magic word is changes to the correct answer, adds the tag #magic-word to the autocomplete
13921397
```
@@ -1400,3 +1405,55 @@ bind
14001405
</td>
14011406
</tr>
14021407
</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
1439+
1440+
```
1441+
commit
1442+
[#system/timer resolution: 1000]
1443+
```
1444+
1445+
Displays the current time
1446+
1447+
```
1448+
search
1449+
[#system/timer hour minute second]
1450+
1451+
bind
1452+
[#ui/text text: "{{hour}}:{{minute}}:{{second}}"]
1453+
```
1454+
</code>
1455+
</td>
1456+
</tr>
1457+
</table>
1458+
1459+
{% endraw %}

0 commit comments

Comments
 (0)