Difference between revisions of "ProcessingTestsTemplate"
(Created page with '==Processing.js Test Template html code == Processing.js html file for writing tests with a uniform look and design <nowiki><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tra...') |
(No difference)
|
Latest revision as of 22:06, 21 October 2009
Processing.js Test Template html code
Processing.js html file for writing tests with a uniform look and design
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Processing.js test of xxxx()</title> <script type="text/javascript" src="processing.js"></script> <script type="text/javascript" src="init.js"></script> <style type="text/css"> html, body { background: #EEE; font-family: Arial; font-size: 13px; margin: 0; padding: 0; } h1 { background: #385C85; color: #FFF; padding: 10px; padding-left: 20px; margin-top: 0px; } h1 a { color: #FFF; } h2 { padding-left: 20px; } p { padding-left: 20px; line-height: 1.3em; } p a { color: #385C85; } canvas { margin: 10px 0; } pre { margin-left: 20px; margin-right: 20px; padding: 5px; background: #FFF; border-top: 1px solid #333; border-bottom: 1px solid #333; } div.ref-col { float: left; width: 32%; } </style> </head> <body> <h1> <!-- name of your function and test description --> Shorten() test</h1> <h2> This is a demo of my xxxx() test</h2> <br /> <p> <!-- copy paste your processing code below this script tag --> <script id="script" type="application/processing"> size(550,150, P3D); background(225); stroke(24, 60, 100); fill(225); rect(1, 1, 547, 147); String[] sa1 = {"BTP500 ", "BTH540 ", "BTB520 ", "DPS909 ", "Last Course"}; String[] sa2 = shorten(sa1); PFont font; font = loadFont("Arial.vlw"); textFont(font, 18); fill(0, 0, 0); // test string array shortening String courses = ""; for (int i=0; i < sa2.length; i++){ courses += sa2[i]; } // original arrays String courses1 = ""; for (int i=0; i < sa1.length; i++){ courses1 += sa1[i]; } // display outputs text("original string array: " + courses1, 10, 25); text("shortened string array: " + courses, 10, 50); </script> <canvas id="display" style="width:200;height:100;"></canvas> <script type="text/javascript"> $(document).ready(function(){ var canvas = document.getElementById('display'); var script = document.getElementById('script').text; var source = script.replace(/[^\.]size\(\)\;/,'size('+ $("body").width() +','+ $("body").height() +');'); Processing(canvas,source); }); </script><br /> <b>Test written by <a href="http://dhodgin.wordpress.com/">Daniel Hodgin</a> <pre style="border-style: dotted; border-width: 1px; background-color: #FFFFFF; padding: 2px; margin: 5px"> size(550,150, P3D); background(225); stroke(24, 60, 100); fill(225); rect(1, 1, 547, 147); String[] sa1 = {"BTP500 ", "BTH540 ", "BTB520 ", "DPS909 ", "Last Course"}; String[] sa2 = shorten(sa1); PFont font; font = loadFont("Arial.vlw"); textFont(font, 18); fill(0, 0, 0); // test string array shortening String courses = ""; for (int i=0; i < sa2.length; i++){ courses += sa2[i]; } // original arrays String courses1 = ""; for (int i=0; i < sa1.length; i++){ courses1 += sa1[i]; } // display outputs text("original string array: " + courses1, 10, 25); text("shortened string array: " + courses, 10, 50); </pre> <br /> </body> </html>