mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Fix so shapes rotated too
This commit is contained in:
@@ -622,10 +622,10 @@ public class Forge implements ApplicationListener {
|
|||||||
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH);
|
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
shapeRenderer.begin(ShapeType.Line);
|
startShape(ShapeType.Line);
|
||||||
shapeRenderer.setColor(color);
|
shapeRenderer.setColor(color);
|
||||||
shapeRenderer.line(adjustX(x1), adjustY(y1, 0), adjustX(x2), adjustY(y2, 0));
|
shapeRenderer.line(adjustX(x1), adjustY(y1, 0), adjustX(x2), adjustY(y2, 0));
|
||||||
shapeRenderer.end();
|
endShape();
|
||||||
|
|
||||||
if (needSmoothing) {
|
if (needSmoothing) {
|
||||||
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
||||||
@@ -663,7 +663,7 @@ public class Forge implements ApplicationListener {
|
|||||||
w = Math.round(w - 1);
|
w = Math.round(w - 1);
|
||||||
h = Math.round(h - 1);
|
h = Math.round(h - 1);
|
||||||
|
|
||||||
shapeRenderer.begin(ShapeType.Line);
|
startShape(ShapeType.Line);
|
||||||
shapeRenderer.setColor(color);
|
shapeRenderer.setColor(color);
|
||||||
|
|
||||||
x = adjustX(x);
|
x = adjustX(x);
|
||||||
@@ -676,7 +676,7 @@ public class Forge implements ApplicationListener {
|
|||||||
shapeRenderer.line(x2, y2, x2, y);
|
shapeRenderer.line(x2, y2, x2, y);
|
||||||
shapeRenderer.line(x2 + 1, y, x, y); //+1 prevents corner not being filled
|
shapeRenderer.line(x2 + 1, y, x, y); //+1 prevents corner not being filled
|
||||||
|
|
||||||
shapeRenderer.end();
|
endShape();
|
||||||
|
|
||||||
if (cornerRadius > 0) {
|
if (cornerRadius > 0) {
|
||||||
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
||||||
@@ -706,10 +706,10 @@ public class Forge implements ApplicationListener {
|
|||||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||||
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); //must be smooth to ensure edges aren't missed
|
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); //must be smooth to ensure edges aren't missed
|
||||||
|
|
||||||
shapeRenderer.begin(ShapeType.Line);
|
startShape(ShapeType.Line);
|
||||||
shapeRenderer.setColor(color);
|
shapeRenderer.setColor(color);
|
||||||
shapeRenderer.rect(adjustX(x), adjustY(y, h), w, h);
|
shapeRenderer.rect(adjustX(x), adjustY(y, h), w, h);
|
||||||
shapeRenderer.end();
|
endShape();
|
||||||
|
|
||||||
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
||||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||||
@@ -733,10 +733,10 @@ public class Forge implements ApplicationListener {
|
|||||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
shapeRenderer.begin(ShapeType.Filled);
|
startShape(ShapeType.Filled);
|
||||||
shapeRenderer.setColor(color);
|
shapeRenderer.setColor(color);
|
||||||
shapeRenderer.rect(adjustX(x), adjustY(y, h), w, h);
|
shapeRenderer.rect(adjustX(x), adjustY(y, h), w, h);
|
||||||
shapeRenderer.end();
|
endShape();
|
||||||
|
|
||||||
if (color.a < 1) {
|
if (color.a < 1) {
|
||||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||||
@@ -760,10 +760,10 @@ public class Forge implements ApplicationListener {
|
|||||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||||
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH);
|
Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH);
|
||||||
|
|
||||||
shapeRenderer.begin(ShapeType.Line);
|
startShape(ShapeType.Line);
|
||||||
shapeRenderer.setColor(color);
|
shapeRenderer.setColor(color);
|
||||||
shapeRenderer.circle(adjustX(x), adjustY(y, 0), radius);
|
shapeRenderer.circle(adjustX(x), adjustY(y, 0), radius);
|
||||||
shapeRenderer.end();
|
endShape();
|
||||||
|
|
||||||
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
Gdx.gl.glDisable(GL10.GL_LINE_SMOOTH);
|
||||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||||
@@ -787,10 +787,10 @@ public class Forge implements ApplicationListener {
|
|||||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
shapeRenderer.begin(ShapeType.Filled);
|
startShape(ShapeType.Filled);
|
||||||
shapeRenderer.setColor(color);
|
shapeRenderer.setColor(color);
|
||||||
shapeRenderer.circle(adjustX(x), adjustY(y, 0), radius); //TODO: Make smoother
|
shapeRenderer.circle(adjustX(x), adjustY(y, 0), radius); //TODO: Make smoother
|
||||||
shapeRenderer.end();
|
endShape();
|
||||||
|
|
||||||
if (color.a < 1) {
|
if (color.a < 1) {
|
||||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||||
@@ -812,10 +812,10 @@ public class Forge implements ApplicationListener {
|
|||||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
shapeRenderer.begin(ShapeType.Filled);
|
startShape(ShapeType.Filled);
|
||||||
shapeRenderer.setColor(color);
|
shapeRenderer.setColor(color);
|
||||||
shapeRenderer.triangle(adjustX(x1), adjustY(y1, 0), adjustX(x2), adjustY(y2, 0), adjustX(x3), adjustY(y3, 0));
|
shapeRenderer.triangle(adjustX(x1), adjustY(y1, 0), adjustX(x2), adjustY(y2, 0), adjustX(x3), adjustY(y3, 0));
|
||||||
shapeRenderer.end();
|
endShape();
|
||||||
|
|
||||||
if (color.a < 1) {
|
if (color.a < 1) {
|
||||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||||
@@ -850,9 +850,9 @@ public class Forge implements ApplicationListener {
|
|||||||
Color bottomLeftColor = vertical ? color2 : color1;
|
Color bottomLeftColor = vertical ? color2 : color1;
|
||||||
Color bottomRightColor = color2;
|
Color bottomRightColor = color2;
|
||||||
|
|
||||||
shapeRenderer.begin(ShapeType.Filled);
|
startShape(ShapeType.Filled);
|
||||||
shapeRenderer.rect(adjustX(x), adjustY(y, h), w, h, bottomLeftColor, bottomRightColor, topRightColor, topLeftColor);
|
shapeRenderer.rect(adjustX(x), adjustY(y, h), w, h, bottomLeftColor, bottomRightColor, topRightColor, topLeftColor);
|
||||||
shapeRenderer.end();
|
endShape();
|
||||||
|
|
||||||
if (needBlending) {
|
if (needBlending) {
|
||||||
Gdx.gl.glDisable(GL20.GL_BLEND);
|
Gdx.gl.glDisable(GL20.GL_BLEND);
|
||||||
@@ -861,6 +861,18 @@ public class Forge implements ApplicationListener {
|
|||||||
batch.begin();
|
batch.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startShape(ShapeType shapeType) {
|
||||||
|
if (isTransformed) {
|
||||||
|
//must copy matrix before starting shape if transformed
|
||||||
|
shapeRenderer.setTransformMatrix(batch.getTransformMatrix());
|
||||||
|
}
|
||||||
|
shapeRenderer.begin(shapeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void endShape() {
|
||||||
|
shapeRenderer.end();
|
||||||
|
}
|
||||||
|
|
||||||
public void setAlphaComposite(float alphaComposite0) {
|
public void setAlphaComposite(float alphaComposite0) {
|
||||||
alphaComposite = alphaComposite0;
|
alphaComposite = alphaComposite0;
|
||||||
batch.setColor(new Color(1, 1, 1, alphaComposite));
|
batch.setColor(new Color(1, 1, 1, alphaComposite));
|
||||||
@@ -893,6 +905,8 @@ public class Forge implements ApplicationListener {
|
|||||||
endClip();
|
endClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isTransformed;
|
||||||
|
|
||||||
public void setRotateTransform(float originX, float originY, float rotation) {
|
public void setRotateTransform(float originX, float originY, float rotation) {
|
||||||
batch.end();
|
batch.end();
|
||||||
float dx = adjustX(originX);
|
float dx = adjustX(originX);
|
||||||
@@ -901,13 +915,15 @@ public class Forge implements ApplicationListener {
|
|||||||
batch.getTransformMatrix().rotate(Vector3.Z, rotation);
|
batch.getTransformMatrix().rotate(Vector3.Z, rotation);
|
||||||
batch.getTransformMatrix().translate(-dx, -dy, 0);
|
batch.getTransformMatrix().translate(-dx, -dy, 0);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
//shapeRenderer.setTransformMatrix(matrix);
|
isTransformed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearTransform() {
|
public void clearTransform() {
|
||||||
batch.end();
|
batch.end();
|
||||||
batch.getTransformMatrix().idt();
|
batch.getTransformMatrix().idt();
|
||||||
|
shapeRenderer.setTransformMatrix(batch.getTransformMatrix());
|
||||||
batch.begin();
|
batch.begin();
|
||||||
|
isTransformed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawRotatedImage(Texture image, float x, float y, float w, float h, float originX, float originY, float rotation) {
|
public void drawRotatedImage(Texture image, float x, float y, float w, float h, float originX, float originY, float rotation) {
|
||||||
|
|||||||
Reference in New Issue
Block a user