Christopher Townsend
Christopher Townsend

Reputation: 1746

Shape Renderer Increasing Square Size Not Uniform

So I have an actor object I extended that will either draw a square or a circle, every frame it increases in size by 0.1.

When I draw circle it increases in size correctly and grows on screen, however when I draw a rect it jumps in size every 2.0 increments. I was wondering if anyone else had seen this behaviour.

Here is the simple code I use to draw the shapes.

  float size = 10.0f;

    @Override
    public void draw(Batch batch, float parentAlpha) {

        super.draw(batch, parentAlpha);

        ShapeRenderer r = new ShapeRenderer();

        r.begin(ShapeRenderer.ShapeType.Filled);
        r.setColor(Color.RED);

        //r.circle(this.getX() - (size / 2), this.getY() - (size / 2), size);  //this increases correctly
        r.rect(this.getX() - (size / 2), this.getY() - (size / 2), size, size);  //this doesnt

        r.end();

        size += 0.1f;

    }

So you can see what I mean I took some vids:

Circle : https://youtu.be/TtLcMxUCKb0

Square : https://youtu.be/UUGNfSpotKo

Upvotes: 2

Views: 72

Answers (1)

tobloef
tobloef

Reputation: 1891

Seems to me like the square is expanding the least amount it can, 1 pixel at a time, it just looks a bit different from the circle since the circle does more than just expand 1 pixel to each side It has to the circle always look as round as possible, so updates a bit more often, shifting around a few pixel but not expanding.

Upvotes: 2

Related Questions