Question

I'm trying to draw a image attached to a box, but:

Graphics2D surf = (Graphics2D) surface.create(x, y, width, height);
image.draw(surf, width, height);
surface.setColor(Color.BLUE);
surface.fillRect(-5, -5, 10, 10);
surf.dispose();

doesnt render that box at -5 from the surface.create area

#creates a new Graphics object based on this Graphics object, but with a new translation and clip area.

how ignore clip area?

Was it helpful?

Solution

Well.. the create does clip the area, the only simple solution I did is:

Graphics2D surf = (Graphics2D) surface.create();
surf.translate(x,y);
image.draw(surf, width, height);
surface.setColor(Color.BLUE);
surface.fillRect(-5, -5, 10, 10);
surf.dispose();

And this does draw as expected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top