Skip to content

Commit

Permalink
Removed dead code from DashLine
Browse files Browse the repository at this point in the history
  • Loading branch information
Zelaux committed Oct 1, 2023
1 parent 5fc27ab commit e1cc776
Showing 1 changed file with 7 additions and 29 deletions.
36 changes: 7 additions & 29 deletions graphics/dashDraw/src/arclibrary/graphics/DashLine.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package arclibrary.graphics;

import arc.func.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import arc.util.pooling.*;
import arc.util.pooling.Pool.*;

/**
* Draws polies with dash lines with same length and same spacing length
* */
*/
public class DashLine{
@SuppressWarnings("unused")
private static final Vec2 tmp1 = new Vec2(), tmp2 = new Vec2(), tmp3 = new Vec2(), tmp4 = new Vec2();
private static final Vec2 vector = new Vec2(), u = new Vec2(), v = new Vec2(), inner = new Vec2(), outer = new Vec2();
private static final Pool<PointList> pointListPool = Pools.get(PointList.class, PointList::new);
private static FloatSeq floats = new FloatSeq(20);
private static final FloatSeq floats = new FloatSeq(20);

@SuppressWarnings("unused")
public static void dashPoly(float... cords){
dashPolyWithLength(10, cords);
}
Expand All @@ -31,7 +33,6 @@ public static void brokenLine(float... cords){
try{
float stroke = Lines.getStroke();
floats.clear();
int iterationsCount = realSize;
begin:
{
float x = pointList.x(0), y = pointList.y(0);
Expand All @@ -48,6 +49,7 @@ public static void brokenLine(float... cords){
y - diffy - diffx);
}
for(int i = 0; i < realSize - 2; i++){
//noinspection UnnecessaryLocalVariable
int i0 = i;
int i1 = i + 1;
int i2 = i + 2;
Expand All @@ -65,13 +67,6 @@ public static void brokenLine(float... cords){
if(beta == 0){
v.setZero();
float hstroke = stroke / 2f;
float len0 = Mathf.len(x1 - x0, y1 - y0);
float dx2 = x2 - x1;
float dy2 = y2 - y1;
float len1 = Mathf.len(dx2, dy2);
float
diffx = Mathf.lerp((x1 - x0) / len0, dx2 / len1, 0.5f) * hstroke,
diffy = Mathf.lerp((y1 - y0) / len0, dy2 / len1, 0.5f) * hstroke;
tmp1.set(x2, y2).sub(x1, y1);
tmp2.set(x0, y0).sub(x1, y1);
float angleDiff = Mathf.mod(tmp1.angle() - tmp2.angle(), 360);
Expand All @@ -84,14 +79,6 @@ public static void brokenLine(float... cords){
,
tmp2.x + x1, tmp2.y + y1
);
/* floats.add(
x1 - diffy,
y1 + diffx,
x1 + diffy,
y1 - diffx
);*/
continue;
}

Expand Down Expand Up @@ -161,7 +148,6 @@ public static void dashPolyWithLength(final float middleLength, float... cords){
final float len2 = len * len;
boolean line = true;
float cornerPercent = -1;
int color = Draw.getColor().rgba();

for(int currentIndex = 0; currentIndex < cords.length / 2; currentIndex++){
Vec2 cur = Tmp.v1.set(pointList.x(currentIndex), pointList.y(currentIndex));
Expand All @@ -180,21 +166,17 @@ public static void dashPolyWithLength(final float middleLength, float... cords){
}
line = !line;
position.add(vector);
cornerPercent = -1;
//cornerPercent = -1;
}else{
cornerPercent = 1f - position.dst(next) / len;

Vec2 nextPosition;
// System.out.println("\n\n\n\n");
int nextIndex = currentIndex + 2;
FloatSeq floats = new FloatSeq();
floats.add(position.x, position.y);
floats.add(next.x, next.y);
do{
if(nextIndex % cords.length == 0){
if(line){
// brokenLine(floats.toArray());
}
return;
}
float next2x = pointList.x(nextIndex);
Expand All @@ -210,8 +192,6 @@ public static void dashPolyWithLength(final float middleLength, float... cords){
}
floats.add(currentx + nextPosition.x, currenty + nextPosition.y);
if(nextLen < perfectLen && cornerPercent > 0.0000001f){
// Log.info("cornerPercent: @(@,@)",
// cornerPercent, cornerPercent * len, nextLen);
cornerPercent = (perfectLen - nextLen) / len;
}else{
break;
Expand All @@ -220,11 +200,9 @@ public static void dashPolyWithLength(final float middleLength, float... cords){
}while(true);
currentIndex = nextIndex - 2;
if(line){
// Lines.polyline(floats, false);
brokenLine(floats.toArray());
}
line = !line;
// Lines.
break;
}
}
Expand Down

0 comments on commit e1cc776

Please sign in to comment.