Hi. I am working with simple canvases and I have noticed this unintuitive behaviour. When two canvases are exactly next to each other but do not overlap the method intersects still returns true. See the attached screenshot and standalone example.
EDIT: Manually setting the margins to 0 on both canvases doesn't seem to help.
Code:
package combo.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.widgets.Canvas; public class Application implements EntryPoint { private Canvas drawingCanvas; @Override public void onModuleLoad() { drawingCanvas = new Canvas(); drawingCanvas.setWidth(200); drawingCanvas.setHeight(200); Canvas firstChild = new Canvas(); firstChild.setWidth(50); firstChild.setHeight(50); firstChild.setBackgroundColor("red"); firstChild.setBorder("1px solid green"); drawingCanvas.addChild(firstChild); firstChild.moveTo(0, 0); Canvas secondChild = new Canvas(); secondChild.setWidth(50); secondChild.setHeight(50); secondChild.setBackgroundColor("blue"); secondChild.setBorder("1px solid green"); drawingCanvas.addChild(secondChild); secondChild.moveTo(50, 50); if (firstChild.intersects(secondChild)) { drawingCanvas.setBackgroundColor("black"); } else { drawingCanvas.setBackgroundColor("white"); } drawingCanvas.draw(); } }
EDIT: Manually setting the margins to 0 on both canvases doesn't seem to help.
Comment