Skip to content

Instantly share code, notes, and snippets.

@unstoppablecarl
Last active August 29, 2015 14:05
Show Gist options
  • Save unstoppablecarl/afe01360fae546ce49ec to your computer and use it in GitHub Desktop.
Save unstoppablecarl/afe01360fae546ce49ec to your computer and use it in GitHub Desktop.
var config = {
top: {
// repeat or scale (x only)
transform: 'repeat',
data:[
'01',
'01',
]
},
right: {
data:[
'1#',
'0#',
'1#',
'0#',
'1#'
]
},
bottom: {
// repeat or scale (x only)
transform: 'scale',
data:[
'01',
'01'
]
},
left: {
// mirrors right settings igoring all left settings
mirror: true,
// ignored
data:[
]
},
center: {
transformX: 'repeat',
transformY: 'scale',
data: [
'000000',
'000000',
'000000',
'000000',
'000000',
]
},
top_left: {
data: [
'##',
'#+'
]
},
top_right: {
mirrorFrom: 'top_left',
},
bottom_left: {
mirrorFrom: 'top_left',
},
bottom_right: {
mirrorFrom: 'top_left',
}
};
// result
var result = [
'##'+'010101'+'##',
'#+'+'010101'+'+#',
'#1'+'000000'+'1#',
'#0'+'000000'+'0#',
'#1'+'000000'+'1#',
'#0'+'000000'+'0#',
'#1'+'000000'+'1#',
'#+'+'000111'+'+#',
'##'+'000111'+'##',
];
// template format can be loaded from
var result = [
'## 010101 ##',
'#+ 010101 +#',
' ',
'#1 000000 1#',
'#0 000000 0#',
'#1 000000 1#',
'#0 000000 0#',
'#1 000000 1#',
' ',
'#+ 000111 +#',
'## 000111 ##',
];
var config = {
/* full template example
data: [
'## 010101 ##',
'#+ 010101 +#',
' ',
'#1 000000 1#',
'#0 000000 0#',
'#1 000000 1#',
'#0 000000 0#',
'#1 000000 1#',
' ',
'#+ 000111 +#',
'## 000111 ##',
],
*/
// template excluding repeated / mirrored parts
data: [
'## 01 ',
'#+ 01 ',
' ',
' 000000 1#',
' 000000 0#',
' 000000 1#',
' 000000 0#',
' 000000 1#',
' ',
' 01 ',
' 01 ',
],
top: {
// repeat or scale (x only)
transform: 'repeat',
},
right: {
// repeat or scale (y only)
transform: 'repeat'
},
bottom: {
// repeat or scale (x only)
transform: 'scale',
},
left: {
// mirrors right settings igoring all left settings
mirror: true,
},
center: {
// need to set how to scale both x and y
transformX: 'repeat',
transformY: 'scale',
},
// corners don't scale
top_left: {
},
top_right: {
mirrorFrom: 'top_left',
},
bottom_left: {
mirrorFrom: 'top_left',
},
bottom_right: {
mirrorFrom: 'top_left',
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment