mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
614 lines
21 KiB
Java
614 lines
21 KiB
Java
package com.google.android.material.shape;
|
|
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Matrix;
|
|
import android.graphics.Path;
|
|
import android.graphics.RectF;
|
|
import com.google.android.material.shadow.ShadowRenderer;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class ShapePath {
|
|
protected static final float ANGLE_LEFT = 180.0f;
|
|
private static final float ANGLE_UP = 270.0f;
|
|
private boolean containsIncompatibleShadowOp;
|
|
|
|
@Deprecated
|
|
public float currentShadowAngle;
|
|
|
|
@Deprecated
|
|
public float endShadowAngle;
|
|
|
|
@Deprecated
|
|
public float endX;
|
|
|
|
@Deprecated
|
|
public float endY;
|
|
private final List<PathOperation> operations = new ArrayList();
|
|
private final List<ShadowCompatOperation> shadowCompatOperations = new ArrayList();
|
|
|
|
@Deprecated
|
|
public float startX;
|
|
|
|
@Deprecated
|
|
public float startY;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static abstract class PathOperation {
|
|
protected final Matrix matrix = new Matrix();
|
|
|
|
public abstract void applyToPath(Matrix matrix, Path path);
|
|
}
|
|
|
|
private float getCurrentShadowAngle() {
|
|
return this.currentShadowAngle;
|
|
}
|
|
|
|
private float getEndShadowAngle() {
|
|
return this.endShadowAngle;
|
|
}
|
|
|
|
private void setCurrentShadowAngle(float f) {
|
|
this.currentShadowAngle = f;
|
|
}
|
|
|
|
private void setEndShadowAngle(float f) {
|
|
this.endShadowAngle = f;
|
|
}
|
|
|
|
private void setEndX(float f) {
|
|
this.endX = f;
|
|
}
|
|
|
|
private void setEndY(float f) {
|
|
this.endY = f;
|
|
}
|
|
|
|
private void setStartX(float f) {
|
|
this.startX = f;
|
|
}
|
|
|
|
private void setStartY(float f) {
|
|
this.startY = f;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public boolean containsIncompatibleShadowOp() {
|
|
return this.containsIncompatibleShadowOp;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public float getEndX() {
|
|
return this.endX;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public float getEndY() {
|
|
return this.endY;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public float getStartX() {
|
|
return this.startX;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public float getStartY() {
|
|
return this.startY;
|
|
}
|
|
|
|
public ShapePath() {
|
|
reset(0.0f, 0.0f);
|
|
}
|
|
|
|
public ShapePath(float f, float f2) {
|
|
reset(f, f2);
|
|
}
|
|
|
|
public void reset(float f, float f2) {
|
|
reset(f, f2, ANGLE_UP, 0.0f);
|
|
}
|
|
|
|
public void reset(float f, float f2, float f3, float f4) {
|
|
setStartX(f);
|
|
setStartY(f2);
|
|
setEndX(f);
|
|
setEndY(f2);
|
|
setCurrentShadowAngle(f3);
|
|
setEndShadowAngle((f3 + f4) % 360.0f);
|
|
this.operations.clear();
|
|
this.shadowCompatOperations.clear();
|
|
this.containsIncompatibleShadowOp = false;
|
|
}
|
|
|
|
public void lineTo(float f, float f2) {
|
|
PathLineOperation pathLineOperation = new PathLineOperation();
|
|
pathLineOperation.x = f;
|
|
pathLineOperation.y = f2;
|
|
this.operations.add(pathLineOperation);
|
|
LineShadowOperation lineShadowOperation = new LineShadowOperation(pathLineOperation, getEndX(), getEndY());
|
|
addShadowCompatOperation(lineShadowOperation, lineShadowOperation.getAngle() + ANGLE_UP, lineShadowOperation.getAngle() + ANGLE_UP);
|
|
setEndX(f);
|
|
setEndY(f2);
|
|
}
|
|
|
|
public void lineTo(float f, float f2, float f3, float f4) {
|
|
if ((Math.abs(f - getEndX()) < 0.001f && Math.abs(f2 - getEndY()) < 0.001f) || (Math.abs(f - f3) < 0.001f && Math.abs(f2 - f4) < 0.001f)) {
|
|
lineTo(f3, f4);
|
|
return;
|
|
}
|
|
PathLineOperation pathLineOperation = new PathLineOperation();
|
|
pathLineOperation.x = f;
|
|
pathLineOperation.y = f2;
|
|
this.operations.add(pathLineOperation);
|
|
PathLineOperation pathLineOperation2 = new PathLineOperation();
|
|
pathLineOperation2.x = f3;
|
|
pathLineOperation2.y = f4;
|
|
this.operations.add(pathLineOperation2);
|
|
InnerCornerShadowOperation innerCornerShadowOperation = new InnerCornerShadowOperation(pathLineOperation, pathLineOperation2, getEndX(), getEndY());
|
|
if (innerCornerShadowOperation.getSweepAngle() > 0.0f) {
|
|
lineTo(f, f2);
|
|
lineTo(f3, f4);
|
|
} else {
|
|
addShadowCompatOperation(innerCornerShadowOperation, innerCornerShadowOperation.getStartAngle() + ANGLE_UP, innerCornerShadowOperation.getEndAngle() + ANGLE_UP);
|
|
setEndX(f3);
|
|
setEndY(f4);
|
|
}
|
|
}
|
|
|
|
public void quadToPoint(float f, float f2, float f3, float f4) {
|
|
PathQuadOperation pathQuadOperation = new PathQuadOperation();
|
|
pathQuadOperation.setControlX(f);
|
|
pathQuadOperation.setControlY(f2);
|
|
pathQuadOperation.setEndX(f3);
|
|
pathQuadOperation.setEndY(f4);
|
|
this.operations.add(pathQuadOperation);
|
|
this.containsIncompatibleShadowOp = true;
|
|
setEndX(f3);
|
|
setEndY(f4);
|
|
}
|
|
|
|
public void cubicToPoint(float f, float f2, float f3, float f4, float f5, float f6) {
|
|
this.operations.add(new PathCubicOperation(f, f2, f3, f4, f5, f6));
|
|
this.containsIncompatibleShadowOp = true;
|
|
setEndX(f5);
|
|
setEndY(f6);
|
|
}
|
|
|
|
public void addArc(float f, float f2, float f3, float f4, float f5, float f6) {
|
|
PathArcOperation pathArcOperation = new PathArcOperation(f, f2, f3, f4);
|
|
pathArcOperation.setStartAngle(f5);
|
|
pathArcOperation.setSweepAngle(f6);
|
|
this.operations.add(pathArcOperation);
|
|
ArcShadowOperation arcShadowOperation = new ArcShadowOperation(pathArcOperation);
|
|
float f7 = f5 + f6;
|
|
boolean z = f6 < 0.0f;
|
|
if (z) {
|
|
f5 = (f5 + ANGLE_LEFT) % 360.0f;
|
|
}
|
|
addShadowCompatOperation(arcShadowOperation, f5, z ? (ANGLE_LEFT + f7) % 360.0f : f7);
|
|
double d = f7;
|
|
setEndX(((f + f3) * 0.5f) + (((f3 - f) / 2.0f) * ((float) Math.cos(Math.toRadians(d)))));
|
|
setEndY(((f2 + f4) * 0.5f) + (((f4 - f2) / 2.0f) * ((float) Math.sin(Math.toRadians(d)))));
|
|
}
|
|
|
|
public void applyToPath(Matrix matrix, Path path) {
|
|
int size = this.operations.size();
|
|
for (int i = 0; i < size; i++) {
|
|
this.operations.get(i).applyToPath(matrix, path);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public ShadowCompatOperation createShadowCompatOperation(Matrix matrix) {
|
|
addConnectingShadowIfNecessary(getEndShadowAngle());
|
|
final Matrix matrix2 = new Matrix(matrix);
|
|
final ArrayList arrayList = new ArrayList(this.shadowCompatOperations);
|
|
return new ShadowCompatOperation() { // from class: com.google.android.material.shape.ShapePath.1
|
|
@Override // com.google.android.material.shape.ShapePath.ShadowCompatOperation
|
|
public void draw(Matrix matrix3, ShadowRenderer shadowRenderer, int i, Canvas canvas) {
|
|
Iterator it = arrayList.iterator();
|
|
while (it.hasNext()) {
|
|
((ShadowCompatOperation) it.next()).draw(matrix2, shadowRenderer, i, canvas);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
private void addShadowCompatOperation(ShadowCompatOperation shadowCompatOperation, float f, float f2) {
|
|
addConnectingShadowIfNecessary(f);
|
|
this.shadowCompatOperations.add(shadowCompatOperation);
|
|
setCurrentShadowAngle(f2);
|
|
}
|
|
|
|
private void addConnectingShadowIfNecessary(float f) {
|
|
if (getCurrentShadowAngle() == f) {
|
|
return;
|
|
}
|
|
float currentShadowAngle = ((f - getCurrentShadowAngle()) + 360.0f) % 360.0f;
|
|
if (currentShadowAngle > ANGLE_LEFT) {
|
|
return;
|
|
}
|
|
PathArcOperation pathArcOperation = new PathArcOperation(getEndX(), getEndY(), getEndX(), getEndY());
|
|
pathArcOperation.setStartAngle(getCurrentShadowAngle());
|
|
pathArcOperation.setSweepAngle(currentShadowAngle);
|
|
this.shadowCompatOperations.add(new ArcShadowOperation(pathArcOperation));
|
|
setCurrentShadowAngle(f);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static abstract class ShadowCompatOperation {
|
|
static final Matrix IDENTITY_MATRIX = new Matrix();
|
|
final Matrix renderMatrix = new Matrix();
|
|
|
|
public abstract void draw(Matrix matrix, ShadowRenderer shadowRenderer, int i, Canvas canvas);
|
|
|
|
ShadowCompatOperation() {
|
|
}
|
|
|
|
public final void draw(ShadowRenderer shadowRenderer, int i, Canvas canvas) {
|
|
draw(IDENTITY_MATRIX, shadowRenderer, i, canvas);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static class LineShadowOperation extends ShadowCompatOperation {
|
|
private final PathLineOperation operation;
|
|
private final float startX;
|
|
private final float startY;
|
|
|
|
public LineShadowOperation(PathLineOperation pathLineOperation, float f, float f2) {
|
|
this.operation = pathLineOperation;
|
|
this.startX = f;
|
|
this.startY = f2;
|
|
}
|
|
|
|
@Override // com.google.android.material.shape.ShapePath.ShadowCompatOperation
|
|
public void draw(Matrix matrix, ShadowRenderer shadowRenderer, int i, Canvas canvas) {
|
|
RectF rectF = new RectF(0.0f, 0.0f, (float) Math.hypot(this.operation.y - this.startY, this.operation.x - this.startX), 0.0f);
|
|
this.renderMatrix.set(matrix);
|
|
this.renderMatrix.preTranslate(this.startX, this.startY);
|
|
this.renderMatrix.preRotate(getAngle());
|
|
shadowRenderer.drawEdgeShadow(canvas, this.renderMatrix, rectF, i);
|
|
}
|
|
|
|
float getAngle() {
|
|
return (float) Math.toDegrees(Math.atan((this.operation.y - this.startY) / (this.operation.x - this.startX)));
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
static class InnerCornerShadowOperation extends ShadowCompatOperation {
|
|
private final PathLineOperation operation1;
|
|
private final PathLineOperation operation2;
|
|
private final float startX;
|
|
private final float startY;
|
|
|
|
public InnerCornerShadowOperation(PathLineOperation pathLineOperation, PathLineOperation pathLineOperation2, float f, float f2) {
|
|
this.operation1 = pathLineOperation;
|
|
this.operation2 = pathLineOperation2;
|
|
this.startX = f;
|
|
this.startY = f2;
|
|
}
|
|
|
|
@Override // com.google.android.material.shape.ShapePath.ShadowCompatOperation
|
|
public void draw(Matrix matrix, ShadowRenderer shadowRenderer, int i, Canvas canvas) {
|
|
ShadowRenderer shadowRenderer2;
|
|
float sweepAngle = getSweepAngle();
|
|
if (sweepAngle > 0.0f) {
|
|
return;
|
|
}
|
|
double hypot = Math.hypot(this.operation1.x - this.startX, this.operation1.y - this.startY);
|
|
double hypot2 = Math.hypot(this.operation2.x - this.operation1.x, this.operation2.y - this.operation1.y);
|
|
float min = (float) Math.min(i, Math.min(hypot, hypot2));
|
|
double d = min;
|
|
double tan = Math.tan(Math.toRadians((-sweepAngle) / 2.0f)) * d;
|
|
if (hypot > tan) {
|
|
RectF rectF = new RectF(0.0f, 0.0f, (float) (hypot - tan), 0.0f);
|
|
this.renderMatrix.set(matrix);
|
|
this.renderMatrix.preTranslate(this.startX, this.startY);
|
|
this.renderMatrix.preRotate(getStartAngle());
|
|
shadowRenderer2 = shadowRenderer;
|
|
shadowRenderer2.drawEdgeShadow(canvas, this.renderMatrix, rectF, i);
|
|
} else {
|
|
shadowRenderer2 = shadowRenderer;
|
|
}
|
|
float f = 2.0f * min;
|
|
RectF rectF2 = new RectF(0.0f, 0.0f, f, f);
|
|
this.renderMatrix.set(matrix);
|
|
this.renderMatrix.preTranslate(this.operation1.x, this.operation1.y);
|
|
this.renderMatrix.preRotate(getStartAngle());
|
|
this.renderMatrix.preTranslate((float) ((-tan) - d), (-2.0f) * min);
|
|
shadowRenderer.drawInnerCornerShadow(canvas, this.renderMatrix, rectF2, (int) min, 450.0f, sweepAngle, new float[]{(float) (d + tan), f});
|
|
if (hypot2 > tan) {
|
|
RectF rectF3 = new RectF(0.0f, 0.0f, (float) (hypot2 - tan), 0.0f);
|
|
this.renderMatrix.set(matrix);
|
|
this.renderMatrix.preTranslate(this.operation1.x, this.operation1.y);
|
|
this.renderMatrix.preRotate(getEndAngle());
|
|
this.renderMatrix.preTranslate((float) tan, 0.0f);
|
|
shadowRenderer2.drawEdgeShadow(canvas, this.renderMatrix, rectF3, i);
|
|
}
|
|
}
|
|
|
|
float getStartAngle() {
|
|
return (float) Math.toDegrees(Math.atan((this.operation1.y - this.startY) / (this.operation1.x - this.startX)));
|
|
}
|
|
|
|
float getEndAngle() {
|
|
return (float) Math.toDegrees(Math.atan((this.operation2.y - this.operation1.y) / (this.operation2.x - this.operation1.x)));
|
|
}
|
|
|
|
float getSweepAngle() {
|
|
float endAngle = ((getEndAngle() - getStartAngle()) + 360.0f) % 360.0f;
|
|
return endAngle <= ShapePath.ANGLE_LEFT ? endAngle : endAngle - 360.0f;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static class ArcShadowOperation extends ShadowCompatOperation {
|
|
private final PathArcOperation operation;
|
|
|
|
public ArcShadowOperation(PathArcOperation pathArcOperation) {
|
|
this.operation = pathArcOperation;
|
|
}
|
|
|
|
@Override // com.google.android.material.shape.ShapePath.ShadowCompatOperation
|
|
public void draw(Matrix matrix, ShadowRenderer shadowRenderer, int i, Canvas canvas) {
|
|
shadowRenderer.drawCornerShadow(canvas, matrix, new RectF(this.operation.getLeft(), this.operation.getTop(), this.operation.getRight(), this.operation.getBottom()), i, this.operation.getStartAngle(), this.operation.getSweepAngle());
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class PathLineOperation extends PathOperation {
|
|
private float x;
|
|
private float y;
|
|
|
|
@Override // com.google.android.material.shape.ShapePath.PathOperation
|
|
public void applyToPath(Matrix matrix, Path path) {
|
|
Matrix matrix2 = this.matrix;
|
|
matrix.invert(matrix2);
|
|
path.transform(matrix2);
|
|
path.lineTo(this.x, this.y);
|
|
path.transform(matrix);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class PathQuadOperation extends PathOperation {
|
|
|
|
@Deprecated
|
|
public float controlX;
|
|
|
|
@Deprecated
|
|
public float controlY;
|
|
|
|
@Deprecated
|
|
public float endX;
|
|
|
|
@Deprecated
|
|
public float endY;
|
|
|
|
private float getControlX() {
|
|
return this.controlX;
|
|
}
|
|
|
|
private float getControlY() {
|
|
return this.controlY;
|
|
}
|
|
|
|
private float getEndX() {
|
|
return this.endX;
|
|
}
|
|
|
|
private float getEndY() {
|
|
return this.endY;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void setControlX(float f) {
|
|
this.controlX = f;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void setControlY(float f) {
|
|
this.controlY = f;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void setEndX(float f) {
|
|
this.endX = f;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void setEndY(float f) {
|
|
this.endY = f;
|
|
}
|
|
|
|
@Override // com.google.android.material.shape.ShapePath.PathOperation
|
|
public void applyToPath(Matrix matrix, Path path) {
|
|
Matrix matrix2 = this.matrix;
|
|
matrix.invert(matrix2);
|
|
path.transform(matrix2);
|
|
path.quadTo(getControlX(), getControlY(), getEndX(), getEndY());
|
|
path.transform(matrix);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class PathArcOperation extends PathOperation {
|
|
private static final RectF rectF = new RectF();
|
|
|
|
@Deprecated
|
|
public float bottom;
|
|
|
|
@Deprecated
|
|
public float left;
|
|
|
|
@Deprecated
|
|
public float right;
|
|
|
|
@Deprecated
|
|
public float startAngle;
|
|
|
|
@Deprecated
|
|
public float sweepAngle;
|
|
|
|
@Deprecated
|
|
public float top;
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public float getBottom() {
|
|
return this.bottom;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public float getLeft() {
|
|
return this.left;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public float getRight() {
|
|
return this.right;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public float getStartAngle() {
|
|
return this.startAngle;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public float getSweepAngle() {
|
|
return this.sweepAngle;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public float getTop() {
|
|
return this.top;
|
|
}
|
|
|
|
private void setBottom(float f) {
|
|
this.bottom = f;
|
|
}
|
|
|
|
private void setLeft(float f) {
|
|
this.left = f;
|
|
}
|
|
|
|
private void setRight(float f) {
|
|
this.right = f;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void setStartAngle(float f) {
|
|
this.startAngle = f;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void setSweepAngle(float f) {
|
|
this.sweepAngle = f;
|
|
}
|
|
|
|
private void setTop(float f) {
|
|
this.top = f;
|
|
}
|
|
|
|
public PathArcOperation(float f, float f2, float f3, float f4) {
|
|
setLeft(f);
|
|
setTop(f2);
|
|
setRight(f3);
|
|
setBottom(f4);
|
|
}
|
|
|
|
@Override // com.google.android.material.shape.ShapePath.PathOperation
|
|
public void applyToPath(Matrix matrix, Path path) {
|
|
Matrix matrix2 = this.matrix;
|
|
matrix.invert(matrix2);
|
|
path.transform(matrix2);
|
|
RectF rectF2 = rectF;
|
|
rectF2.set(getLeft(), getTop(), getRight(), getBottom());
|
|
path.arcTo(rectF2, getStartAngle(), getSweepAngle(), false);
|
|
path.transform(matrix);
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static class PathCubicOperation extends PathOperation {
|
|
private float controlX1;
|
|
private float controlX2;
|
|
private float controlY1;
|
|
private float controlY2;
|
|
private float endX;
|
|
private float endY;
|
|
|
|
private float getControlX1() {
|
|
return this.controlX1;
|
|
}
|
|
|
|
private float getControlX2() {
|
|
return this.controlX2;
|
|
}
|
|
|
|
private float getControlY1() {
|
|
return this.controlY1;
|
|
}
|
|
|
|
private float getControlY2() {
|
|
return this.controlY1;
|
|
}
|
|
|
|
private float getEndX() {
|
|
return this.endX;
|
|
}
|
|
|
|
private float getEndY() {
|
|
return this.endY;
|
|
}
|
|
|
|
private void setControlX1(float f) {
|
|
this.controlX1 = f;
|
|
}
|
|
|
|
private void setControlX2(float f) {
|
|
this.controlX2 = f;
|
|
}
|
|
|
|
private void setControlY1(float f) {
|
|
this.controlY1 = f;
|
|
}
|
|
|
|
private void setControlY2(float f) {
|
|
this.controlY2 = f;
|
|
}
|
|
|
|
private void setEndX(float f) {
|
|
this.endX = f;
|
|
}
|
|
|
|
private void setEndY(float f) {
|
|
this.endY = f;
|
|
}
|
|
|
|
public PathCubicOperation(float f, float f2, float f3, float f4, float f5, float f6) {
|
|
setControlX1(f);
|
|
setControlY1(f2);
|
|
setControlX2(f3);
|
|
setControlY2(f4);
|
|
setEndX(f5);
|
|
setEndY(f6);
|
|
}
|
|
|
|
@Override // com.google.android.material.shape.ShapePath.PathOperation
|
|
public void applyToPath(Matrix matrix, Path path) {
|
|
Matrix matrix2 = this.matrix;
|
|
matrix.invert(matrix2);
|
|
path.transform(matrix2);
|
|
path.cubicTo(this.controlX1, this.controlY1, this.controlX2, this.controlY2, this.endX, this.endY);
|
|
path.transform(matrix);
|
|
}
|
|
}
|
|
}
|