commit 352bd3629496fdd82be3f013245f09ce98e8fa9f
Author: leszek <leszek@koltunski.pl>
Date:   Mon Feb 19 01:38:50 2024 +0100

    More support for configuring the stickers.

diff --git a/src/main/java/org/distorted/objectlib/helpers/FactorySticker.java b/src/main/java/org/distorted/objectlib/helpers/FactorySticker.java
index 649626c6..81e929f7 100644
--- a/src/main/java/org/distorted/objectlib/helpers/FactorySticker.java
+++ b/src/main/java/org/distorted/objectlib/helpers/FactorySticker.java
@@ -184,8 +184,8 @@ public class FactorySticker
     float quotient = radius/(float)Math.sqrt(vX*vX + vY*vY);
     float ret = computeAngle(vX,-vY)-computeQuotientOfCurvature(quotient,curvature);
 
-    if( ret>=2*PI ) ret -= 2*PI;
-    if( ret<0     ) ret += 2*PI;
+    while( ret>=2*PI ) ret -= 2*PI;
+    while( ret<0     ) ret += 2*PI;
 
     return ret;
     }
@@ -209,12 +209,17 @@ public class FactorySticker
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  private void drawRoundCorner(Canvas canvas, Paint paint,int color, int left, int bottom, float stroke,
-                              float radius, float cX, float cY, float pA, float cA)
+  private void drawRoundCorner(Canvas canvas, Paint paint, int color, int left, int bottom,
+                               float stroke, float radius, float cX, float cY, float pA, float cA)
     {
+    final float A = 4.0f;
+
     cX = (0.5f+cX)*mTexHeight;
     cY = (0.5f-cY)*mTexHeight;
-    float R = radius*mTexHeight + stroke/2;
+    float r = radius*mTexHeight + stroke/2;    // distance from the center of the circle arc of
+                                               // which we are drawing to the center of the edge line
+    float R = radius*mTexHeight + A*stroke/2;  // distance from the center of the circle to the center
+                                               // of the arc being drawn; the arc is A times thicker.
 
     boolean isConvex = ((pA<cA && cA<pA+PI) || (pA<cA+2*PI && cA+2*PI<pA+PI));
     float startA, stopA, centerA, alpha, D;
@@ -230,7 +235,7 @@ public class FactorySticker
       float diff = cA-centerA;
       if( diff<0 ) diff += 2*PI;
       alpha = diff> PI/2 ? PI-diff : diff;
-      D = (float)(R/Math.sin(alpha));
+      D = (float)(r/Math.sin(alpha));
       }
     else
       {
@@ -241,7 +246,7 @@ public class FactorySticker
       float diff = centerA-cA;
       if( diff<0 ) diff += 2*PI;
       alpha = diff> PI/2 ? PI-diff : diff;
-      D = (float)((R-stroke)/Math.sin(alpha));
+      D = (float)((r-stroke)/Math.sin(alpha));
       }
 
     float sweepA = startA-stopA;
@@ -257,6 +262,7 @@ public class FactorySticker
     sweepA *= 180/PI;
 
     if( !isConvex ) paint.setColor(color);
+    paint.setStrokeWidth(A*stroke);
     canvas.drawArc( left+oX-R, bottom-oY-R, left+oX+R, bottom-oY+R, startA, sweepA, false, paint);
     if( !isConvex ) paint.setColor(COLOR_STROKE);
     }
@@ -265,8 +271,8 @@ public class FactorySticker
 // TODO: this doesn't really support proper drawing of rounded corners in case two neighbouring
 // strokes are not equal to each other.
 
