Skip to content

Instantly share code, notes, and snippets.

@mathdoodle
Last active August 29, 2015 14:23
Show Gist options
  • Save mathdoodle/63f8ad7e756b0236c805 to your computer and use it in GitHub Desktop.
Save mathdoodle/63f8ad7e756b0236c805 to your computer and use it in GitHub Desktop.
DoodlePad
{
"uuid": "318d32d3-03ec-4450-99be-a6eeb3c530f6",
"description": "DoodlePad",
"dependencies": {
"DomReady": "latest",
"davinci-blade": "1.1.1"
},
"operatorOverloading": true
}
<!doctype html>
<html>
<head>
<style>
/* STYLE-MARKER */
</style>
<!-- SCRIPTS-MARKER -->
</head>
<body>
<pre id='info'></pre>
<script>
// CODE-MARKER
</script>
</body>
</html>
var e3 = blade.e3ga.e3;
var meter = blade.e3ga.units.meter;
var newton = blade.e3ga.units.newton;
var kilogram = blade.e3ga.units.kilogram;
var second = blade.e3ga.units.second;
DomReady.ready(function() {
try {
calculation();
}
catch(e) {
function colorize(arg: any, color:string) {
return "<span style='color:"+color+"'>" + arg + "</span>";
}
println(colorize(e.message,'red'));
}
});
/**
* Do the calculation here.
*/
function calculation() {
var a = -9.81 * e3 * newton / kilogram;
var m = 70 * blade.e3ga.units.kilogram;
var F = m * a;
showvar('a', a);
showvar('m', m);
showvar('F = m * a', F.toFixed(2));
}
/**
* Print the HTML string without a line ending.
*/
function print(html: string): void {
var element = document.getElementById('info');
element.innerHTML = element.innerHTML + html;
}
/**
* Print the HTML string and go to the next line.
*/
function println(html: string): void {
print(html + '\n');
}
function showvar(name: string, value: any) {
println("<b>" + name + "</b> => " + value)
}
#info {
position: absolute;
left: 40%;
top: 200px;
font-size: 26px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment