문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top