Java Code Examples for org.newdawn.slick.geom.Rectangle#transform()

The following examples show how to use org.newdawn.slick.geom.Rectangle#transform() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RectProcessor.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.svg.inkscape.ElementProcessor#process(org.newdawn.slick.svg.Loader, org.w3c.dom.Element, org.newdawn.slick.svg.Diagram, org.newdawn.slick.geom.Transform)
 */
public void process(Loader loader, Element element, Diagram diagram, Transform t) throws ParsingException {
	Transform transform = Util.getTransform(element);
    transform = new Transform(t, transform); 
	
	float width = Float.parseFloat(element.getAttribute("width"));
	float height = Float.parseFloat(element.getAttribute("height"));
	float x = Float.parseFloat(element.getAttribute("x"));
	float y = Float.parseFloat(element.getAttribute("y"));
	
	Rectangle rect = new Rectangle(x,y,width+1,height+1);
	Shape shape = rect.transform(transform);
	
	NonGeometricData data = Util.getNonGeometricData(element);
	data.addAttribute("width", ""+width);
	data.addAttribute("height", ""+height);
	data.addAttribute("x", ""+x);
	data.addAttribute("y", ""+y);
	
	diagram.addFigure(new Figure(Figure.RECTANGLE, shape, data, transform));
}
 
Example 2
Source File: MorphShapeTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see BasicGame#init(GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	a = new Rectangle(100,100,50,200);
	a = a.transform(Transform.createRotateTransform(0.1f,100,100));
	b = new Rectangle(200,100,50,200);
	b = b.transform(Transform.createRotateTransform(-0.6f,100,100));
	c = new Rectangle(300,100,50,200);
	c = c.transform(Transform.createRotateTransform(-0.2f,100,100));
	
	morph = new MorphShape(a);
	morph.addShape(b);
	morph.addShape(c);
	
	container.setVSync(true);
}