Permalink
Browse files

move demo into demo directory; add jquery

  • Loading branch information...
osteele committed Mar 23, 2008
1 parent 91f3f34 commit b77ec2f71266624fd190635f5aabc9c47b6ccb33
Showing with 101 additions and 34 deletions.
  1. +14 −0 3rd-party/CREDITS
  2. +31 −0 3rd-party/jquery-1.2.1.min.js
  3. +8 −0 3rd-party/swfobject.js
  4. +0 −23 cfdg.html
  5. +8 −0 demo/demo.js
  6. +27 −0 demo/index.html
  7. +13 −11 javascripts/cfdg.js
View
@@ -0,0 +1,14 @@
+== JQuery
+
+jQuery 1.1.4 - New Wave Javascript
+
+Copyright (c) 2007 John Resig (jquery.com)
+Dual licensed under the MIT (MIT-LICENSE.txt)
+and GPL (GPL-LICENSE.txt) licenses.
+
+== SWFObject
+
+SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
+
+SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
+http://www.opensource.org/licenses/mit-license.php

Large diffs are not rendered by default.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,23 +0,0 @@
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>CFDG</title>
- <link href="styles.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="javascripts/cfdg.model.js"></script>
- <script type="text/javascript" src="javascripts/cfdg.parser.js"></script>
- <script type="text/javascript" src="javascripts/cfdg.graphics.js"></script>
- <script type="text/javascript" src="javascripts/cfdg.drawing.js"></script>
- </head>
- <body>
- <div id="statusField"></div>
- <table><tr><td width="30%">
- <textarea cols="40" rows="100" id="sourceField"> </textarea>
- </td><td width="70%" style="height: 500" valign="top">
- <canvas id="canvas" width="600" height="500"></canvas>
- </td></tr></table>
- <script type="text/javascript" src="javascripts/cfdg.js"></script>
-
- <div id="footer">
- Copyright 2006 by <a href="/">Oliver Steele</a>. All rights reserved.
- </div>
- </body>
-</html>
View
@@ -0,0 +1,8 @@
+/* Copyright 2008 by Oliver Steele. All rights reserved. */
+
+$(function() {
+ setup($("#canvas")[0]);
+ var rendering = false;
+ $('#renderButton').click(doRender);
+ $('#stopButton').click(stopRendering);
+});
View
@@ -0,0 +1,27 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>CFDG</title>
+ <link href="styles.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../javascripts/cfdg.model.js"></script>
+ <script type="text/javascript" src="../javascripts/cfdg.parser.js"></script>
+ <script type="text/javascript" src="../javascripts/cfdg.graphics.js"></script>
+ <script type="text/javascript" src="../javascripts/cfdg.drawing.js"></script>
+ <script type="text/javascript" src="../javascripts/cfdg.js"></script>
+ <script type="text/javascript" src="../3rd-party/jquery-1.2.1.min.js"></script>
+ <script type="text/javascript" src="demo.js"></script>
+ </head>
+ <body>
+ <div id="statusField"></div>
+ <button id="renderButton">Render</button>
+ <button id="stopButton">Stop</button>
+ <table><tr><td width="30%">
+ <textarea cols="40" rows="100" id="sourceField"> </textarea>
+ </td><td width="70%" style="height: 500" valign="top">
+ <canvas id="canvas" width="600" height="500"></canvas>
+ </td></tr></table>
+
+ <div id="footer">
+ Copyright 2006 by <a href="/">Oliver Steele</a>. All rights reserved.
+ </div>
+ </body>
+</html>
View
@@ -1,11 +1,13 @@
/* Copyright 2006 Oliver Steele. All rights reserved. */
-//var interval_name = setInterval('draw()',100);
-//clearInterval('animateShape()',500);
+var canvas;
+var ctx;
-canvas = document.getElementById("canvas");
-var ctx = canvas.getContext("2d");
-ctx.save();
+function setup(canvasElement) {
+ canvas = canvasElement;
+ ctx = canvas.getContext("2d");
+ ctx.save();
+}
var Stats;
var NewBounds;
@@ -62,9 +64,9 @@ Graphics.prototype.setViewport = function (bounds) {
this.ctx.restore();
this.clear();
this.ctx.save();
- var scale = Math.min(canvas.width / (xmax - xmin),
- canvas.height / (ymax - ymin));
- //info('scale = ' + scale);
+ var scale = Math.min(
+ canvas.width / (xmax - xmin || 1),
+ canvas.height / (ymax - ymin || 1));
this.ctx.scale(scale, scale);
this.ctx.translate(-xmin, -ymin);
@@ -190,17 +192,17 @@ function drawNext() {
if (drawingContext.queue.length)
msg += " " + drawingContext.queue.length + " expansions remaining.";
if (Stats.resetCount) msg += " (Reset bounds " + Stats.resetCount + " time"+(Stats.resetCount==1?'':'s')+".)";
- statusField.innerHTML = msg;
+ $('#statusField').html(msg);
if (drawingContext.queue.length)
- setTimeout('drawNext()', 10);
+ setTimeout(drawNext, 10);
else
stopRendering();
}
function stopRendering() {
if (drawingContext.queue.length)
- statusField.innerHTML = "<font color='#ff0000'>Stopped rendering</font> at " + Stats.shapeCount + " shapes after " + Math.round(((new Date).getTime() - Stats.startTime)/1000) + "s, with " + drawingContext.queue.length + " expansions remaining.";
+ $('#statusField').html("<font color='#ff0000'>Stopped rendering</font> at " + Stats.shapeCount + " shapes after " + Math.round(((new Date).getTime() - Stats.startTime)/1000) + "s, with " + drawingContext.queue.length + " expansions remaining.");
drawingContext.queue = [];
drawingContext = null;

0 comments on commit b77ec2f

Please sign in to comment.