creative technology
[]
readme
new(s)
masterclass
workshop(s)
CA1
CA2
CA3
CA4
CA5
project(s)
NM1
NM2
NM3
NM4
NM5
resource(s)
_
/ .
math-coffee
/
/ [-]
/ [@cfg-math-coffee]
/ math-coffee.cfg
<script type="text/javascript" src="cfg/math/mathsvg.js"></script></script>
<body>
<center>
svg canvas
<embed width="600" height="260" src="../media/d.svg"
script='
initPicture(-3,3,-3,3)
axes(1,1,"labels",1)
// a = 1.5
update()
'>
coffee
<script id="coffee" type="text/coffeescript">
square = (x) -> x * x
cube = (x) -> square(x) * x
window.square = square;
window.cube = cube;
</script>
compile
<script>
function compile(cf) {
//alert(cf);
source = document.getElementById(cf).innerText;
//alert(source);
JS = CoffeeScript.compile(source);
//alert(JS);
eval(JS);
}
</script>
<script src="coffee/documentation/vendor/jquery-1.4.2.js"></script>
<script src="coffee/extras/coffee-script.js"></script>
initialize
<script>
function setfv() {
f=document.getElementById('fv').value;
}
a = 2.5;
xmode = 0;
thestroke = "blue";
compile("coffee");
cube = window.cube;
square = window.square;
toggle(s)
function toggle() {
if (xmode == 1) { thestroke = "blue"; xmode = 0; }
else { thestroke = "red"; xmode = 1; }
// alert("update");
update();
}
function xstroke() { return thestroke; }
update(s)
function update () {
f=document.getElementById('fv').value;
p = []
with (Math)
for (var x = -a; x < a+.1; x += .1)
p[p.length] = [x, eval(f)]
stroke = xstroke()
//path(p,"func")
plot(f,-a,a)
setText(f,"fval")
setText(a.toFixed(2),"aval")
setText((-a).toFixed(2),"maval")
}
</script>
description(s)
<h5>
y=<span id="fval">f</span>
<input type="text" id="fv" name="fname" value="cube(x)" onblur="toggle()" />
for <span id="maval">a <=x<= a</span>
<input type="button" value="-" onclick="a-=.25;update()"/>
<input type="button" value="+" onclick="a+=.25;update()"/>
</h5>
</center>
</body>

[]
readme
new(s)
masterclass
workshop(s)
CA1
CA2
CA3
CA4
CA5
project(s)
NM1
NM2
NM3
NM4
NM5
resource(s)
_
/ .
(C) Æliens
09/09/09
creativetechnology.eu