User:Thalia de Jong/counting: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:
<h1>My coding counting magic (it ain't easy)</h1>
<h1>My coding counting magic (it ain't easy)</h1>


<!doctype html>
<canvas id="canvas" width="960" height="540" showsrc>
<html>
var paint;
<head>
 
<title>Thalia's coding magic</title> <!--dit is de tab titel-->
function draw(){
<script>
    c= document.getElementById("canvas");
//confirm("Click OK if you're ready for magic!");
    paint= c.getContext ("2d");
 
var paint;
    paint.fillStyle="#3333CC";
    paint.fillRect (0,0,960,540);
function draw(){
 
c= document.getElementById("canvas");
    paint.fillStyle="#FF0033";
paint= c.getContext ("2d");
    drawredhair();
 
paint.fillStyle="#3333CC";
    paint.fillStyle="#33FF99";
paint.fillRect (0,0,960,540);
    drawgreentail1();
 
paint.fillStyle="#FF0033";
    //How do I make a loop within a loop? I couldn't figure it out here and so I keep adding greentails. Seems a bit tedious...
drawredhair();
    paint.fillStyle="#33FF99";
    drawgreentail2();
paint.fillStyle="#33FF99";
 
drawgreentail1();
    paint.fillStyle="#33FF99";
    drawgreentail3();
//How do I make a loop within a loop? I couldn't figure it out here and so I keep adding greentails. Seems a bit tedious...
 
paint.fillStyle="#33FF99";
    paint.fillStyle="#33FF99";
drawgreentail2();
    drawgreentail4();
 
paint.fillStyle="#33FF99";
    paint.fillStyle="#33FF99";
drawgreentail3();
    drawgreentail5();
}
paint.fillStyle="#33FF99";
 
drawgreentail4();
function drawredhair(){
x= 480;
paint.fillStyle="#33FF99";
y= 180;
drawgreentail5();
counter=1;
 
}
while (counter<200){
paint.fillRect(x,y,150,120);
function drawredhair(){
x=x+1;
x= 480;
y=y-1/2;
y= 180;
counter=counter+1;
counter=1;
}
}
while (counter<200){
 
paint.fillRect(x,y,150,120);
function drawgreentail1(){
x=x+1;
x=650;
y=y-1/2;
y=400;
counter=counter+1;
counter=1;
}
}
while (counter<30){
    paint.fillRect(x,y,20,2);
function drawgreentail1(){
    x=x+5;
x=650;
    y=y+3;
y=400;
    counter=counter+1;
counter=1;
}
}
function drawgreentail2(){
x=671;
y=400;
counter=1;
while (counter<28){
    paint.fillRect(x,y,18,2);
    x=x+5;
    y=y+3;
    counter=counter+1;
    }
}
while (counter<30){
function drawgreentail3(){
paint.fillRect(x,y,20,2);
x=690;
x=x+5;
y=400;
y=y+3;
counter=1;
counter=counter+1;
}
while (counter<26){
}
    paint.fillRect(x,y,16,2);
    x=x+5;
function drawgreentail2(){
    y=y+3;
x=671;
    counter=counter+1;
y=400;
}
counter=1;
}
while (counter<28){
function drawgreentail4(){
paint.fillRect(x,y,18,2);
x=707;
x=x+5;
y=400;
y=y+3;
counter=1;
counter=counter+1;
}
while (counter<24){
}
    paint.fillRect(x,y,14,2);
    x=x+5;
function drawgreentail3(){
    y=y+3;
x=690;
    counter=counter+1;
y=400;
}
counter=1;
}
while (counter<26){
function drawgreentail5(){
paint.fillRect(x,y,16,2);
x=722;
x=x+5;
y=400;
y=y+3;
counter=1;
counter=counter+1;
}
while (counter<22){
}
    paint.fillRect(x,y,14,2);
    x=x+5;
function drawgreentail4(){
    y=y+3;
x=707;
    counter=counter+1;
y=400;
}
counter=1;
}
</canvas>
while (counter<24){
paint.fillRect(x,y,14,2);
x=x+5;
y=y+3;
counter=counter+1;
}
}
function drawgreentail5(){
x=722;
y=400;
counter=1;
while (counter<22){
paint.fillRect(x,y,14,2);
x=x+5;
y=y+3;
counter=counter+1;
}
}
</script>
</head>
<body onload= "draw()">
<canvas id="canvas" width="960" height="540"style="border:10px solid #ff8cfd;">
</canvas>
</body>
</html>

Latest revision as of 10:54, 29 October 2012

tumblr_m96z2fG1eL1rdj88go1_250.gif

My coding counting magic (it ain't easy)

<canvas id="canvas" width="960" height="540" showsrc> var paint;

function draw(){

   c= document.getElementById("canvas");
   paint= c.getContext ("2d");
   paint.fillStyle="#3333CC";	
   paint.fillRect (0,0,960,540);
   paint.fillStyle="#FF0033";	
   drawredhair();
   paint.fillStyle="#33FF99";
   drawgreentail1();
   //How do I make a loop within a loop? I couldn't figure it out here and so I keep adding greentails. Seems a bit tedious...
   paint.fillStyle="#33FF99";
   drawgreentail2();
   paint.fillStyle="#33FF99";
   drawgreentail3();
   paint.fillStyle="#33FF99";
   drawgreentail4();
   paint.fillStyle="#33FF99";
   drawgreentail5();

}

function drawredhair(){ x= 480; y= 180; counter=1;

while (counter<200){ paint.fillRect(x,y,150,120); x=x+1; y=y-1/2; counter=counter+1; } }

function drawgreentail1(){ x=650; y=400; counter=1;

while (counter<30){ paint.fillRect(x,y,20,2); x=x+5; y=y+3; counter=counter+1; } }

function drawgreentail2(){ x=671; y=400; counter=1;

while (counter<28){ paint.fillRect(x,y,18,2); x=x+5; y=y+3; counter=counter+1;

   }

}

function drawgreentail3(){ x=690; y=400; counter=1;

while (counter<26){ paint.fillRect(x,y,16,2); x=x+5; y=y+3; counter=counter+1; } }

function drawgreentail4(){ x=707; y=400; counter=1;

while (counter<24){ paint.fillRect(x,y,14,2); x=x+5; y=y+3; counter=counter+1; } }

function drawgreentail5(){ x=722; y=400; counter=1;

while (counter<22){ paint.fillRect(x,y,14,2); x=x+5; y=y+3; counter=counter+1; } } </canvas>