Example usage for com.badlogic.gdx.math Polygon setOrigin

List of usage examples for com.badlogic.gdx.math Polygon setOrigin

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Polygon setOrigin.

Prototype

public void setOrigin(float originX, float originY) 

Source Link

Document

Sets the origin point to which all of the polygon's local vertices are relative to.

Usage

From source file:com.kotcrab.vis.runtime.entity.TextEntity.java

License:Apache License

private void calculateBoundingRectangle() {
    Polygon polygon = new Polygon(new float[] { 0, 0, textLayout.width, 0, textLayout.width, textLayout.height,
            0, textLayout.height });//from   w  w  w .  java 2 s  . c om
    polygon.setPosition(x, y);
    polygon.setRotation(rotation);
    polygon.setScale(scaleX, scaleY);
    polygon.setOrigin(originX, originY);
    boundingRectangle = polygon.getBoundingRectangle();
}

From source file:de.gebatzens.meteva.GScout.java

License:Open Source License

public static Polygon createPolygon(float width, float height) {
    Polygon p = new Polygon(new float[] { 0, 0, width, 0, width, height, 0, height });
    p.setOrigin(width / 2, height / 2);
    return p;/*from   w  ww  . j  av a 2s  .co  m*/
}

From source file:de.gebatzens.meteva.GScout.java

License:Open Source License

public static Polygon createCirclePolygon(float radius) {
    float[] verts = new float[30];
    int index = 0;
    for (int i = 0; i < 360; i += 24) {
        verts[index] = (float) (Math.cos(Math.toRadians(i)) * radius + radius);
        verts[index + 1] = (float) (Math.sin(Math.toRadians(i)) * radius + radius);
        index += 2;//  ww w.  j av  a2s.c  o m
    }
    Polygon p = new Polygon(verts);
    p.setOrigin(radius, radius);
    return p;
}

From source file:org.catrobat.catroid.content.Look.java

License:Open Source License

public Polygon[] getCurrentCollisionPolygon() {
    Polygon[] originalPolygons;/*from  w  w  w .j a va2s. c  o m*/
    if (getLookData() == null) {
        originalPolygons = new Polygon[0];
    } else {
        if (getLookData().getCollisionInformation().collisionPolygons == null) {
            getLookData().getCollisionInformation().loadOrCreateCollisionPolygon();
        }
        originalPolygons = getLookData().getCollisionInformation().collisionPolygons;
    }

    Polygon[] transformedPolygons = new Polygon[originalPolygons.length];

    for (int p = 0; p < transformedPolygons.length; p++) {
        Polygon poly = new Polygon(originalPolygons[p].getTransformedVertices());
        poly.translate(getX(), getY());
        poly.setRotation(getRotation());
        poly.setScale(getScaleX(), getScaleY());
        poly.setOrigin(getOriginX(), getOriginY());
        transformedPolygons[p] = poly;
    }
    return transformedPolygons;
}

From source file:pl.kotcrab.libgdx.util.Text.java

License:Apache License

private void calculateBoundingRectangle() {
    Polygon polygon = new Polygon(new float[] { 0, 0, textBounds.width, 0, textBounds.width, textBounds.height,
            0, textBounds.height });//w ww.  j a v a2  s. c o m

    polygon.setPosition(gx, gy);
    polygon.setRotation(rotation);
    polygon.setScale(scaleX, scaleY);
    polygon.setOrigin(originX, originY);

    boundingRectangle = polygon.getBoundingRectangle();
}