-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tile.js
27 lines (24 loc) · 1.02 KB
/
Tile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//
// "Tile" is similar to "Sprite," but instead of relying on the
// "pixelSize" property for sizing, it simply expands (and distorts)
// to fill its container.
//
/*
<Tile sprite={["x.",".x"]}
letterToColor={{"x":"yellow", ".":"brown"}} />
*/
import React from 'react';
import { View } from 'react-native';
function Tile(props) {
const markup = (<View style={{flexDirection: "column", height:"100%", width:"100%"}}>
{props.sprite.map((t,i)=>{
return (<View key={"tile-outer-" + i + props.x + props.y} style={{height:props.pixelSize, flexDirection: "row", flex:1, flexGrow: 1}}>
{t.split('').map((u,j)=>{
return (<View key={"tile-inner-" + (i * 100 + j) + props.x + props.y} style={{ flex:1, flexGrow: 1,
backgroundColor:props.letterToColor[u]}} />);})}
</View>);})}
</View>
);
return <View>{markup}</View>
}
export default Tile;