MOS substitution: Difference between revisions

Inthar (talk | contribs)
Inthar (talk | contribs)
Line 212: Line 212:
== Pseudocode ==
== Pseudocode ==
<syntaxhighlight lang="py">
<syntaxhighlight lang="py">
def letterwise_subst(template_word, slot, filling_word):
def letterwise_subst(template_word, slot, filling_word):
    result = ""
    result = ""
    i = 0
    i = 0
    for letter in template_word:
    for letter in template_word:
        if letter == slot:
        if letter == slot:
            result += filling_word[i]
            result += filling_word[i]
            i += 1
            i += 1
        else:
        else:
            result += letter
            result += letter
    return result
    return result
   
   
# brightness is multiplied by the gcd of the step counts in UDP
# brightness is multiplied by the gcd of the step counts in UDP
# nX X (nY Y nZ Z) (brightness_of_filling_mos) | (nY + nZ - gcd(nY, nZ) - brightness_of_filling_mos)
# nX X (nY Y nZ Z) (brightness_of_filling_mos) | (nY + nZ - gcd(nY, nZ) - brightness_of_filling_mos)
def mos_subst(nX, nY, nZ, sizeX, sizeY, sizeZ, brightness_of_filling_mos):
def mos_subst(nX, nY, nZ, sizeX, sizeY, sizeZ, brightness_of_filling_mos):
    template_mos = mos_word(nX, nY + nZ, ["X", "W"], brightness=nX + nY + nZ - gcd(nX, nY + nZ)) # word in X and W; X is treated as L and W as s for purposes of brightness
    template_mos = mos_word(nX, nY + nZ, ["X", "W"], brightness=nX + nY + nZ - gcd(nX, nY + nZ)) # word in X and W; X is treated as L and W as s for purposes of brightness
    filling_mos = mos_word(nY, nZ, ["Y", "Z"], brightness=brightness_of_filling_mos)
    filling_mos = mos_word(nY, nZ, ["Y", "Z"], brightness=brightness_of_filling_mos)
    word = letterwise_subst(template_mos, "W", filling_mos)
    word = letterwise_subst(template_mos, "W", filling_mos)
    scale = subst_step_sizes(word, [sizeX, sizeY, sizeZ])
    scale = subst_step_sizes(word, [sizeX, sizeY, sizeZ])
    return scale
    return scale
</syntaxhighlight>
</syntaxhighlight>