Skip to content

Commit

Permalink
feat XYZ in upper case
Browse files Browse the repository at this point in the history
this fix allows alg= to input upper case XYZ
if algdisplay=xyzupper is provided, will also display them in upper case
  • Loading branch information
alexfung888 committed Feb 6, 2020
1 parent 80c441b commit 76e45f9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions demo/alexfung.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ <h3>Color Fix</h3>
<div class="roofpig" data-config="alg=U| colored=*|flags=showalg startsolved">Normal: U on top</div>
<div class="roofpig" data-config="alg=M| colored=*|flags=showalg startsolved|algdisplay=rotations">color fix for M</div>
<div class="roofpig" data-config="alg=x| colored=*|flags=showalg startsolved|algdisplay=rotations">color fix for X</div>

<h3>Upper Case XYZ</h3>
<p>
Using the algdisplay=xyzUpper option, X/Y/Z are displayed in upper case, as they should be.
</p>
<div class="roofpig" data-config="alg=x y z| colored=|flags=showalg startsolved|algdisplay=rotations">Lower Case xyz</div>
<div class="roofpig" data-config="alg=x y z| colored=|flags=showalg startsolved|algdisplay=rotations xyzUpper">Upper Case XYZ</div>
6 changes: 4 additions & 2 deletions src/Alg.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ class Alg
if code.indexOf('+') > -1
new CompositeMove(code, @world3d, @speed)

else if code[0] in ['x', 'y', 'z']
else if (c0lower = code[0].toLowerCase()) in ['x', 'y', 'z']
[t1, t2] = turn_codes[Move.parse_turns(code.substring(1))]
moves = switch code[0]
moves = switch c0lower
when 'x' then "R#{t1}+M#{t2}+L#{t2}"
when 'y' then "U#{t1}+E#{t2}+D#{t2}"
when 'z' then "F#{t1}+S#{t1}+B#{t2}"
new CompositeMove(moves, @world3d, @speed, c0lower + code.substring(1))
# allow input XYZ, but must store as xyz or else Z will be displayed as 2
new CompositeMove(moves, @world3d, @speed, code)

else
Expand Down
1 change: 1 addition & 0 deletions src/Config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Config
ad = this.raw(ALGDISPLAY)
result = {}
result.fancy2s = ad.indexOf('fancy2s') > -1
result.xyzUpper = ad.indexOf('xyzUpper') > -1
result.rotations = ad.indexOf('rotations') > -1
result.Zcode = "2"
result.Zcode = "2'" if ad.indexOf('2p') > -1
Expand Down
5 changes: 5 additions & 0 deletions src/Dom.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ class Dom

# LUCIDA_WIDTHS = {M:108, '+':100, '>':100, '<':100, w:98, D:94, U:87, 2:80, R:80, x:78, Z:77, B:73, z:73, F:68, E:68, S:68, L:67, y:65, '²':53, ' ':40, "'":29}
LUCIDA_WIDTHS = {M:108, '+':100, '>':100, '<':100, w:98, D:94, U:87, 2:80, R:80, x:78, Z:77, B:73, z:73, F:68, E:68, S:68, L:67, y:65, '²':53, ' ':40, "'":29
, X:79, Y:79
}
# I haven't really found out what the width here means.
# Below are the real values from the Lucida Sans font,
# since +/</> are 1628, I divide numbers by 16.28 and round up to get the value for LUCIDA_WIDTHS
# , X:1282, Y:1276

init_alg_text: (text) ->
if @alg_text
Expand Down
1 change: 1 addition & 0 deletions src/Move.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Move
@displayify: (move_text, algdisplay) ->
result = move_text.replace('Z', algdisplay.Zcode)
result = result.replace('2', '²') if algdisplay.fancy2s
result = result.replace("x", 'X').replace("y", 'Y').replace("z", 'Z') if algdisplay.xyzUpper
result

display_text: (algdisplay) ->
Expand Down

0 comments on commit 76e45f9

Please sign in to comment.