Line texture improvements, #1005 (#1008)

This commit is contained in:
Emux
2023-01-11 18:51:54 +02:00
committed by GitHub
parent c36d62e0d1
commit fd092aa4dd
4 changed files with 20 additions and 41 deletions

View File

@@ -562,7 +562,7 @@ public class XmlThemeBuilder extends DefaultHandler {
b.fixed = parseBoolean(value);
else if ("stipple".equals(name))
b.stipple = Math.round(parseInt(value) * mScale * mStrokeScale);
b.stipple = (int) (parseInt(value) * mScale * mStrokeScale);
else if ("stipple-stroke".equals(name))
b.stippleColor(value);
@@ -615,12 +615,16 @@ public class XmlThemeBuilder extends DefaultHandler {
if (b.dashArray.length == 1) {
b.randomOffset = false;
b.stipple = b.dashArray[0] < 1 ? 1 : (int) b.dashArray[0];
if (mTheme.isMapsforgeTheme())
b.stipple *= Parameters.MAPSFORGE_DASH_FACTOR;
b.stippleWidth = 1;
b.stippleColor = Color.TRANSPARENT;
b.dashArray = null;
} else {
// Min dash is 1
float factor = 1;
for (float f : b.dashArray) {
if (0 < f && f < 1)
factor = Math.max(factor, 1 / f);
}
// Odd number of entries is duplicated
if (b.dashArray.length % 2 != 0) {
float[] newDashArray = new float[b.dashArray.length * 2];
@@ -631,10 +635,7 @@ public class XmlThemeBuilder extends DefaultHandler {
int width = 0;
int height = b.strokeWidth < 1 ? 1 : (int) b.strokeWidth;
for (float f : b.dashArray) {
if (f < 1)
f = 1;
if (mTheme.isMapsforgeTheme())
f *= Parameters.MAPSFORGE_DASH_FACTOR;
f *= factor;
width += f;
}
Bitmap bitmap = CanvasAdapter.newBitmap(width, height, 0);
@@ -643,10 +644,7 @@ public class XmlThemeBuilder extends DefaultHandler {
int x = 0;
boolean transparent = false;
for (float f : b.dashArray) {
if (f < 1)
f = 1;
if (mTheme.isMapsforgeTheme())
f *= Parameters.MAPSFORGE_DASH_FACTOR;
f *= factor;
canvas.fillRectangle(x, 0, f, height, transparent ? Color.TRANSPARENT : Color.WHITE);
x += f;
transparent = !transparent;