Skip to content

Commit

Permalink
Remove no-longer-needed function wrappers in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Aug 13, 2022
1 parent 9f87978 commit 8dcaa02
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/chess/map.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ read = (filename) ->
console.assert dom.type == 'svg'
dom.props.children

(key) -> ->
(key) ->
# Map blanks to empty string
key = key.trim()
key = '' if key == '.'
Expand Down
4 changes: 2 additions & 2 deletions examples/chess/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ function read(filename) {
return dom.props.children;
}

(key) => function() {
(key, context) => {
// Map blanks to empty string
key = key.trim();
if (key === '.') key = '';
const piece = key.toLowerCase();
return (
<symbol viewBox="0 0 45 45">
<rect width="45" height="45" fill="white" stroke="white"/>
{(this.i + this.j) % 2 === 0 ? light : dark}
{(context.i + context.j) % 2 === 0 ? light : dark}
{key.trim() && key !== '.' &&
read(`./Chess_${piece}${piece === key ? "d" : "l"}t45.svg`)
}
Expand Down
1 change: 1 addition & 0 deletions examples/polyomino/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
all: cjsx jsx coffee
cjsx:
svgtiler -f outlines.cjsx *.asc
jsx:
Expand Down
22 changes: 13 additions & 9 deletions examples/polyomino/outlines.cjsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
Border = (props) ->
<line {...props} stroke="black" stroke-width="5" stroke-linecap="round"/>

(key) -> ->
(key) ->
<symbol viewBox="-10 -10 20 20" overflowBox="-12.5 -12.5 25 25">
{if this.neighbor(-1,0).key != key
<Border x1="-10" y1="-10" x2="-10" y2="10"/>}
{if this.neighbor(+1,0).key != key
<Border x1="10" y1="-10" x2="10" y2="10"/>}
{if this.neighbor(0,-1).key != key
<Border x1="-10" y1="-10" x2="10" y2="-10"/>}
{if this.neighbor(0,+1).key != key
<Border x1="-10" y1="10" x2="10" y2="10"/>}
{if @neighbor(-1,0).key != key
<Border x1="-10" y1="-10" x2="-10" y2="10"/>
}
{if @neighbor(+1,0).key != key
<Border x1="10" y1="-10" x2="10" y2="10"/>
}
{if @neighbor(0,-1).key != key
<Border x1="-10" y1="-10" x2="10" y2="-10"/>
}
{if @neighbor(0,+1).key != key
<Border x1="-10" y1="10" x2="10" y2="10"/>
}
</symbol>
10 changes: 5 additions & 5 deletions examples/polyomino/outlines.coffee
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
borderStyle = 'stroke="black" stroke-width="5" stroke-linecap="round"'

(key) -> ->
(key) ->
s = '''
<symbol viewBox="-10 -10 20 20" overflowBox="-12.5 -12.5 25 25">
'''
if this.neighbor(-1,0).key != key
if @neighbor(-1,0).key != key
s += """<line x1="-10" y1="-10" x2="-10" y2="10" #{borderStyle}/>"""
if this.neighbor(+1,0).key != key
if @neighbor(+1,0).key != key
s += """<line x1="10" y1="-10" x2="10" y2="10" #{borderStyle}/>"""
if this.neighbor(0,-1).key != key
if @neighbor(0,-1).key != key
s += """<line x1="-10" y1="-10" x2="10" y2="-10" #{borderStyle}/>"""
if this.neighbor(0,+1).key != key
if @neighbor(0,+1).key != key
s += """<line x1="-10" y1="10" x2="10" y2="10" #{borderStyle}/>"""
s += '</symbol>'
10 changes: 5 additions & 5 deletions examples/polyomino/outlines.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const Border = (props) =>
<line {...props} stroke="black" stroke-width="5" stroke-linecap="round"/>;

(key) => function() {
(key, context) => {
return <symbol viewBox="-10 -10 20 20" overflowBox="-12.5 -12.5 25 25">
{this.neighbor(-1,0).key !== key &&
{context.neighbor(-1,0).key !== key &&
<Border x1="-10" y1="-10" x2="-10" y2="10"/>}
{this.neighbor(+1,0).key !== key &&
{context.neighbor(+1,0).key !== key &&
<Border x1="10" y1="-10" x2="10" y2="10"/>}
{this.neighbor(0,-1).key !== key &&
{context.neighbor(0,-1).key !== key &&
<Border x1="-10" y1="-10" x2="10" y2="-10"/>}
{this.neighbor(0,+1).key !== key &&
{context.neighbor(0,+1).key !== key &&
<Border x1="-10" y1="10" x2="10" y2="10"/>}
</symbol>
}
3 changes: 2 additions & 1 deletion examples/tetris/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
all:
all: txt coffee
txt:
svgtiler -f -P NES_level7.txt example.asc
coffee:
svgtiler -f -P NES_level7.coffee example.asc

0 comments on commit 8dcaa02

Please sign in to comment.