jeudi 23 avril 2015

JQuery Checkbox and Switch Case

I use a checkbox.I can get checked value in checkbox into an globalarray.But I don't match checkbox value id and shapes id.Now, whatever I checked, shapes are created in switchcase order.I want to do the same checked shapes and created shapes.How can I do?

<input type="checkbox" value="circle" class="chk">circle</input>
<input type="checkbox" value="star" class="chk">star</input>
<input type="checkbox" value="square" class="chk">square</input>
<input type="checkbox" value="hexagon" class="chk">hexagon</input>


var newShape = null;
    switch (pointer){
        case 0:
            newShape = new fabric.Circle({
                  id: '1',
                  hasBorders:false,
                  hasControls:false,
                  radius: 20, 
                  fill: fillColors, 
                  left: posX, 
                  top: posY
                });
            break;
        case 1:
            var newShape = new fabric.Polygon([
        {x: 10, y: 3},
        {x: 25, y: 18},
        {x: 40, y: 3},
        {x: 35, y: 25},
        {x: 50, y: 40},
        {x: 33, y: 40},
        {x: 25, y: 60},
        {x: 18, y: 40},
        {x: 0, y: 40},
        {x: 15, y: 25}], {
                  hasBorders:false,
                  hasControls:false,
                  id: '2',
          fill: fillColors,
              left: posX,
              top: posY,
              angle: 180
        });
            break; 
case 3:
    var newShape = new fabric.Polygon([
      {x: 45, y: 0},
      {x: 67.5, y: 22.5},
      {x: 67.5, y: 45},
      {x:45, y: 67.5},
      {x: 22.5, y: 45},
      {x: 22.5, y: 22.5} ], {
       id: '4',
           hasBorders:false,
           hasControls:false,
       left: posX,
       top: posY,
       fill: fillColors
     });
            break;




Aucun commentaire:

Enregistrer un commentaire