Issue #19 new

Shapes are not symmetrical.

Jeremiah Senkpiel
created an issue

Shapes fail to be symmetrical.

Rectangles and squares are curved in the bottom-left corner.

Rounded rectangles have (or sometimes have) different curves for each corner.

RoundedRectangle(x, y, 30, 30, 7) Creates an uneven shape (see attachment).

This is a major issue when trying to make any UI composed of drawn shapes.

Comments (3)

  1. mlemaudit

    It seems that there are at least 2 ways to deal with Rounded Rectangles :

    1. Use the Graphics.drawRoundRect() method
    2. Use the RoudedRectangle object

    Curiously, the Graphics.drawRoundRect() method doesn't use the RoundedRectangle object, but it's own code.

    Both ways are not completely satisfying, but Graphics.drawRoundRect() seems to have nicer results compared to the rectangle built with the same parameters.

    Here's a little code to demonstrate this :

    import org.newdawn.slick.AppGameContainer;
    import org.newdawn.slick.BasicGame;
    import org.newdawn.slick.GameContainer;
    import org.newdawn.slick.Graphics;
    import org.newdawn.slick.SlickException;
    import org.newdawn.slick.geom.RoundedRectangle;
    import org.newdawn.slick.geom.Shape;
    import org.newdawn.slick.Color;
    
    public class RoundedRectangleTest extends BasicGame {
    
        public RoundedRectangleTest() {
            super( "Rounded Rectangle Test" );
        }
    
        public void init( GameContainer gc )
            throws SlickException {
        }
    
        public void update( GameContainer gc, int delta )
            throws SlickException {
    
        }
    
        public void render( GameContainer gc, Graphics g )
            throws SlickException {
    
            // this is the rectangle shape used to verify the rounded rectangles
            g.setColor( Color.white );
            g.drawRect( 50, 50, 100, 30 );
    
            // in red : Graphics.drawRoundRect() method
            g.setColor( Color.red );
            g.drawRoundRect( 50, 50, 100, 30, 7 );
    
            // in blue : RoudedRectangle object drawn by Graphics.draw() method
            g.setColor( Color.blue );
            Shape rr = new RoundedRectangle( 50, 50, 100, 30, 7 );
            g.draw( rr );
        }
    
        public static void main( String[] args )
            throws SlickException {
    
            AppGameContainer app = new AppGameContainer( new RoundedRectangleTest() );
    
            app.setDisplayMode( 200, 100, false );
            app.start();
        }
    }
    
  2. Log in to comment