Update
This commit is contained in:
parent
f8f8212357
commit
997653632f
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,18 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Syndicate: SVG</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script src="../../third-party/jquery-2.2.0.min.js"></script>
|
||||
<script src="../../dist/syndicatecompiler.js"></script>
|
||||
<script src="../../dist/syndicate.js"></script>
|
||||
<script type="text/syndicate-js" src="index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SVG example</h1>
|
||||
<p>After the example in <a href="http://elm-lang.org/blog/farewell-to-frp">this Elm post</a>.</p>
|
||||
<p>Source code: <a href="index.js">index.js</a></p>
|
||||
<div id="clock"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,35 @@
|
|||
var DOM = Syndicate.DOM.DOM;
|
||||
var jQueryEvent = Syndicate.JQuery.jQueryEvent;
|
||||
|
||||
assertion type time(value);
|
||||
|
||||
$(document).ready(function () {
|
||||
ground dataspace G {
|
||||
Syndicate.JQuery.spawnJQueryDriver();
|
||||
Syndicate.DOM.spawnDOMDriver();
|
||||
|
||||
actor {
|
||||
setInterval(Syndicate.Dataspace.wrap(function () {
|
||||
:: time(+(new Date()));
|
||||
}), 1000);
|
||||
|
||||
forever {
|
||||
on message time($now) {
|
||||
this.angle = (((now / 1000) % 60) / 60) * 2 * Math.PI;
|
||||
this.handX = 50 + 40 * Math.cos(this.angle);
|
||||
this.handY = 50 + 40 * Math.sin(this.angle);
|
||||
}
|
||||
assert DOM('#clock', 'clock', Syndicate.seal(
|
||||
["svg", [["xmlns", "http://www.w3.org/2000/svg"],
|
||||
["width", "300px"],
|
||||
["viewBox", "0 0 100 100"]],
|
||||
["circle", [["fill", "#0B79CE"],
|
||||
["r", 45], ["cx", 50], ["cy", 50]]],
|
||||
["line", [["stroke", "#023963"],
|
||||
["x1", 50], ["y1", 50],
|
||||
["x2", this.handX], ["y2", this.handY]]]]))
|
||||
when (typeof this.angle === 'number');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue