<html>
<title>Bodymass</title>
<head>
</head>
<body>
<h2>Rechteck</h2>
<title>Rechteck</title>
<canvas id="canvas" name="canvas" width="200" height="200" ></canvas>
<br /> Länge:<input type="text" id="ip1" name="ip1" value="0"/>
<br /> Breite:<input type="text" id="ip2" name="ip2" value="0"/>
<br /> <input type="button" value="berechne Rechteck" onclick=
"
var rechteck=
{laenge:+ip1.value,
breite:+ip2.value,
umfang: function(){return 2*(this.laenge+this.breite);},
inhalt: function(){return this.laenge*this.breite;},
bild: canvas.getContext('2d'),
graph: function(){
this.bild.fillStyle = 'rgb(0,0,0)';
this.bild.fillRect (0,0, 200,200);
this.bild.fillStyle = 'rgb(0,255,0)';
this.bild.fillRect (0,0, this.laenge,this.breite);
this.bild.font = '20px Arial';
this.bild.fillText('U='+this.umfang()+',A='+this.inhalt(), 0,200);
}
};
rechteck.graph();//Aufrufen
">
</body>
</html>
<!--
Kommentar
-->