Skip to content

Commit

Permalink
change to begin accepting Javascript methods in infragrammar again, #64
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren committed Jul 30, 2014
1 parent 071b2ed commit fb952e8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 48 deletions.
6 changes: 6 additions & 0 deletions README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ To run the whole node server:
* run `node app.js` or `nodejs app.js` from the root directory.
* navigate to http://localhost:8001/sandbox/

You'll need coffeescript (`sudo apt-get install coffeescript`) to compile the javascript source. After editing the various .coffee files in the public directory, run make to compile them:

* `cd public`
* `make`


24 changes: 12 additions & 12 deletions public/infragram.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -204,26 +204,26 @@ update = (img) ->
render(result)

save_expressions = (r,g,b) ->
r = r.toUpperCase().replace(/X/g,$('#slider').val()/100)
g = g.toUpperCase().replace(/X/g,$('#slider').val()/100)
b = b.toUpperCase().replace(/X/g,$('#slider').val()/100)
r = r.replace(/X/g,$('#slider').val()/100)
g = g.replace(/X/g,$('#slider').val()/100)
b = b.replace(/X/g,$('#slider').val()/100)
r = "R" if r == ""
g = "G" if g == ""
b = "B" if b == ""
eval("r_exp = function(R,G,B){return "+r+";}")
eval("g_exp = function(R,G,B){return "+g+";}")
eval("b_exp = function(R,G,B){return "+b+";}")
eval("r_exp = function(R,G,B){var r=R,g=G,b=B;return "+r+";}")
eval("g_exp = function(R,G,B){var r=R,g=G,b=B;return "+g+";}")
eval("b_exp = function(R,G,B){var r=R,g=G,b=B;return "+b+";}")

save_expressions_hsv = (h,s,v) ->
h = h.toUpperCase().replace(/X/g,$('#slider').val()/100)
s = s.toUpperCase().replace(/X/g,$('#slider').val()/100)
v = v.toUpperCase().replace(/X/g,$('#slider').val()/100)
h = h.replace(/X/g,$('#slider').val()/100)
s = s.replace(/X/g,$('#slider').val()/100)
v = v.replace(/X/g,$('#slider').val()/100)
h = "H" if h == ""
s = "S" if s == ""
v = "V" if v == ""
eval("r_exp = function(R,G,B){var hsv = rgb2hsv(R, G, B), H = hsv[0], S = hsv[1], V = hsv[2]; return hsv2rgb("+h+","+s+","+v+")[0];}")
eval("g_exp = function(R,G,B){var hsv = rgb2hsv(R, G, B), H = hsv[0], S = hsv[1], V = hsv[2]; return hsv2rgb("+h+","+s+","+v+")[1];}")
eval("b_exp = function(R,G,B){var hsv = rgb2hsv(R, G, B), H = hsv[0], S = hsv[1], V = hsv[2]; return hsv2rgb("+h+","+s+","+v+")[2];}")
eval("r_exp = function(R,G,B){var h=H,s=S,v=V,hsv = rgb2hsv(R, G, B), H = hsv[0], S = hsv[1], V = hsv[2]; return hsv2rgb("+h+","+s+","+v+")[0];}")
eval("g_exp = function(R,G,B){var h=H,s=S,v=V,hsv = rgb2hsv(R, G, B), H = hsv[0], S = hsv[1], V = hsv[2]; return hsv2rgb("+h+","+s+","+v+")[1];}")
eval("b_exp = function(R,G,B){var h=H,s=S,v=V,hsv = rgb2hsv(R, G, B), H = hsv[0], S = hsv[1], V = hsv[2]; return hsv2rgb("+h+","+s+","+v+")[2];}")

# modified from:
# http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
Expand Down
70 changes: 35 additions & 35 deletions public/infragram.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion views/layout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ html
script(src="/bootstrap/js/bootstrap-slider.js")
script(src="/socket.io/socket.io.js")
script(src="/webgl-utils.js")
script(src="/infragram.js?hash=4837c9a132bd450a6a5f2d60163dbd335d1f3534")
script(src="/infragram.js?hash=bc3922928c235167f815afa0f517c480779bc51c")

script#shader-vs(type="x-shader/x-vertex")
script#shader-fs-template(type="x-shader/x-fragment")
Expand Down

0 comments on commit fb952e8

Please sign in to comment.