color conversion to/from array
This commit is contained in:
parent
ee2a22f7d5
commit
438b3f680d
1 changed files with 26 additions and 0 deletions
|
|
@ -144,6 +144,9 @@ does not alter the array. Alternately, _have_ it alter the array.
|
||||||
$(@).dialog "close"
|
$(@).dialog "close"
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alert arraytocolor colortoarray '#102030'
|
||||||
|
|
||||||
$("#entryname").val data.name
|
$("#entryname").val data.name
|
||||||
$("#entryauthor").val data.author
|
$("#entryauthor").val data.author
|
||||||
$("#entryamiga").val data.amiga
|
$("#entryamiga").val data.amiga
|
||||||
|
|
@ -166,6 +169,29 @@ A Helper function to dump json out of an object as text:
|
||||||
dumpjson = (obj) ->
|
dumpjson = (obj) ->
|
||||||
JSON.stringify(obj)
|
JSON.stringify(obj)
|
||||||
|
|
||||||
|
Color conversion from array to color item:
|
||||||
|
|
||||||
|
This decimal to hex conversion only handles 00-FF but it's fine for this purpose;
|
||||||
|
we actually _want_ that limitation in the output.
|
||||||
|
|
||||||
|
dec2hex = (num) ->
|
||||||
|
"#{('000'+num.toString 16).slice -2}"
|
||||||
|
|
||||||
|
hex2dec = (num) ->
|
||||||
|
parseInt num,16
|
||||||
|
|
||||||
|
arraytocolor = (array) ->
|
||||||
|
c = (dec2hex x for x in array)[0..2].join ''
|
||||||
|
"##{c}"
|
||||||
|
|
||||||
|
colortoarray = (color) ->
|
||||||
|
re = /(\d\d)(\d\d)(\d\d)/
|
||||||
|
c = color.slice 1
|
||||||
|
c1 = c.replace re,"$1,$2,$3"
|
||||||
|
x = (hex2dec i for i in c1.split ",")
|
||||||
|
x.push 0
|
||||||
|
x
|
||||||
|
|
||||||
When clicking 'New' we want to make a brand new Sahli, and then clear out
|
When clicking 'New' we want to make a brand new Sahli, and then clear out
|
||||||
the buttons and create the editor bit as blank.
|
the buttons and create the editor bit as blank.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue