diff --git a/README.md b/README.md index 3e49f4be..9cf0a049 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ [![](https://github.com/Anuken/Arc/workflows/Java%20CI/badge.svg)](https://github.com/Anuken/Arc/actions) -Wow a fork of a fork of libgdx no way +Wow a fork of a fork of libgdx no way. \ No newline at end of file diff --git a/arc-core/src/arc/graphics/Pixmap.java b/arc-core/src/arc/graphics/Pixmap.java index 4daed47e..ad18ebae 100644 --- a/arc-core/src/arc/graphics/Pixmap.java +++ b/arc-core/src/arc/graphics/Pixmap.java @@ -433,9 +433,9 @@ public void draw(Pixmap pixmap, int srcx, int srcy, int srcWidth, int srcHeight, ByteBuffer pixels = this.pixels, otherPixels = pixmap.pixels; int startY = Math.max(dsty, 0), - endY = Math.min(dsty + Math.min(dstHeight, oheight), height), + endY = Math.min(Math.min(dsty + Math.min(dstHeight, oheight), height), dsty - srcy + oheight), startX = Math.max(dstx, 0), - endX = Math.min(dstx + Math.min(dstWidth, owidth), width), + endX = Math.min(Math.min(dstx + Math.min(dstWidth, owidth), width), dstx - srcx + owidth), offsetY = dsty - srcy, scanX = Math.max(Math.max(srcx, -dstx), 0), scanWidth = (endX - startX) * 4; diff --git a/arc-core/src/arc/graphics/g2d/Lines.java b/arc-core/src/arc/graphics/g2d/Lines.java index 200c2fa3..ab6075cd 100644 --- a/arc-core/src/arc/graphics/g2d/Lines.java +++ b/arc-core/src/arc/graphics/g2d/Lines.java @@ -236,7 +236,8 @@ private static void preparePointyJoin(Vec2 A, Vec2 B, Vec2 C, Vec2 D, Vec2 E, fl prepareStraightJoin(B, D, E, halfLineWidth); return; } - float len = (float)(halfLineWidth / Math.sin(angle)); + //clamps length to avoid super sharp edges. this looks pretty bad, but it's better than the alternative of a 1-pixel line to infinity + float len = Mathf.clamp((float)(halfLineWidth / Math.sin(angle)), -halfLineWidth*10f, halfLineWidth*10f); boolean bendsLeft = angle < 0; AB.setLength(len); BC.setLength(len); diff --git a/arc-core/src/arc/scene/ui/TextField.java b/arc-core/src/arc/scene/ui/TextField.java index 41e7f127..f14d3a9b 100644 --- a/arc-core/src/arc/scene/ui/TextField.java +++ b/arc-core/src/arc/scene/ui/TextField.java @@ -842,7 +842,11 @@ protected void moveCursor(boolean forward, boolean jump){ int limit = forward ? text.length() : 0; int charOffset = forward ? 0 : -1; while((forward ? ++cursor < limit : --cursor > limit) && jump){ - if(!continueCursor(cursor, charOffset)) break; + if(forward != continueCursor(cursor, charOffset)) break; + } + if(!jump || (forward && cursor >= limit) || (!forward && cursor <= limit)) return; + while((forward ? ++cursor < limit : --cursor > limit)){ + if(forward == continueCursor(cursor, charOffset)) break; } } @@ -1133,12 +1137,17 @@ public boolean keyTyped(InputEvent event, char character){ if(hasSelection) cursor = delete(false); else{ + boolean ctrl = Core.input.ctrl() && !Core.input.alt(); + boolean jump = ctrl && !passwordMode; if(backspace && cursor > 0){ - text = text.substring(0, cursor - 1) + text.substring(cursor--); + moveCursor(false, jump); + text = text.substring(0, cursor) + text.substring(oldCursor); renderOffset = 0; } if(delete && cursor < text.length()){ - text = text.substring(0, cursor) + text.substring(cursor + 1); + moveCursor(true, jump); + text = text.substring(0, oldCursor) + text.substring(cursor); + cursor = oldCursor; } } if(add && !remove){ diff --git a/arc-core/test/PixmapTest.java b/arc-core/test/PixmapTest.java index 9ea01d53..19a955a9 100644 --- a/arc-core/test/PixmapTest.java +++ b/arc-core/test/PixmapTest.java @@ -1,4 +1,6 @@ import arc.graphics.*; +import arc.math.*; +import arc.math.geom.*; import arc.util.*; import org.junit.*; @@ -27,6 +29,44 @@ public void pixmapCreate(){ assertEquals(0, pix.get(0, 0)); } + @Test + public void pixmapBounds(){ + int x = 176; + + Pixmap base = new Pixmap(176, 269); + Pixmap crop = new Pixmap(176, 176); + + crop.draw(base, 0, 176, x, x, 0, 0, x, x, true); + } + + static Rect rect = new Rect(); + static Vec2 v1 = new Vec2(), v2 = new Vec2(); + + static void randomize(){ + rect.set(Mathf.random(30f), Mathf.random(30f), 8f, 8f); + v1.set(Mathf.random(30f), Mathf.random(30f)); + v2.set(Mathf.random(30f), Mathf.random(30f)); + } + +// @Test +// public void raycasts(){ +// +// Vec2 hole = new Vec2(); +// int[] results = {0}; +// +// bench(() -> { +// randomize(); +// +// results[0] += Intersector.intersectSegmentRectangle(v1, v2, rect) ? 1 : 0; +// }, () -> { +// randomize(); +// +// results[0] += Intersector.intersectSegmentRectangleFast(v1.x, v1.y, v2.x, v2.y, rect.x, rect.y, rect.width, rect.height) ? 1 : 0; +// }, 100_000_000); +// +// Log.info(results[0]); +// } + /* @Test public void normals(){