FC18: Made super/sub script in six and 18 bit methods

This commit is contained in:
Willem Cazander 2025-08-22 16:25:55 +02:00
parent 7ea17d7628
commit a122f4e181
4 changed files with 75 additions and 28 deletions

View file

@ -98,11 +98,11 @@ final public class FourCornerRecipe {
return out;
}
static public List<Integer> embedSandWalkerX06(List<PrimordialOctal> rhythm) {
return embedSandWalkerX06(new ArrayList<>(), rhythm);
static public List<Integer> embedSandWalker(List<PrimordialOctal> rhythm) {
return embedSandWalker(new ArrayList<>(), rhythm);
}
static public List<Integer> embedSandWalkerX06(List<Integer> out, List<PrimordialOctal> rhythm) {
static public List<Integer> embedSandWalker(List<Integer> out, List<PrimordialOctal> rhythm) {
Objects.requireNonNull(rhythm);
if (!FourCornerRecipe.SAND_WORM_SIGN.contains(rhythm.size())) {
throw new IllegalArgumentException("Sand walker rhythm is not 72 bit aligned: " + rhythm.size());
@ -307,52 +307,99 @@ final public class FourCornerRecipe {
return out;
}
static public List<Integer> toScriptSuper(int value) {
return toScript(new ArrayList<>(), Integer.toString(value), 0);
static public List<Integer> toScriptSuperX06(int value) {
return toScript(new ArrayList<>(), Integer.toString(value), 0, true);
}
static public List<Integer> toScriptSub(int value) {
return toScript(new ArrayList<>(), Integer.toString(value), 10);
static public List<Integer> toScriptSubX06(int value) {
return toScript(new ArrayList<>(), Integer.toString(value), 10, true);
}
static public List<Integer> toScriptSuper(BigInteger value) {
return toScript(new ArrayList<>(), value.toString(10), 0);
static public List<Integer> toScriptSuperX06(BigInteger value) {
return toScript(new ArrayList<>(), value.toString(10), 0, true);
}
static public List<Integer> toScriptSub(BigInteger value) {
return toScript(new ArrayList<>(), value.toString(10), 10);
static public List<Integer> toScriptSubX06(BigInteger value) {
return toScript(new ArrayList<>(), value.toString(10), 10, true);
}
static public void toScriptSuper(List<Integer> out, int value) {
toScript(out, Integer.toString(value), 0);
static public void toScriptSuperX06(List<Integer> out, int value) {
toScript(out, Integer.toString(value), 0, true);
}
static public void toScriptSub(List<Integer> out, int value) {
toScript(out, Integer.toString(value), 10);
static public void toScriptSubX06(List<Integer> out, int value) {
toScript(out, Integer.toString(value), 10, true);
}
static public void toScriptSuper(List<Integer> out, BigInteger value) {
toScript(out, value.toString(10), 0);
static public void toScriptSuperX06(List<Integer> out, BigInteger value) {
toScript(out, value.toString(10), 0, true);
}
static public void toScriptSub(List<Integer> out, BigInteger value) {
toScript(out, value.toString(10), 10);
static public void toScriptSubX06(List<Integer> out, BigInteger value) {
toScript(out, value.toString(10), 10, true);
}
static private List<Integer> toScript(List<Integer> out, String value, int off) {
static public List<Integer> toScriptSuperX18(int value) {
return toScript(new ArrayList<>(), Integer.toString(value), 0, false);
}
static public List<Integer> toScriptSubX18(int value) {
return toScript(new ArrayList<>(), Integer.toString(value), 10, false);
}
static public List<Integer> toScriptSuperX18(BigInteger value) {
return toScript(new ArrayList<>(), value.toString(10), 0, false);
}
static public List<Integer> toScriptSubX18(BigInteger value) {
return toScript(new ArrayList<>(), value.toString(10), 10, false);
}
static public void toScriptSuperX18(List<Integer> out, int value) {
toScript(out, Integer.toString(value), 0, false);
}
static public void toScriptSubX18(List<Integer> out, int value) {
toScript(out, Integer.toString(value), 10, false);
}
static public void toScriptSuperX18(List<Integer> out, BigInteger value) {
toScript(out, value.toString(10), 0, false);
}
static public void toScriptSubX18(List<Integer> out, BigInteger value) {
toScript(out, value.toString(10), 10, false);
}
static private List<Integer> toScript(List<Integer> out, String value, int off, boolean isSixBit) {
PrimitiveIterator.OfInt i = value.codePoints().iterator();
while (i.hasNext()) {
int chr = i.nextInt();
if (chr == '-') {
if (off == 0) {
out.add(FCDotPIE9CDash11.NXX_03.cakePointDotIndex());
if (isSixBit) {
out.addAll(FCDotPIE9CDash11.NXX_03.baklavaPointSequence());
} else {
out.add(FCDotPIE9CDash11.NXX_03.cakePointDotIndex());
}
} else {
out.add(FCDotPIE9CDash11.NXX_08.cakePointDotIndex());
if (isSixBit) {
out.addAll(FCDotPIE9CDash11.NXX_08.baklavaPointSequence());
} else {
out.add(FCDotPIE9CDash11.NXX_08.cakePointDotIndex());
}
}
continue;
}
int num = chr - '0';
out.add(FCDotPIE9CDash20.valueOf(num + off).cakePointDotIndex());
if (isSixBit) {
out.addAll(FCDotPIE9CDash20.valueOf(num + off).baklavaPointSequence());
} else {
out.add(FCDotPIE9CDash20.valueOf(num + off).cakePointDotIndex());
}
}
if (isSixBit) {
out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.cakePointDotIndex()); // fixme improve: see FourCornerDotCollePie9.baklavaPointsPIE9C
}
return out;
}

View file

@ -233,9 +233,9 @@ public class FourCornerUnicodeDisplay {
@Override
public void strobeNCR1632(BigInteger denominator, BigInteger numerator) {
List<Integer> math = new ArrayList<>();
FourCornerRecipe.toScriptSuper(math, numerator);
FourCornerRecipe.toScriptSuperX18(math, numerator);
math.add(FCDotCDC1604DashP6.NY02_BAR_V_RIGHT.ordinal());
FourCornerRecipe.toScriptSub(math, denominator);
FourCornerRecipe.toScriptSubX18(math, denominator);
renderFromInt18(math, output);
}

View file

@ -92,7 +92,7 @@ public class FourCornerZionStenoGrapher {
@Override
public void strobeSandWalker(List<PrimordialOctal> rhythm) {
FourCornerRecipe.embedSandWalkerX06(out, rhythm);
FourCornerRecipe.embedSandWalker(out, rhythm);
}
@Override

View file

@ -42,13 +42,13 @@ public class FourCornerRecipeTest {
public void testSandWalker() throws Exception {
List<Integer> cdc = new ArrayList<>();
Assertions.assertThrows(IllegalArgumentException.class, () -> {
FourCornerRecipe.embedSandWalkerX06(cdc, List.of(PrimordialOctal.PART_1));
FourCornerRecipe.embedSandWalker(cdc, List.of(PrimordialOctal.PART_1));
});
List<PrimordialOctal> octalMine = new ArrayList<>();
for (int i=0;i<24;i++) {
octalMine.add(PrimordialOctal.PART_1);
}
FourCornerRecipe.embedSandWalkerX06(cdc, octalMine);
FourCornerRecipe.embedSandWalker(cdc, octalMine);
String res = FourCornerUnicodeDisplay.text().renderFromInt18(cdc);
Assertions.assertTrue(res.endsWith("PART_1PART_1"), "missing " + res);
}