-  private void drawEdge(Canvas canvas, Paint paint, int left, int bottom, int color,
-                        float[] strokes, float[][] vertices, float[] angles, float[] radii )
+  private void drawEdge(Canvas canvas, Paint paint, int left, int bottom, int color, float[] strokes,
+                        float[][] vertices, float[] angles, float[] radii, float borders, float corners )
     {
     int length = vertices.length;
 
@@ -281,7 +287,7 @@ public class FactorySticker
 
     for(int vert=0; vert<length; vert++)
       {
-      float stroke = strokes[vert]*mTexHeight;
+      float stroke = borders*strokes[vert]*mTexHeight;
 
       if( stroke>0 )
         {
@@ -312,15 +318,15 @@ public class FactorySticker
 
     for(int vert=0; vert<length; vert++)
       {
-      float stroke = strokes[vert]*mTexHeight;
-      paint.setStrokeWidth(stroke);
-
+      float stroke = borders*strokes[vert]*mTexHeight;
       int prev = vert==0 ? length-1 : vert-1;
-      float prevAngle = computeSideAngle(currX-prevX,currY-prevY,radii[prev],-prevA);
-      float currAngle = computeSideAngle(nextX-currX,nextY-currY,radii[vert],+currA);
+      float rp = radii[prev]*corners;
+      float rv = radii[vert]*corners;
+      float prevAngle = computeSideAngle(currX-prevX,currY-prevY,rp,-prevA);
+      float currAngle = computeSideAngle(nextX-currX,nextY-currY,rv,+currA);
 
-      if( radii[vert]>0 && stroke>0 )
-        drawRoundCorner(canvas,paint,color,left,bottom,stroke,radii[vert],currX,currY,prevAngle,currAngle);
+      if( rv>0 && stroke>0 )
+        drawRoundCorner(canvas,paint,color,left,bottom,stroke,rv,currX,currY,prevAngle,currAngle);
 
       prevX = currX;
       prevY = currY;
@@ -337,7 +343,8 @@ public class FactorySticker
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC
 
-  public void drawRoundedPolygons(Canvas canvas, Paint paint, int left, int bottom, int color, int height, ObjectSticker sticker)
+  public void drawRoundedPolygons(Canvas canvas, Paint paint, int left, int bottom, int color,
+                                  int height, ObjectSticker sticker, float borders, float corners)
     {
     mTexHeight = height;
 
@@ -362,7 +369,7 @@ public class FactorySticker
     for(int l=0; l<numLoops; l++)
       {
       float[] ang = (angles==null? null : angles[l]);
-      drawEdge(canvas, paint, left, bottom, color, strokes[l], vertices[l], ang, radii[l]);
+      drawEdge(canvas, paint, left, bottom, color, strokes[l], vertices[l], ang, radii[l], borders, corners);
       }
 
     canvas.restore();
diff --git a/src/main/java/org/distorted/objectlib/main/ObjectControl.java b/src/main/java/org/distorted/objectlib/main/ObjectControl.java
index 83957479..87e7d447 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectControl.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectControl.java
@@ -816,6 +816,15 @@ public class ObjectControl
       mPreRender.resetAllTextureMaps();
       }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void recreateSticker(float borders, float corners)
+      {
+      TwistyObject object = mPreRender.getObject();
+      object.createTexture(borders,corners);
+      object.setTexture();
+      }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     public TwistyObject getObject()
diff --git a/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java b/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
index 216c0ddd..12aa158e 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
@@ -37,7 +37,6 @@ public class ObjectPreRender implements EffectListener
   private TwistyObject mOldObject, mNewObject;
   private OperatingSystemInterface mOS;
   private MovesFinished mAddActionListener;
-//  private final BlockController mBlockController;
   private final ObjectLibInterface mInterface;
   private String mDebug;
   private float mMoveX, mMoveY;
diff --git a/src/main/java/org/distorted/objectlib/main/TwistyObject.java b/src/main/java/org/distorted/objectlib/main/TwistyObject.java
index 43088bde..4fab06fa 100644
--- a/src/main/java/org/distorted/objectlib/main/TwistyObject.java
+++ b/src/main/java/org/distorted/objectlib/main/TwistyObject.java
@@ -1614,10 +1614,9 @@ public abstract class TwistyObject
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // the getFaceColors + final INTERNAL_COLOR in a grid (so that we do not exceed the maximum texture size)
 
-  private void createTexture()
+  void createTexture(float borders, float corners)
     {
     Paint paint = new Paint();
-    mBitmap = Bitmap.createBitmap( mNumTexCols*mTexHeight, mNumTexRows*mTexHeight, Bitmap.Config.ARGB_4444);
     Canvas canvas = new Canvas(mBitmap);
 
     paint.setAntiAlias(true);
@@ -1636,7 +1635,7 @@ public abstract class TwistyObject
           {
           ObjectSticker sticker = retSticker(texture/mNumFaceColors);
           int color = getColor(texture%mNumFaceColors);
-          factory.drawRoundedPolygons(canvas, paint, col*mTexHeight, (mNumTexRows-row)*mTexHeight, color, mTexHeight, sticker);
+          factory.drawRoundedPolygons(canvas, paint, col*mTexHeight, (mNumTexRows-row)*mTexHeight, color, mTexHeight, sticker,borders,corners);
           }
         else if( texture>mNumTextures-mNumOverrides && texture<=mNumTextures )
           {
@@ -1652,7 +1651,11 @@ public abstract class TwistyObject
 
   void setTexture()
     {
-    if( mBitmap==null ) createTexture();
+    if( mBitmap==null )
+      {
+      mBitmap = Bitmap.createBitmap( mNumTexCols*mTexHeight, mNumTexRows*mTexHeight, Bitmap.Config.ARGB_4444);
+      createTexture(1.0f,1.0f);
+      }
 
     if( !mTexture.setTextureAlreadyInverted(mBitmap) )
       {
