Raghvendra Singh

Members
  • Content Count

    2
  • Joined

  • Last visited

  1. Hi @jake.caron Below is is the code var type = 'image/png'; var encoderOptions = 0.92; var gl = game.getContext('2d'); var canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); var imageData; var xMin = parseInt(this.getMinX(this.polygons.body.vertices)); var xMax = parseInt(this.getMaxX(this.polygons.body.vertices)); var yMin = parseInt(this.getMinY(this.polygons.body.vertices)); var yMax = parseInt(this.getMaxY(this.polygons.body.vertices)); //imageData = gl.getImageData((xMin-20), (yMin+20), (xMin-50),((yMax+30)-yMin)); imageData = gl.getImageData((xMin-20), (yMin+20), 300, 300); var data = imageData.data; ctx.putImageData(imageData, 0, 0); var src = canvas.toDataURL(type, encoderOptions); var image = new Image(); image.src = src; console.log("xMax-xMin :: ", xMax-xMin) console.log("((yMax+50)-yMin) :: ", ((yMax+50)-yMin)) if((xMax-xMin) < 150){ image.style.width = "150px"; }else{ image.style.width = (xMax-xMin)+"px"; } image.style.height = (yMax-yMin)+"px"; image.style.position = 'absolute'; image.style.left = '900px'; image.style.top = '100px'; image.style.paddingLeft = '2px'; document.body.appendChild(image); You need to just update the x and y value according to your x and y value.
  2. Hi All, Below is my project url please visit : http://111.93.53.134/digital/test/polygon/ Now my question is that i am creating a polygon at run time and add physics to polygon. When the polygon collides with matter body a horizontal redline is drawn and when i click on the down arrow button then another metal spring collides with polygon shapes then a blue line draw and you can drag the blue line. So i have to take the snapshot of only that polygon and redline which is beneath the polygon and that blue line which is being dragged and show them in the grid box 1,2,3,4. The polygons can be rotate as well by middle button when the spring metal is not collides with the polygon. I have tried several ways to figure this out but not able to fix the snapshot . I am attaching the image that what i actually want. And please tell me a way to make the polygon shapes more steady while rotation. Thanks, Raghvendra