Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

chippy demo

  • Loading branch information...
commit 8d97571588d3e74666a7a9204443eacafca1b7b6 1 parent 0e63328
@zot authored
View
9 TODO.html
@@ -27,6 +27,11 @@
<h1>TODO</h1>
<ul>
+<li>chippy demo
+<ul>
+<li>pan/zoom</li>
+<li>Leisure-based mouse controls -- rotate rock with arrow keys</li>
+</ul></li>
<li>notebook
<ul>
<li>use file system api
@@ -38,6 +43,10 @@
<li>"save-as" saves the web page</li>
</ul></li>
<li>incremental compilation (automatically recompile and update all errors)</li>
+<li>function preconditions
+<ul>
+<li>"make precondition" button</li>
+</ul></li>
<li>run test cases button
<ul>
<li>checkbox to run all tests on successful auto-build</li>
View
5 TODO.md
@@ -6,6 +6,9 @@
* build should preserve outputs
# TODO
+* chippy demo
+ * pan/zoom
+ * Leisure-based mouse controls -- rotate rock with arrow keys
* notebook
* use file system api
* each webpage is a whole project and gets its own directory on the file system
@@ -14,6 +17,8 @@
* use FS for autosave
* "save-as" saves the web page
* incremental compilation (automatically recompile and update all errors)
+ * function preconditions
+ * "make precondition" button
* run test cases button
* checkbox to run all tests on successful auto-build
* auto build should clear tests on a recompile
View
20 bootLeisure.cs
@@ -6,15 +6,15 @@
bootLeisure = ->
body = document.body
- if (body.getAttribute 'leisurecode')?
- pre = document.createElement 'pre'
- pre.setAttribute 'leisurecode', ''
- pre.setAttribute 'contentEditable', 'true'
- pre.innerHTML = body.innerHTML
- while body.firstChild
- body.removeChild body.firstChild
- body.appendChild pre
- body.removeAttribute 'leisurecode'
+ # if (body.getAttribute 'leisurecode')?
+ # pre = document.createElement 'pre'
+ # pre.setAttribute 'leisurecode', ''
+ # pre.setAttribute 'contentEditable', 'true'
+ # pre.innerHTML = body.innerHTML
+ # while body.firstChild
+ # body.removeChild body.firstChild
+ # body.appendChild pre
+ # body.removeAttribute 'leisurecode'
window.removeEventListener 'load', bootLeisure
for i in ['leisure', 'gaudy', 'thin', 'cthulhu' ]
style = document.createElement('link')
@@ -25,7 +25,9 @@ body.appendChild pre
loadThen ['leisure', 'prim', 'pretty', 'replCore', 'browserRepl', 'std', 'notebook', 'jquery-1.7.2.min'], ->
Repl.init()
for node in document.querySelectorAll "[leisurecode]"
+ node.setAttribute 'contentEditable', 'true'
Notebook.bindNotebook node
+ Notebook.changeTheme node, 'thin'
Notebook.evalDoc node
loadThen = (files, cont, index)->
View
15 bootLeisure.js
@@ -9,19 +9,8 @@
Leisure = {};
bootLeisure = function bootLeisure() {
- var body, i, pre, style, _i, _len, _ref;
+ var body, i, style, _i, _len, _ref;
body = document.body;
- if ((body.getAttribute('leisurecode')) != null) {
- pre = document.createElement('pre');
- pre.setAttribute('leisurecode', '');
- pre.setAttribute('contentEditable', 'true');
- pre.innerHTML = body.innerHTML;
- while (body.firstChild) {
- body.removeChild(body.firstChild);
- }
- body.appendChild(pre);
- body.removeAttribute('leisurecode');
- }
window.removeEventListener('load', bootLeisure);
_ref = ['leisure', 'gaudy', 'thin', 'cthulhu'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -39,7 +28,9 @@
_results = [];
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
node = _ref2[_j];
+ node.setAttribute('contentEditable', 'true');
Notebook.bindNotebook(node);
+ Notebook.changeTheme(node, 'thin');
_results.push(Notebook.evalDoc(node));
}
return _results;
View
4 build
@@ -1,5 +1,7 @@
#!/bin/sh
-node_modules/coffee-script/bin/coffee -c leisure.cs prim.cs
+node_modules/coffee-script/bin/coffee -c leisure.cs prim.cs game.cs
node_modules/coffee-script/bin/coffee -c repl.cs runRepl.cs testLeisure.cs replCore.cs browserRepl.cs pretty.cs testing.cs bootLeisure.cs notebook.cs
node runRepl -q -c -b std
node testLeisure
+#node runRepl -q -c parseAst
+node_modules/coffee-script/bin/coffee -c chippy.cs
View
31 chippy.cs
@@ -1,6 +1,7 @@
window.Chippy = root = {}
-snake = null
+doc = null
+boulder = null
space = null
v = cp.v
@@ -8,8 +9,8 @@
# if you want to reuse SVG shapes, use the "use" element
class PolyThing
constructor: (name, @mass)->
- @svg = document.getElementById(name)
- skel = document.getElementById "#{name}-skeleton"
+ @svg = doc.getElementById(name)
+ skel = doc.getElementById "#{name}-skeleton"
bbox = skel.getBBox()
@midx = bbox.x + bbox.width / 2
@midy = bbox.y + bbox.height / 2
@@ -30,7 +31,7 @@ class PolyThing
# if you want to reuse SVG shapes, use the "use" element
class GroundThing
constructor: (name)->
- skel = document.getElementById "#{name}-skeleton"
+ skel = doc.getElementById "#{name}-skeleton"
pts = (getPoints skel, 0, 0)
@body = space.staticBody
@body.setPos v(0, 0)
@@ -46,13 +47,14 @@ s.setElasticity e
for s in @shapes
s.setFriction f
-initChippy = ->
- space = new cp.Space();
+initChippy = (document)->
+ doc = document
+ space = new cp.Space()
space.gravity = v 0, 230
- snake = new PolyThing 'boulder', 200
- snake.setElasticity 1.2
- snake.setFriction 2
- snake.setAngVel 7
+ root.boulder = boulder = new PolyThing 'boulder', 200
+ boulder.setElasticity 1.4
+ boulder.setFriction 0.3
+ boulder.setAngVel 10
ground = new GroundThing 'ground'
ground.setElasticity 0.6
ground.setFriction 1
@@ -71,10 +73,17 @@ ground.setFriction 1
if crds.length == 2
lastx += Number(crds[0])
lasty += Number(crds[1])
+ # use unshift to make the widing right
pts.unshift lastx - midx, lasty - midy
console.log ""
pts
+svgTransform = (svg, x, y)->
+ if !pt? then pt = svg.createSVGPoint()
+ pt.x = x
+ pt.y = y
+ pt.matrixTransform(svg.getCTM())
+
lastStep = Date.now()
remainder = null
resized = true
@@ -120,3 +129,5 @@ ground.setFriction 1
root.initChippy = initChippy
root.run = run
+root.svgTransform = svgTransform
+root.boulder = boulder
View
343 chippy.html
@@ -2,310 +2,45 @@
<head>
<script src="cp.js"></script>
<script src="chippy.js"></script>
+<script src="game.js"></script>
+<script src="bootLeisure.js"></script>
+<script>
+var LEFT_ARROW = 37
+var UP_ARROW = 38
+var RIGHT_ARROW = 39
+var DOWN_ARROW = 40
+
+function initChippy(svg) {
+ var doc = svg.getSVGDocument();
+ var win = doc.defaultView;
+ win.leisureEvent = function(funcName) {Prim.leisureEvent(funcName, win.event);}
+ Chippy.initChippy(doc);
+ Chippy.run();
+ Game.bindSvgDiv(document.getElementById('floop'), keyFunc)
+ //win.leisureEvent('newGame');
+}
+function keyFunc(e) {
+ c = (e.charCode || e.keyCode || e.which)
+ switch (c) {
+ case LEFT_ARROW:
+ Chippy.boulder.body.w -= 0.5
+ break;
+ case RIGHT_ARROW:
+ Chippy.boulder.body.w += 0.5
+ break
+ }
+}
+</script>
</head>
-<body onload="Chippy.initChippy(); Chippy.run()">
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="1024px"
- height="768px"
- id="svg5442"
- version="1.1"
- inkscape:version="0.48.2 r9819"
- sodipodi:docname="map.svg">
- <defs
- id="defs5444">
- <linearGradient
- gradientUnits="userSpaceOnUse"
- y2="644.60358"
- x2="405.17242"
- y1="358.39667"
- x1="183.6207"
- id="linearGradient4900"
- xlink:href="#linearGradient4894"
- inkscape:collect="always" />
- <linearGradient
- id="linearGradient4894">
- <stop
- id="stop4896"
- offset="0"
- style="stop-color:#7f6565;stop-opacity:1" />
- <stop
- id="stop4898"
- offset="1"
- style="stop-color:#392626;stop-opacity:1" />
- </linearGradient>
- <linearGradient
- gradientUnits="userSpaceOnUse"
- y2="208.51062"
- x2="247.87233"
- y1="605.31915"
- x1="252.12766"
- id="linearGradient4930"
- xlink:href="#linearGradient4924"
- inkscape:collect="always" />
- <linearGradient
- id="linearGradient4924">
- <stop
- style="stop-color:#4f2521;stop-opacity:1"
- offset="0"
- id="stop5440" />
- <stop
- id="stop4928"
- offset="1"
- style="stop-color:#338333;stop-opacity:1" />
- </linearGradient>
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4924"
- id="linearGradient4827"
- gradientUnits="userSpaceOnUse"
- x1="252.12766"
- y1="605.31915"
- x2="247.87233"
- y2="208.51062" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4924"
- id="linearGradient4830"
- gradientUnits="userSpaceOnUse"
- x1="252.12766"
- y1="605.31915"
- x2="247.87233"
- y2="208.51062" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4924"
- id="linearGradient4833"
- gradientUnits="userSpaceOnUse"
- x1="252.12766"
- y1="605.31915"
- x2="247.87233"
- y2="208.51062" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4924"
- id="linearGradient4836"
- gradientUnits="userSpaceOnUse"
- x1="252.12766"
- y1="605.31915"
- x2="247.87233"
- y2="208.51062"
- gradientTransform="matrix(1.2835854,0,0,1,0.64745998,166.2276)" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4924"
- id="linearGradient4839"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(1.2835854,0,0,1,0.64745998,166.2276)"
- x1="252.12766"
- y1="605.31915"
- x2="247.87233"
- y2="208.51062" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4894"
- id="linearGradient4842"
- gradientUnits="userSpaceOnUse"
- x1="183.6207"
- y1="358.39667"
- x2="405.17242"
- y2="644.60358" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4894"
- id="linearGradient4855"
- gradientUnits="userSpaceOnUse"
- x1="183.6207"
- y1="358.39667"
- x2="405.17242"
- y2="644.60358"
- gradientTransform="matrix(0.25467235,0,0,0.25644276,-10.766548,68.951446)" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4894"
- id="linearGradient4865"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.25467235,0,0,0.25644276,-10.766548,68.951446)"
- x1="183.6207"
- y1="358.39667"
- x2="405.17242"
- y2="644.60358" />
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4894"
- id="linearGradient4873"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.25467235,0,0,0.25644276,-10.766548,68.951446)"
- x1="186.20399"
- y1="345.56934"
- x2="381.92273"
- y2="615.10077" />
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="0.76"
- inkscape:cx="307.09109"
- inkscape:cy="363.01608"
- inkscape:current-layer="layer1"
- inkscape:document-units="px"
- showgrid="false"
- inkscape:window-width="1918"
- inkscape:window-height="1051"
- inkscape:window-x="0"
- inkscape:window-y="27"
- inkscape:window-maximized="0" />
- <metadata
- id="metadata5447">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- id="layer1"
- inkscape:label="Layer 1"
- inkscape:groupmode="layer">
- <g
- id="boulder"
- inkscape:label="#g4875">
- <path
- sodipodi:nodetypes="ccccccccc"
- style="fill:url(#linearGradient4873);fill-opacity:1;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 36.395455,166.74454 25.949618,-3.99797 18.516002,6.43909 7.97784,18.18078 -5.253626,27.20735 -31.360941,7.36385 -25.049791,-11.54553 -4.171358,-25.7408 z"
- id="boulder-skeleton"
- inkscape:connector-curvature="0" />
- <path
- style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 34.020659,187.60931 c -3.2247,3.67937 -5.990533,9.12148 -3.766673,13.99135 1.003475,2.12441 3.60657,3.0489 5.742579,2.14686"
- id="path4902"
- inkscape:connector-curvature="0" />
- <path
- style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 48.291091,211.48501 c 2.153281,3.9685 6.722462,7.94469 11.483663,6.15936 4.407515,-1.4379 5.390927,-7.02494 9.788202,-8.44606 2.601796,-0.61829 7.402001,-0.69112 5.658005,-4.77981 -0.316074,-1.35762 -0.770761,-2.67793 -1.243089,-3.98705"
- id="path4904"
- inkscape:connector-curvature="0" />
- <path
- style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 57.951076,183.18788 c -3.01377,0.24541 -6.936305,0.67506 -8.39953,3.76264 -1.088805,3.56277 3.038539,5.42686 4.235683,8.23102 1.572324,2.13481 -0.256364,7.72217 3.558379,7.22649 1.151292,-0.33849 2.206012,-0.9364 3.240013,-1.53444"
- id="path4906"
- inkscape:connector-curvature="0" />
- <path
- style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 61.4638,175.00824 c 0.360458,-4.3506 6.333594,-3.9136 8.820215,-1.69229 3.071488,2.18771 3.854298,6.39614 2.815675,9.87193"
- id="path4908"
- inkscape:connector-curvature="0" />
- <path
- style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 33.581568,180.53502 c -1.640161,-4.82297 5.110701,-3.82603 7.819513,-3.28658 2.728099,0.82679 6.66368,0.72482 5.241078,-3.19065 -0.132646,-3.7013 2.565597,-7.28705 6.340392,-7.60384 0.915998,-0.13974 1.851679,-0.173 2.773076,-0.0675"
- id="path4910"
- inkscape:connector-curvature="0" />
- </g>
- <path
- style="fill:url(#linearGradient4839);fill-opacity:1;stroke:#000000;stroke-width:1.13295424px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 0.50401247,483.34972 135.11094753,32.72292 121.64836,-52.61816 90.01616,166.2308 177.53604,-73.30952 70.75812,-17.76415 86.38372,-109.6609 192.87504,23.17132 151.6123,-71.0121 2.1412,386.98011 -1029.6818612,2.5895 z"
- id="ground-skeleton"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cccccccccccc" />
- <g
- id="snake"
- inkscape:label="Layer 1"
- transform="matrix(0.16354665,0,0,0.17294153,642.67124,68.363334)">
- <path
- style="fill:#c400cd;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 369.40693,457.13023 C 343.45846,398.2563 280.47783,321.77751 118.76428,193.95883 418.08327,341.75668 737.89259,499.0248 737.89259,499.0248 c 0,0 -224.17779,-49.19018 -343.12803,-27.09185 z"
- id="path3770"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccc" />
- <g
- style="stroke:#000000;stroke-width:3;stroke-opacity:1"
- transform="translate(-39.306358,24.855491)"
- inkscape:transform-center-y="-26.589595"
- inkscape:transform-center-x="-38.728324"
- id="g3988">
- <path
- transform="matrix(0.70710678,-0.70710679,0.70710679,0.70710678,-408.73234,-82.896217)"
- d="m -87.644779,606.22321 c 0,16.31265 -19.533521,29.53668 -43.629341,29.53668 -24.09583,0 -43.62935,-13.22403 -43.62935,-29.53668 0,-16.31266 19.53352,-29.53668 43.62935,-29.53668 24.09582,0 43.629341,13.22402 43.629341,29.53668 z"
- sodipodi:ry="29.53668"
- sodipodi:rx="43.629345"
- sodipodi:cy="606.22321"
- sodipodi:cx="-131.27412"
- id="path3990"
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- sodipodi:type="arc" />
- <path
- sodipodi:nodetypes="czcc"
- inkscape:connector-curvature="0"
- id="path3992"
- d="M 58.562409,479.98343 C 74.636675,459.32822 93.172749,432.2897 95.93017,413.27112 98.687588,394.25255 91.634674,358.94769 59.022885,344.34816 20.969383,333.8184 -28.256972,376.94496 -42.551153,407.84758"
- style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
- <path
- inkscape:connector-curvature="0"
- id="path3994"
- d="m -90.938914,442.32357 c 12.74131,15.05792 12.74131,15.05792 12.74131,15.05792"
- style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
- </g>
- <path
- sodipodi:nodetypes="cscssssssssssscsccccccccccccc"
- inkscape:connector-curvature="0"
- id="path2989"
- d="M -0.83232693,600.93431 C -14.72122,585.19357 -39.637889,509.85955 49.07407,456.99181 c 71.5406,-42.6345 101.07573,-9.03385 120.78007,17.00262 55.69831,-44.91411 127.92399,-82.24386 205.14586,-73.4841 35.94416,4.07737 82.1662,34.27483 87.97852,77.06972 8.54761,62.93423 -13.04855,83.16215 -44.53003,116.49549 -45.98224,48.68709 -72.27669,57.74976 -111.57796,113.90445 -36.04005,51.49497 -41.77795,81.16262 -41.6122,120.23809 0.35947,84.74463 60.71428,173.86402 59.78836,173.86402 -0.51576,0 -56.42937,-30.06459 -88.07493,-83.82623 -25.16661,-42.75476 -27.881,-107.60064 -26.17189,-133.23729 4.62964,-69.44445 30.75787,-95.98506 68.87644,-142.88048 33.89389,-41.69799 112.70676,-117.99838 88.78774,-150.80144 -24.19049,-33.17536 -67.84502,-33.99292 -111.0619,-9.47035 -34.94478,19.82873 -39.84896,23.82441 -56.71963,36.86244 40.09471,53.49212 -28.60401,102.79241 -44.5311,115.69939 C 69.469378,704.67347 23.360256,639.81353 9.1522195,617.30991 35.997716,613.30342 77.159302,607.81112 77.159302,607.81112 l -3.839974,-23.64066 40.569562,8.93246 -8.33333,-39.81481 48.80174,8.60567 -43.24619,-78.05012 6.48148,48.14816 -37.037034,-11.11112 10.185185,47.22222 -37.962964,-2.77777 1.101537,27.04115 z"
- style="fill:#007700;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
- <path
- sodipodi:nodetypes="cc"
- inkscape:connector-curvature="0"
- id="path2991"
- d="m 32.773109,477.57227 c 10.560982,23.57483 37.656144,29.23007 57.983194,0"
- style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
- <g
- style="stroke:#000000;stroke-width:3;stroke-opacity:1"
- id="g3983">
- <path
- sodipodi:type="arc"
- style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- id="path3981"
- sodipodi:cx="-131.27412"
- sodipodi:cy="606.22321"
- sodipodi:rx="43.629345"
- sodipodi:ry="29.53668"
- d="m -87.644779,606.22321 c 0,16.31265 -19.533521,29.53668 -43.629341,29.53668 -24.09583,0 -43.62935,-13.22403 -43.62935,-29.53668 0,-16.31266 19.53352,-29.53668 43.62935,-29.53668 24.09582,0 43.629341,13.22402 43.629341,29.53668 z"
- transform="matrix(0.70710678,-0.70710679,0.70710679,0.70710678,-408.73234,-82.896217)" />
- <path
- style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 58.562409,479.98343 C 74.636675,459.32822 93.172749,432.2897 95.93017,413.27112 98.687588,394.25255 91.634674,358.94769 59.022885,344.34816 20.969383,333.8184 -28.256972,376.94496 -42.551153,407.84758"
- id="path2993"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="czcc" />
- <path
- style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m -90.938914,442.32357 c 12.74131,15.05792 12.74131,15.05792 12.74131,15.05792"
- id="path3979"
- inkscape:connector-curvature="0" />
- </g>
- <path
- sodipodi:nodetypes="ccccc"
- inkscape:connector-curvature="0"
- id="path3000"
- d="M 387.86127,431.55293 C 378.03467,367.96912 336.99422,277.7957 213.87283,112.47779 464.73988,332.709 732.94798,567.39108 732.94798,567.39108 c 0,0 -203.80777,-105.53554 -324.42434,-114.97678 z"
- style="fill:#c400cd;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
- </g>
- </g>
-</svg>
+<body>
+ <table style="width: 100%; height: 100%">
+ <tr style="height: 100%"><td style="width: 0; vertical-align: top">
+ <div id="floop" tabindex="0" style="display: inline" onmousedown="this.focus()">
+ <object data="map2.svg" type="image/svg+xml" width="512" height="384" onload="initChippy(this)"></object>
+ </div>
+ </td>
+ <td style="width: 100%"><pre leisureCode style="height: 100%"></pre></td>
+ </tr>
+ </table>
</body>
</html>
View
35 chippy.js
@@ -1,9 +1,11 @@
(function() {
- var GroundThing, PolyThing, draw, fps, getPoints, initChippy, lastStep, remainder, requestAnimationFrame, resized, root, run, running, snake, space, step, update, v;
+ var GroundThing, PolyThing, boulder, doc, draw, fps, getPoints, initChippy, lastStep, remainder, requestAnimationFrame, resized, root, run, running, space, step, svgTransform, update, v;
window.Chippy = root = {};
- snake = null;
+ doc = null;
+
+ boulder = null;
space = null;
@@ -14,8 +16,8 @@
function PolyThing(name, mass) {
var bbox, pts, self, skel;
this.mass = mass;
- this.svg = document.getElementById(name);
- skel = document.getElementById("" + name + "-skeleton");
+ this.svg = doc.getElementById(name);
+ skel = doc.getElementById("" + name + "-skeleton");
bbox = skel.getBBox();
this.midx = bbox.x + bbox.width / 2;
this.midy = bbox.y + bbox.height / 2;
@@ -57,7 +59,7 @@
function GroundThing(name) {
var i, pts, shape, skel, _ref;
- skel = document.getElementById("" + name + "-skeleton");
+ skel = doc.getElementById("" + name + "-skeleton");
pts = getPoints(skel, 0, 0);
this.body = space.staticBody;
this.body.setPos(v(0, 0));
@@ -95,14 +97,15 @@
})();
- initChippy = function initChippy() {
+ initChippy = function initChippy(document) {
var ground;
+ doc = document;
space = new cp.Space();
space.gravity = v(0, 230);
- snake = new PolyThing('boulder', 200);
- snake.setElasticity(1.2);
- snake.setFriction(2);
- snake.setAngVel(7);
+ root.boulder = boulder = new PolyThing('boulder', 200);
+ boulder.setElasticity(1.4);
+ boulder.setFriction(0.3);
+ boulder.setAngVel(10);
ground = new GroundThing('ground');
ground.setElasticity(0.6);
return ground.setFriction(1);
@@ -133,6 +136,14 @@
return pts;
};
+ svgTransform = function svgTransform(svg, x, y) {
+ var pt;
+ if (!(typeof pt !== "undefined" && pt !== null)) pt = svg.createSVGPoint();
+ pt.x = x;
+ pt.y = y;
+ return pt.matrixTransform(svg.getCTM());
+ };
+
lastStep = Date.now();
remainder = null;
@@ -191,4 +202,8 @@
root.run = run;
+ root.svgTransform = svgTransform;
+
+ root.boulder = boulder;
+
}).call(this);
View
295 map.svg
@@ -0,0 +1,295 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="1024px"
+ height="768px"
+ id="svg5442"
+ version="1.1"
+ inkscape:version="0.48.2 r9819"
+ sodipodi:docname="map.svg">
+ <defs
+ id="defs5444">
+ <linearGradient
+ id="linearGradient4894">
+ <stop
+ id="stop4896"
+ offset="0"
+ style="stop-color:#7f6565;stop-opacity:1" />
+ <stop
+ id="stop4898"
+ offset="1"
+ style="stop-color:#392626;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient4924">
+ <stop
+ style="stop-color:#4f2521;stop-opacity:1"
+ offset="0"
+ id="stop5440" />
+ <stop
+ id="stop4928"
+ offset="1"
+ style="stop-color:#338333;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4924"
+ id="linearGradient4839"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.2835854,0,0,1,0.64745998,166.2276)"
+ x1="252.12766"
+ y1="605.31915"
+ x2="247.87233"
+ y2="208.51062" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4894"
+ id="linearGradient4873"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.25467235,0,0,0.25644276,-10.766548,68.951446)"
+ x1="186.20399"
+ y1="345.56934"
+ x2="381.92273"
+ y2="615.10077" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4894"
+ id="linearGradient4889"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.25467235,0,0,0.25644276,283.97029,293.95145)"
+ x1="186.20399"
+ y1="345.56934"
+ x2="381.92273"
+ y2="615.10077" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.53740115"
+ inkscape:cx="425.32899"
+ inkscape:cy="-101.19685"
+ inkscape:current-layer="layer1"
+ inkscape:document-units="px"
+ showgrid="false"
+ inkscape:window-width="1918"
+ inkscape:window-height="1049"
+ inkscape:window-x="0"
+ inkscape:window-y="149"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata5447">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ style="display:inline">
+ <path
+ style="fill:url(#linearGradient4839);fill-opacity:1;stroke:#000000;stroke-width:1.13295424px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 0.50401247,483.34972 135.11094753,32.72292 121.64836,-52.61816 90.01616,166.2308 177.53604,-73.30952 70.75812,-17.76415 86.38372,-109.6609 192.87504,23.17132 151.6123,-71.0121 2.1412,386.98011 -1029.6818612,2.5895 z"
+ id="ground-skeleton"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccccccc" />
+ <g
+ id="snake"
+ inkscape:label="Layer 1"
+ transform="matrix(0.16354665,0,0,0.17294153,642.67124,68.363334)">
+ <path
+ style="fill:#c400cd;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 369.40693,457.13023 C 343.45846,398.2563 280.47783,321.77751 118.76428,193.95883 418.08327,341.75668 737.89259,499.0248 737.89259,499.0248 c 0,0 -224.17779,-49.19018 -343.12803,-27.09185 z"
+ id="path3770"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc" />
+ <g
+ style="stroke:#000000;stroke-width:3;stroke-opacity:1"
+ transform="translate(-39.306358,24.855491)"
+ inkscape:transform-center-y="-26.589595"
+ inkscape:transform-center-x="-38.728324"
+ id="g3988">
+ <path
+ transform="matrix(0.70710678,-0.70710679,0.70710679,0.70710678,-408.73234,-82.896217)"
+ d="m -87.644779,606.22321 c 0,16.31265 -19.533521,29.53668 -43.629341,29.53668 -24.09583,0 -43.62935,-13.22403 -43.62935,-29.53668 0,-16.31266 19.53352,-29.53668 43.62935,-29.53668 24.09582,0 43.629341,13.22402 43.629341,29.53668 z"
+ sodipodi:ry="29.53668"
+ sodipodi:rx="43.629345"
+ sodipodi:cy="606.22321"
+ sodipodi:cx="-131.27412"
+ id="path3990"
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:nodetypes="czcc"
+ inkscape:connector-curvature="0"
+ id="path3992"
+ d="M 58.562409,479.98343 C 74.636675,459.32822 93.172749,432.2897 95.93017,413.27112 98.687588,394.25255 91.634674,358.94769 59.022885,344.34816 20.969383,333.8184 -28.256972,376.94496 -42.551153,407.84758"
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3994"
+ d="m -90.938914,442.32357 c 12.74131,15.05792 12.74131,15.05792 12.74131,15.05792"
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+ <path
+ sodipodi:nodetypes="cscssssssssssscsccccccccccccc"
+ inkscape:connector-curvature="0"
+ id="path2989"
+ d="M -0.83232693,600.93431 C -14.72122,585.19357 -39.637889,509.85955 49.07407,456.99181 c 71.5406,-42.6345 101.07573,-9.03385 120.78007,17.00262 55.69831,-44.91411 127.92399,-82.24386 205.14586,-73.4841 35.94416,4.07737 82.1662,34.27483 87.97852,77.06972 8.54761,62.93423 -13.04855,83.16215 -44.53003,116.49549 -45.98224,48.68709 -72.27669,57.74976 -111.57796,113.90445 -36.04005,51.49497 -41.77795,81.16262 -41.6122,120.23809 0.35947,84.74463 60.71428,173.86402 59.78836,173.86402 -0.51576,0 -56.42937,-30.06459 -88.07493,-83.82623 -25.16661,-42.75476 -27.881,-107.60064 -26.17189,-133.23729 4.62964,-69.44445 30.75787,-95.98506 68.87644,-142.88048 33.89389,-41.69799 112.70676,-117.99838 88.78774,-150.80144 -24.19049,-33.17536 -67.84502,-33.99292 -111.0619,-9.47035 -34.94478,19.82873 -39.84896,23.82441 -56.71963,36.86244 40.09471,53.49212 -28.60401,102.79241 -44.5311,115.69939 C 69.469378,704.67347 23.360256,639.81353 9.1522195,617.30991 35.997716,613.30342 77.159302,607.81112 77.159302,607.81112 l -3.839974,-23.64066 40.569562,8.93246 -8.33333,-39.81481 48.80174,8.60567 -43.24619,-78.05012 6.48148,48.14816 -37.037034,-11.11112 10.185185,47.22222 -37.962964,-2.77777 1.101537,27.04115 z"
+ style="fill:#007700;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path2991"
+ d="m 32.773109,477.57227 c 10.560982,23.57483 37.656144,29.23007 57.983194,0"
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <g
+ style="stroke:#000000;stroke-width:3;stroke-opacity:1"
+ id="g3983">
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path3981"
+ sodipodi:cx="-131.27412"
+ sodipodi:cy="606.22321"
+ sodipodi:rx="43.629345"
+ sodipodi:ry="29.53668"
+ d="m -87.644779,606.22321 c 0,16.31265 -19.533521,29.53668 -43.629341,29.53668 -24.09583,0 -43.62935,-13.22403 -43.62935,-29.53668 0,-16.31266 19.53352,-29.53668 43.62935,-29.53668 24.09582,0 43.629341,13.22402 43.629341,29.53668 z"
+ transform="matrix(0.70710678,-0.70710679,0.70710679,0.70710678,-408.73234,-82.896217)" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 58.562409,479.98343 C 74.636675,459.32822 93.172749,432.2897 95.93017,413.27112 98.687588,394.25255 91.634674,358.94769 59.022885,344.34816 20.969383,333.8184 -28.256972,376.94496 -42.551153,407.84758"
+ id="path2993"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="czcc" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m -90.938914,442.32357 c 12.74131,15.05792 12.74131,15.05792 12.74131,15.05792"
+ id="path3979"
+ inkscape:connector-curvature="0" />
+ </g>
+ <path
+ sodipodi:nodetypes="ccccc"
+ inkscape:connector-curvature="0"
+ id="path3000"
+ d="M 387.86127,431.55293 C 378.03467,367.96912 336.99422,277.7957 213.87283,112.47779 464.73988,332.709 732.94798,567.39108 732.94798,567.39108 c 0,0 -203.80777,-105.53554 -324.42434,-114.97678 z"
+ style="fill:#c400cd;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+ <use
+ x="0"
+ y="0"
+ xlink:href="#boulder1"
+ id="use3047" />
+ </g>
+ <g
+ inkscape:groupmode="layer"
+ id="layer3"
+ inkscape:label="Hidden"
+ style="display:none">
+ <g
+ id="boulder1"
+ inkscape:label="#g4891">
+ <path
+ sodipodi:nodetypes="ccccccccc"
+ style="fill:url(#linearGradient4889);fill-opacity:1;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 331.13229,391.74454 25.94962,-3.99797 18.516,6.43909 7.97784,18.18078 -5.25362,27.20735 -31.36094,7.36385 -25.04979,-11.54553 -4.17136,-25.7408 z"
+ id="boulder-skeleton"
+ inkscape:connector-curvature="0">
+ <animate
+ attributeName="fill"
+ values="#f88; #8f8; #88f"
+ calcMode="discrete"
+ dur="2s"
+ repeatCount="indefinite"
+ id="animate3072" />
+ </path>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 328.7575,412.60931 c -3.2247,3.67937 -5.99053,9.12148 -3.76667,13.99135 1.00347,2.12441 3.60657,3.0489 5.74257,2.14686"
+ id="path4902"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 343.02793,436.48501 c 2.15328,3.9685 6.72246,7.94469 11.48366,6.15936 4.40752,-1.4379 5.39093,-7.02494 9.78821,-8.44606 2.60179,-0.61829 7.402,-0.69112 5.658,-4.77981 -0.31607,-1.35762 -0.77076,-2.67793 -1.24309,-3.98705"
+ id="path4904"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 352.68792,408.18788 c -3.01377,0.24541 -6.93631,0.67506 -8.39953,3.76264 -1.08881,3.56277 3.03853,5.42686 4.23568,8.23102 1.57232,2.13481 -0.25637,7.72217 3.55838,7.22649 1.15129,-0.33849 2.20601,-0.9364 3.24001,-1.53444"
+ id="path4906"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 356.20064,400.00824 c 0.36046,-4.3506 6.33359,-3.9136 8.82021,-1.69229 3.07149,2.18771 3.8543,6.39614 2.81568,9.87193"
+ id="path4908"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 328.31841,405.53502 c -1.64016,-4.82297 5.1107,-3.82603 7.81951,-3.28658 2.7281,0.82679 6.66368,0.72482 5.24108,-3.19065 -0.13265,-3.7013 2.5656,-7.28705 6.34039,-7.60384 0.916,-0.13974 1.85168,-0.173 2.77308,-0.0675"
+ id="path4910"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ inkscape:label="#g4891"
+ id="boulder2">
+ <path
+ inkscape:connector-curvature="0"
+ id="path3099"
+ d="m 331.13229,391.74454 25.94962,-3.99797 18.516,6.43909 7.97784,18.18078 -5.25362,27.20735 -31.36094,7.36385 -25.04979,-11.54553 -4.17136,-25.7408 z"
+ style="fill:url(#linearGradient4889);fill-opacity:1;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:nodetypes="ccccccccc">
+ <animate
+ id="animate3101"
+ repeatCount="indefinite"
+ dur="2s"
+ calcMode="discrete"
+ values="#f88; #8f8; #88f"
+ attributeName="fill" />
+ </path>
+ <path
+ inkscape:connector-curvature="0"
+ id="path3103"
+ d="m 338.79039,422.47773 c -3.2247,3.67937 -5.99053,9.12148 -3.76667,13.99135 1.00347,2.12441 3.60657,3.0489 5.74257,2.14686"
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3105"
+ d="m 348.29109,437.30738 c 2.15328,3.9685 6.72246,7.94469 11.48366,6.15936 4.40752,-1.4379 5.39093,-7.02494 9.78821,-8.44606 2.60179,-0.61829 7.402,-0.69112 5.658,-4.77981 -0.31607,-1.35762 -0.77076,-2.67793 -1.24309,-3.98705"
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3107"
+ d="m 359.92476,416.74051 c -3.01377,0.24541 -6.93631,0.67506 -8.39953,3.76264 -1.08881,3.56277 3.03853,5.42686 4.23568,8.23102 1.57232,2.13481 -0.25637,7.72217 3.55838,7.22649 1.15129,-0.33849 2.20601,-0.9364 3.24001,-1.53444"
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3109"
+ d="m 365.57564,408.56087 c 0.36046,-4.3506 6.33359,-3.9136 8.82021,-1.69229 3.07149,2.18771 3.8543,6.39614 2.81568,9.87193"
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3111"
+ d="m 326.01577,422.64028 c -1.64016,-4.82297 5.1107,-3.82603 7.81951,-3.28658 2.7281,0.82679 6.66368,0.72482 5.24108,-3.19065 -0.13265,-3.7013 2.5656,-7.28705 6.34039,-7.60384 0.916,-0.13974 1.85168,-0.173 2.77308,-0.0675"
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+ </g>
+</svg>
View
274 map2.svg
@@ -0,0 +1,274 @@
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ Xwidth="1024px"
+ Xheight="768px"
+ viewBox="0 0 1024 768"
+ XpreserveAspectRatio="none"
+ id="svg5442"
+ version="1.1"
+ inkscape:version="0.48.2 r9819"
+ sodipodi:docname="map.svg">
+ <defs
+ id="defs5444">
+ <linearGradient
+ id="linearGradient4894">
+ <stop
+ id="stop4896"
+ offset="0"
+ style="stop-color:#7f6565;stop-opacity:1" />
+ <stop
+ id="stop4898"
+ offset="1"
+ style="stop-color:#392626;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient4924">
+ <stop
+ style="stop-color:#4f2521;stop-opacity:1"
+ offset="0"
+ id="stop5440" />
+ <stop
+ id="stop4928"
+ offset="1"
+ style="stop-color:#338333;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4924"
+ id="linearGradient4839"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.2835854,0,0,1,0.64745998,166.2276)"
+ x1="252.12766"
+ y1="605.31915"
+ x2="247.87233"
+ y2="208.51062" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4894"
+ id="linearGradient4873"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.25467235,0,0,0.25644276,-10.766548,68.951446)"
+ x1="186.20399"
+ y1="345.56934"
+ x2="381.92273"
+ y2="615.10077" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4894"
+ id="linearGradient4889"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.25467235,0,0,0.25644276,283.97029,293.95145)"
+ x1="186.20399"
+ y1="345.56934"
+ x2="381.92273"
+ y2="615.10077" />
+ <g
+ id="boulder1"
+ inkscape:label="#g4891">
+ <path
+ sodipodi:nodetypes="ccccccccc"
+ style="fill:url(#linearGradient4889);fill-opacity:1;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 331.13229,391.74454 25.94962,-3.99797 18.516,6.43909 7.97784,18.18078 -5.25362,27.20735 -31.36094,7.36385 -25.04979,-11.54553 -4.17136,-25.7408 z"
+ id="boulder-skeleton"
+ inkscape:connector-curvature="0">
+ </path>
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 328.7575,412.60931 c -3.2247,3.67937 -5.99053,9.12148 -3.76667,13.99135 1.00347,2.12441 3.60657,3.0489 5.74257,2.14686"
+ id="path4902"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 343.02793,436.48501 c 2.15328,3.9685 6.72246,7.94469 11.48366,6.15936 4.40752,-1.4379 5.39093,-7.02494 9.78821,-8.44606 2.60179,-0.61829 7.402,-0.69112 5.658,-4.77981 -0.31607,-1.35762 -0.77076,-2.67793 -1.24309,-3.98705"
+ id="path4904"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 352.68792,408.18788 c -3.01377,0.24541 -6.93631,0.67506 -8.39953,3.76264 -1.08881,3.56277 3.03853,5.42686 4.23568,8.23102 1.57232,2.13481 -0.25637,7.72217 3.55838,7.22649 1.15129,-0.33849 2.20601,-0.9364 3.24001,-1.53444"
+ id="path4906"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 356.20064,400.00824 c 0.36046,-4.3506 6.33359,-3.9136 8.82021,-1.69229 3.07149,2.18771 3.8543,6.39614 2.81568,9.87193"
+ id="path4908"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 328.31841,405.53502 c -1.64016,-4.82297 5.1107,-3.82603 7.81951,-3.28658 2.7281,0.82679 6.66368,0.72482 5.24108,-3.19065 -0.13265,-3.7013 2.5656,-7.28705 6.34039,-7.60384 0.916,-0.13974 1.85168,-0.173 2.77308,-0.0675"
+ id="path4910"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ inkscape:label="#g4891"
+ id="boulder2">
+ <path
+ inkscape:connector-curvature="0"
+ id="path3099"
+ d="m 331.13229,391.74454 25.94962,-3.99797 18.516,6.43909 7.97784,18.18078 -5.25362,27.20735 -31.36094,7.36385 -25.04979,-11.54553 -4.17136,-25.7408 z"
+ style="fill:url(#linearGradient4889);fill-opacity:1;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:nodetypes="ccccccccc">
+ </path>
+ <path
+ inkscape:connector-curvature="0"
+ id="path3103"
+ d="m 338.79039,422.47773 c -3.2247,3.67937 -5.99053,9.12148 -3.76667,13.99135 1.00347,2.12441 3.60657,3.0489 5.74257,2.14686"
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3105"
+ d="m 348.29109,437.30738 c 2.15328,3.9685 6.72246,7.94469 11.48366,6.15936 4.40752,-1.4379 5.39093,-7.02494 9.78821,-8.44606 2.60179,-0.61829 7.402,-0.69112 5.658,-4.77981 -0.31607,-1.35762 -0.77076,-2.67793 -1.24309,-3.98705"
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3107"
+ d="m 359.92476,416.74051 c -3.01377,0.24541 -6.93631,0.67506 -8.39953,3.76264 -1.08881,3.56277 3.03853,5.42686 4.23568,8.23102 1.57232,2.13481 -0.25637,7.72217 3.55838,7.22649 1.15129,-0.33849 2.20601,-0.9364 3.24001,-1.53444"
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3109"
+ d="m 365.57564,408.56087 c 0.36046,-4.3506 6.33359,-3.9136 8.82021,-1.69229 3.07149,2.18771 3.8543,6.39614 2.81568,9.87193"
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3111"
+ d="m 326.01577,422.64028 c -1.64016,-4.82297 5.1107,-3.82603 7.81951,-3.28658 2.7281,0.82679 6.66368,0.72482 5.24108,-3.19065 -0.13265,-3.7013 2.5656,-7.28705 6.34039,-7.60384 0.916,-0.13974 1.85168,-0.173 2.77308,-0.0675"
+ style="fill:none;stroke:#000000;stroke-width:0.25555602px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.53740115"
+ inkscape:cx="-210.97157"
+ inkscape:cy="122.10003"
+ inkscape:current-layer="boulder2"
+ inkscape:document-units="px"
+ showgrid="false"
+ inkscape:window-width="1918"
+ inkscape:window-height="1051"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata5447">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ style="display:inline">
+ <path
+ style="fill:url(#linearGradient4839);fill-opacity:1;stroke:#000000;stroke-width:1.13295424px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 0.50401247,483.34972 135.11094753,32.72292 121.64836,-52.61816 90.01616,166.2308 177.53604,-73.30952 70.75812,-17.76415 86.38372,-109.6609 192.87504,23.17132 151.6123,-71.0121 2.1412,386.98011 -1029.6818612,2.5895 z"
+ id="ground-skeleton"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccccccc" />
+ <g
+ id="snake"
+ inkscape:label="Layer 1"
+ transform="matrix(0.16354665,0,0,0.17294153,642.67124,68.363334)">
+ <path
+ style="fill:#c400cd;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 369.40693,457.13023 C 343.45846,398.2563 280.47783,321.77751 118.76428,193.95883 418.08327,341.75668 737.89259,499.0248 737.89259,499.0248 c 0,0 -224.17779,-49.19018 -343.12803,-27.09185 z"
+ id="path3770"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccc" />
+ <g
+ style="stroke:#000000;stroke-width:3;stroke-opacity:1"
+ transform="translate(-39.306358,24.855491)"
+ inkscape:transform-center-y="-26.589595"
+ inkscape:transform-center-x="-38.728324"
+ id="g3988">
+ <path
+ transform="matrix(0.70710678,-0.70710679,0.70710679,0.70710678,-408.73234,-82.896217)"
+ d="m -87.644779,606.22321 a 43.629345,29.53668 0 1 1 -87.258691,0 43.629345,29.53668 0 1 1 87.258691,0 z"
+ sodipodi:ry="29.53668"
+ sodipodi:rx="43.629345"
+ sodipodi:cy="606.22321"
+ sodipodi:cx="-131.27412"
+ id="path3990"
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:nodetypes="czcc"
+ inkscape:connector-curvature="0"
+ id="path3992"
+ d="M 58.562409,479.98343 C 74.636675,459.32822 93.172749,432.2897 95.93017,413.27112 98.687588,394.25255 91.634674,358.94769 59.022885,344.34816 20.969383,333.8184 -28.256972,376.94496 -42.551153,407.84758"
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3994"
+ d="m -90.938914,442.32357 c 12.74131,15.05792 12.74131,15.05792 12.74131,15.05792"
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+ <path
+ sodipodi:nodetypes="cscssssssssssscsccccccccccccc"
+ inkscape:connector-curvature="0"
+ id="path2989"
+ d="M -0.83232693,600.93431 C -14.72122,585.19357 -39.637889,509.85955 49.07407,456.99181 c 71.5406,-42.6345 101.07573,-9.03385 120.78007,17.00262 55.69831,-44.91411 127.92399,-82.24386 205.14586,-73.4841 35.94416,4.07737 82.1662,34.27483 87.97852,77.06972 8.54761,62.93423 -13.04855,83.16215 -44.53003,116.49549 -45.98224,48.68709 -72.27669,57.74976 -111.57796,113.90445 -36.04005,51.49497 -41.77795,81.16262 -41.6122,120.23809 0.35947,84.74463 60.71428,173.86402 59.78836,173.86402 -0.51576,0 -56.42937,-30.06459 -88.07493,-83.82623 -25.16661,-42.75476 -27.881,-107.60064 -26.17189,-133.23729 4.62964,-69.44445 30.75787,-95.98506 68.87644,-142.88048 33.89389,-41.69799 112.70676,-117.99838 88.78774,-150.80144 -24.19049,-33.17536 -67.84502,-33.99292 -111.0619,-9.47035 -34.94478,19.82873 -39.84896,23.82441 -56.71963,36.86244 40.09471,53.49212 -28.60401,102.79241 -44.5311,115.69939 C 69.469378,704.67347 23.360256,639.81353 9.1522195,617.30991 35.997716,613.30342 77.159302,607.81112 77.159302,607.81112 l -3.839974,-23.64066 40.569562,8.93246 -8.33333,-39.81481 48.80174,8.60567 -43.24619,-78.05012 6.48148,48.14816 -37.037034,-11.11112 10.185185,47.22222 -37.962964,-2.77777 1.101537,27.04115 z"
+ style="fill:#007700;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <path
+ sodipodi:nodetypes="cc"
+ inkscape:connector-curvature="0"
+ id="path2991"
+ d="m 32.773109,477.57227 c 10.560982,23.57483 37.656144,29.23007 57.983194,0"
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ <g
+ style="stroke:#000000;stroke-width:3;stroke-opacity:1"
+ id="g3983">
+ <path
+ sodipodi:type="arc"
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path3981"
+ sodipodi:cx="-131.27412"
+ sodipodi:cy="606.22321"
+ sodipodi:rx="43.629345"
+ sodipodi:ry="29.53668"
+ d="m -87.644779,606.22321 a 43.629345,29.53668 0 1 1 -87.258691,0 43.629345,29.53668 0 1 1 87.258691,0 z"
+ transform="matrix(0.70710678,-0.70710679,0.70710679,0.70710678,-408.73234,-82.896217)" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 58.562409,479.98343 C 74.636675,459.32822 93.172749,432.2897 95.93017,413.27112 98.687588,394.25255 91.634674,358.94769 59.022885,344.34816 20.969383,333.8184 -28.256972,376.94496 -42.551153,407.84758"
+ id="path2993"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="czcc" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m -90.938914,442.32357 c 12.74131,15.05792 12.74131,15.05792 12.74131,15.05792"
+ id="path3979"
+ inkscape:connector-curvature="0" />
+ </g>
+ <path
+ sodipodi:nodetypes="ccccc"
+ inkscape:connector-curvature="0"
+ id="path3000"
+ d="M 387.86127,431.55293 C 378.03467,367.96912 336.99422,277.7957 213.87283,112.47779 464.73988,332.709 732.94798,567.39108 732.94798,567.39108 c 0,0 -203.80777,-105.53554 -324.42434,-114.97678 z"
+ style="fill:#c400cd;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+ </g>
+ <use
+ xlink:href="#boulder1"
+ id="boulder">
+ <animate attributeName="xlink:href" values="#boulder1; #boulder2" calcMode="discrete" dur="2s" repeatCount="indefinite" id="animate3072"></animate>
+ </use>
+ </g>
+</svg>
View
11 notebook.cs
@@ -197,8 +197,8 @@ frag.appendChild scratch.firstChild
loadButton.addEventListener 'change', (evt)-> loadProgram el, loadButton.files
testButton.addEventListener 'click', -> runTests el
themeSelect.value = el.leisureTheme ? 'thin'
- themeSelect.addEventListener 'change', (evt)-> changeTheme el, evt.target
- viewSelect.addEventListener 'change', (evt)-> changeView el, evt.target
+ themeSelect.addEventListener 'change', (evt)-> changeTheme el, evt.target.value
+ viewSelect.addEventListener 'change', (evt)-> changeView el, evt.target.value
processButton.addEventListener 'click', -> evalDoc el
configureSaveLink(el)
@@ -244,12 +244,12 @@ removeOldDefs c
resultsClass.add 'failed'
el.testResults.innerHTML = "#{passed}/#{failed}"
-changeTheme = (el, t)->
- theme = t.value
+changeTheme = (el, value)->
+ theme = value
el.leisureTheme = theme
document.body.className = theme
-changeView = (el, v)-> alert 'new view: ' + v.value
+changeView = (el, value)-> alert 'new view: ' + value
unwrap = (node)->
parent = node.parentNode
@@ -612,6 +612,7 @@ svg.appendChild txt
root.getBox = getBox
root.makeRange = makeRange
root.grp = grp
+root.changeTheme = changeTheme
#root.selection = -> window.getSelection().getRangeAt(0)
#root.test = -> flatten(root.selection().cloneContents().childNodes[0])
View
14 notebook.js
@@ -257,10 +257,10 @@
});
themeSelect.value = (_ref2 = el.leisureTheme) != null ? _ref2 : 'thin';
themeSelect.addEventListener('change', function(evt) {
- return changeTheme(el, evt.target);
+ return changeTheme(el, evt.target.value);
});
viewSelect.addEventListener('change', function(evt) {
- return changeView(el, evt.target);
+ return changeView(el, evt.target.value);
});
processButton.addEventListener('click', function() {
return evalDoc(el);
@@ -335,15 +335,15 @@
}
};
- changeTheme = function changeTheme(el, t) {
+ changeTheme = function changeTheme(el, value) {
var theme;
- theme = t.value;
+ theme = value;
el.leisureTheme = theme;
return document.body.className = theme;
};
- changeView = function changeView(el, v) {
- return alert('new view: ' + v.value);
+ changeView = function changeView(el, value) {
+ return alert('new view: ' + value);
};
unwrap = function unwrap(node) {
@@ -896,4 +896,6 @@
root.grp = grp;
+ root.changeTheme = changeTheme;
+
}).call(this);
Please sign in to comment.
Something went wrong with that request. Please try again.