Example usage for com.badlogic.gdx.math Vector2 rotateRad

List of usage examples for com.badlogic.gdx.math Vector2 rotateRad

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Vector2 rotateRad.

Prototype

public Vector2 rotateRad(float radians) 

Source Link

Document

Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up.

Usage

From source file:org.ams.testapps.prettypaint.JaggedPolygon.java

License:Open Source License

@Override
public void create() {
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    Gdx.input.setInputProcessor(this);

    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();
    camera = new OrthographicCamera(10, 10 * (h / w));

    // create the circleVertices used for all 3 polygons

    float radius = 2f;
    Vector2 v = new Vector2(radius, 0);
    float angle = MathUtils.PI2 / 50f;
    for (float rad = 0; rad <= MathUtils.PI2; rad += angle) {
        v.rotateRad(angle);
        vertices.add(new Vector2(v).scl(MathUtils.random(1f, 2f)));
    }//from  w w  w.  j  a v a 2  s  .co  m

    polygonBatch = new PrettyPolygonBatch();

    outlinePolygon = new OutlinePolygon();
    outlinePolygon.setVertices(vertices);
    outlinePolygon.setColor(Color.BLACK);

    shadowPolygon = new OutlinePolygon();
    shadowPolygon.setDrawInside(false);
    shadowPolygon.setVertices(vertices);
    shadowPolygon.setColor(new Color(0, 0, 0, 0.4f));
    shadowPolygon.setHalfWidth(outlinePolygon.getHalfWidth() * 5);

    //shadowPolygon.setDrawFrustum(batch,true);
    //shadowPolygon.setDrawCullingRectangles(true);
    //shadowPolygon.setDrawTriangleStrips(false);
    //shadowPolygon.setDrawLineFromFirstToLast(true);

    texture = new Texture("images/for packing/backgrounds-dark/escheresque_ste.png");
    texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    texturePolygon = new TexturePolygon();
    texturePolygon.setTextureRegion(new TextureRegion(texture));
    texturePolygon.setVertices(vertices);

}