Painting with AffineTransform

Jump to navigation Jump to search

Painting with AffineTransform

Anyone played around with trying to use an AffineTransform when painting on the battle field? If I so much as make an exact clone of the existing AffineTransform associated with the Graphics2D object and set the clone as the transform, nothing gets painted to the battlefield. Not sure what is going on there. Maybe something weird Robocode is doing. Example:

public void onPaint(Graphics2D g) {
	AffineTransform clone = new AffineTransform(g.getTransform());
	g.setTransform(clone);
	// paint something here
}

This will result in nothing being painted. Remove setting the transform, and it paints fine.

I'm trying to figure out how to shift the paint position for a paint framework I am trying to write. The general idea in play here is developing a means for moving informational displays around on the screen. I can't get the AffineTransform to work. I also tried to cheat and use graphics from a BufferedImage, then draw the image onto the battle field, but Robocode doesn't allow the use of the drawImage methods.

I would appreciate any information anyone has on using AffineTransform in Robocode, or any other ideas on how I might accomplish what I am trying to do.

Skotty05:44, 2 November 2011

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

Return to Thread:User talk:Skotty/Painting with AffineTransform/reply.