User:Menno Harder/Canvas: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
 
Line 5: Line 5:
[[File:Blok3.png]] Clap one time<br/>
[[File:Blok3.png]] Clap one time<br/>
[[File:Blok4.png]] Clap two times<br/>
[[File:Blok4.png]] Clap two times<br/>
<source lang="html4strict">
function draw() {
    c = document.getElementById("c2");
    p = c.getContext("2d");
    hands = 1;
    x = 20;
    y = 20;
    function functienaam(){
    if (hands < 25) {
        //console.log(hands);
        if (hands % 3 == 0){
          p.fillRect(x,y,20,20);
        }else{
          p.strokeRect(x,y,20,20);
        }
        x = x + 50;
        //hands++;
        if (x > 400) {
            x = 20;
            y = y + 50;
        }
    }
    if (hands >= 24 && hands<48) {
        //console.log(hands);
        if (hands % 2  == 0 || hands % 3 ==0){
          p.strokeRect(x,y,15,15);
        }else{
          p.strokeRect(x,y,20,20);
        }
        x = x + 50;
        //hands++;
        if (x > 400) {
            x = 20;
            y = y + 50;
        }
    }
        if (hands >= 47 && hands<71) {
        //console.log(hands);
        if (hands % 3  == 0 || hands % 2 ==0){
          p.strokeRect(x,y,20,20);
          p.strokeRect(x,y,15,15);
          p.strokeRect(x,y,10,10);
        }else{
          p.fillRect(x,y,20,20);
        }
        x = x + 50;
        //hands++;
        if (x > 400) {
            x = 20;
            y = y + 50;
        }
    }
        if (hands >= 70 && hands<94) {
        //console.log(hands);
        if (hands % 2  == 0 || hands % 4 ==0){
          p.strokeRect(x,y,15,15);
        }else{
          p.fillRect(x,y,20,20);
        }
        x = x + 50;
        //hands++;
        if (x > 400) {
            x = 20;
            y = y + 50;
        }
    }
    hands++;
  }
    setInterval(functienaam, 700);
}
</source>

Latest revision as of 22:59, 13 December 2012

[| Samba class]
Blok1.png Knock one time
Blok2.png Knock two times
Blok3.png Clap one time
Blok4.png Clap two times

function draw() {
    c = document.getElementById("c2");
    p = c.getContext("2d");
    hands = 1;
    x = 20;
    y = 20;
    function functienaam(){
    if (hands < 25) {
        //console.log(hands);
        if (hands % 3 == 0){
          p.fillRect(x,y,20,20);
        }else{
          p.strokeRect(x,y,20,20);
        }
        x = x + 50;
        //hands++;
        if (x > 400) {
            x = 20;
            y = y + 50;
        }
    }
    if (hands >= 24 && hands<48) {
        //console.log(hands);
        if (hands % 2  == 0 || hands % 3 ==0){
          p.strokeRect(x,y,15,15);
        }else{
          p.strokeRect(x,y,20,20);
        }
        x = x + 50;
        //hands++;
        if (x > 400) {
            x = 20;
            y = y + 50;
        }
    }
        if (hands >= 47 && hands<71) {
        //console.log(hands);
        if (hands % 3  == 0 || hands % 2 ==0){
          p.strokeRect(x,y,20,20);
          p.strokeRect(x,y,15,15);
          p.strokeRect(x,y,10,10);
        }else{
          p.fillRect(x,y,20,20);
        }
        x = x + 50;
        //hands++;
        if (x > 400) {
            x = 20;
            y = y + 50;
        }
    }
        if (hands >= 70 && hands<94) {
        //console.log(hands);
        if (hands % 2  == 0 || hands % 4 ==0){
          p.strokeRect(x,y,15,15);
        }else{
          p.fillRect(x,y,20,20);
        }
        x = x + 50;
        //hands++;
        if (x > 400) {
            x = 20;
            y = y + 50;
        }
    }

    hands++;

  }
    setInterval(functienaam, 700);
}