├── icons
├── china.png
├── donut.png
├── drink.png
├── fish.png
├── pizza.png
├── bananas.png
├── candies.png
├── icecreame.png
├── icecreame2.png
└── watermellon.png
├── testem.json
├── .gitignore
├── package.json
├── css
├── mixins.styl
├── main.css
└── main.styl
├── README.md
├── js
├── gruntfile.map
├── gruntfile.js
├── lib
│ ├── jq-events.js
│ ├── tween.min.js
│ └── dat.gui.min.js
├── main.map
├── main.coffee
└── main.js
├── gruntfile.coffee
├── index.html
└── index.jade
/icons/china.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/legomushroom/paperjs-scroll-sections/HEAD/icons/china.png
--------------------------------------------------------------------------------
/icons/donut.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/legomushroom/paperjs-scroll-sections/HEAD/icons/donut.png
--------------------------------------------------------------------------------
/icons/drink.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/legomushroom/paperjs-scroll-sections/HEAD/icons/drink.png
--------------------------------------------------------------------------------
/icons/fish.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/legomushroom/paperjs-scroll-sections/HEAD/icons/fish.png
--------------------------------------------------------------------------------
/icons/pizza.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/legomushroom/paperjs-scroll-sections/HEAD/icons/pizza.png
--------------------------------------------------------------------------------
/icons/bananas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/legomushroom/paperjs-scroll-sections/HEAD/icons/bananas.png
--------------------------------------------------------------------------------
/icons/candies.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/legomushroom/paperjs-scroll-sections/HEAD/icons/candies.png
--------------------------------------------------------------------------------
/icons/icecreame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/legomushroom/paperjs-scroll-sections/HEAD/icons/icecreame.png
--------------------------------------------------------------------------------
/icons/icecreame2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/legomushroom/paperjs-scroll-sections/HEAD/icons/icecreame2.png
--------------------------------------------------------------------------------
/testem.json:
--------------------------------------------------------------------------------
1 | {
2 | "src_files": [
3 | "js/lib/*.js",
4 | "js/*.js",
5 | "js/tests/*.js"
6 | ]
7 | }
--------------------------------------------------------------------------------
/icons/watermellon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/legomushroom/paperjs-scroll-sections/HEAD/icons/watermellon.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # osx noise
2 | .DS_Store
3 | profile
4 |
5 | # xcode noise
6 | build/*
7 | *.mode1
8 | *.mode1v3
9 | *.mode2v3
10 | *.perspective
11 | *.perspectivev3
12 | *.pbxuser
13 | *.xcworkspace
14 | xcuserdata
15 |
16 | # svn & cvs
17 | .svn
18 | CVS
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jelly-menu",
3 | "version": "0.0.0",
4 | "devDependencies": {
5 | "grunt": "~0.4.1",
6 | "grunt-contrib-watch": "~0.3.1",
7 | "grunt-contrib-uglify": "~0.2.0",
8 | "grunt-contrib-concat": "~0.3.0"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/css/mixins.styl:
--------------------------------------------------------------------------------
1 | GS = 8px
2 | BR = 3px
3 |
4 |
5 | bbox()
6 | -webkit-box-sizing: border-box;
7 | -moz-box-sizing: border-box;
8 | box-sizing: border-box;
9 |
10 | rect(size)
11 | width size
12 | height size
13 |
14 | hl(color, size=1px)
15 | outline size solid color
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | paperjs-scroll-sections
2 | =======================
3 | http://codepen.io/sol0mka/full/Jsyxq
4 |
5 | Touch device jelly menu concept - What would you like to eat today?
6 | Will be great x with native implementation on touch devices
7 |
8 | My inspiration started here http://capptivate.co/2013/07/12/making-3/
9 | Most of icons are Ashleigh Brennan's http://dribbble.com/ash-brennan
10 |
--------------------------------------------------------------------------------
/js/gruntfile.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "file": "gruntfile.js",
4 | "sourceRoot": "..",
5 | "sources": [
6 | "gruntfile.coffee"
7 | ],
8 | "names": [],
9 | "mappings": ";AAAA,CAAO,EAAU,EAAA,CAAX,CAAN,EAAkB;CAChB,CAAA,GAAK,KAAL;CACE,CAAK,CAAL,CAAA,CAAU,GAAL,MAAA;CAAL,CAEE,EADF,EAAA;CACE,CACE,IADF,CAAA;CACE,CAAW,CAAX,KAAA,CAAA;QADF;CAAA,CAIE,EADF,EAAA;CACE,CAAK,CAAL,KAAA,SAAK,IAAA,EAAA,CAAA,KAAA;CAAL,CAQM,EAAN,IAAA,iBARA;QAJF;MAFF;CAAA,CAiBE,EADF,EAAA;CACE,CACE,IADF,CAAA;CACE,CAAQ,IAAR,EAAA,8DAAA;QADF;CAAA,CAIE,EADF,EAAA;CACE,CACE,GADF,GAAA;CACE,CAA+B,QAA/B,eAA+B,IAA/B;UADF;QAJF;MAjBF;CAAA,CAyBE,EADF,CAAA;CACE,CAAO,GAAP,CAAA,eAAO;CAAP,CACO,GAAP,CAAA,EAAO;MA1BT;CADF,GAAA;CAAA,CA6BA,GAAK,OAAL,SAAA;CA7BA,CA8BA,GAAK,OAAL,UAAA;CA9BA,CA+BA,GAAK,OAAL,UAAA;CACM,CAAwB,GAAzB,GAAyB,CAA9B,GAAA;CAjCe"
10 | }
--------------------------------------------------------------------------------
/gruntfile.coffee:
--------------------------------------------------------------------------------
1 | module.exports = (grunt) ->
2 | grunt.initConfig
3 | pkg: grunt.file.readJSON("package.json")
4 | concat:
5 | options:
6 | separator: ";"
7 |
8 | dist:
9 | src: [
10 | "js/lib/jquery-2.0.1.js",
11 | "js/lib/jq-events.js",
12 | "js/lib/jquery.mousewheel.js",
13 | "js/lib/tween.min.js",
14 | "js/lib/dat.gui.min.js",
15 | "js/lib/paper.js"
16 | ]
17 | dest: "dist/<%= pkg.name %>.js"
18 |
19 | uglify:
20 | options:
21 | banner: "/*! <%= pkg.name %> <%= grunt.template.today(\"dd-mm-yyyy\") %> */\n"
22 |
23 | dist:
24 | files:
25 | "dist/<%= pkg.name %>.min.js": ["<%= concat.dist.dest %>"]
26 |
27 | watch:
28 | files: ["<%= jshint.files %>"]
29 | tasks: ["concat", "uglify"]
30 |
31 | grunt.loadNpmTasks "grunt-contrib-watch"
32 | grunt.loadNpmTasks "grunt-contrib-uglify"
33 | grunt.loadNpmTasks "grunt-contrib-concat"
34 | grunt.registerTask "default", ["concat", "uglify"]
--------------------------------------------------------------------------------
/js/gruntfile.js:
--------------------------------------------------------------------------------
1 | // Generated by CoffeeScript 1.6.2
2 | module.exports = function(grunt) {
3 | grunt.initConfig({
4 | pkg: grunt.file.readJSON("package.json"),
5 | concat: {
6 | options: {
7 | separator: ";"
8 | },
9 | dist: {
10 | src: ["js/lib/jquery-2.0.1.js", "js/lib/jq-events.js", "js/lib/jquery.mousewheel.js", "js/lib/tween.min.js", "js/lib/dat.gui.min.js", "js/lib/paper.js"],
11 | dest: "dist/<%= pkg.name %>.js"
12 | }
13 | },
14 | uglify: {
15 | options: {
16 | banner: "/*! <%= pkg.name %> <%= grunt.template.today(\"dd-mm-yyyy\") %> */\n"
17 | },
18 | dist: {
19 | files: {
20 | "dist/<%= pkg.name %>.min.js": ["<%= concat.dist.dest %>"]
21 | }
22 | }
23 | },
24 | watch: {
25 | files: ["<%= jshint.files %>"],
26 | tasks: ["concat", "uglify"]
27 | }
28 | });
29 | grunt.loadNpmTasks("grunt-contrib-watch");
30 | grunt.loadNpmTasks("grunt-contrib-uglify");
31 | grunt.loadNpmTasks("grunt-contrib-concat");
32 | return grunt.registerTask("default", ["concat", "uglify"]);
33 | };
34 |
35 | /*
36 | //@ sourceMappingURL=gruntfile.map
37 | */
38 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
9 |
10 |
11 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/js/lib/jq-events.js:
--------------------------------------------------------------------------------
1 | /*
2 | * throttledresize: special jQuery event that happens at a reduced rate compared to "resize"
3 | *
4 | * latest version and complete README available on Github:
5 | * https://github.com/louisremi/jquery-smartresize
6 | *
7 | * Copyright 2012 @louis_remi
8 | * Licensed under the MIT license.
9 | *
10 | * This saved you an hour of work?
11 | * Send me music http://www.amazon.co.uk/wishlist/HNTU0468LQON
12 | */
13 | (function($) {
14 |
15 | var $event = $.event,
16 | $special,
17 | dummy = {_:0},
18 | frame = 0,
19 | wasResized, animRunning;
20 |
21 | $special = $event.special.throttledresize = {
22 | setup: function() {
23 | $( this ).on( "resize", $special.handler );
24 | },
25 | teardown: function() {
26 | $( this ).off( "resize", $special.handler );
27 | },
28 | handler: function( event, execAsap ) {
29 | // Save the context
30 | var context = this,
31 | args = arguments;
32 |
33 | wasResized = true;
34 |
35 | if ( !animRunning ) {
36 | setInterval(function(){
37 | frame++;
38 |
39 | if ( frame > $special.threshold && wasResized || execAsap ) {
40 | // set correct event type
41 | event.type = "throttledresize";
42 | $event.dispatch.apply( context, args );
43 | wasResized = false;
44 | frame = 0;
45 | }
46 | if ( frame > 9 ) {
47 | $(dummy).stop();
48 | animRunning = false;
49 | frame = 0;
50 | }
51 | }, 30);
52 | animRunning = true;
53 | }
54 | },
55 | threshold: 0
56 | };
57 |
58 | })(jQuery);
--------------------------------------------------------------------------------
/js/lib/tween.min.js:
--------------------------------------------------------------------------------
1 | // tween.js - http://github.com/sole/tween.js
2 | 'use strict';var TWEEN=TWEEN||function(){var a=[];return{REVISION:"10",getAll:function(){return a},removeAll:function(){a=[]},add:function(c){a.push(c)},remove:function(c){c=a.indexOf(c);-1!==c&&a.splice(c,1)},update:function(c){if(0===a.length)return!1;for(var b=0,d=a.length,c=void 0!==c?c:void 0!==window.performance&&void 0!==window.performance.now?window.performance.now():Date.now();b(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*a:0.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return 1>(a*=2)?0.5*a*a*a*a:-0.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*
7 | a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*a*a*a:0.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return 0.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:1>(a*=2)?0.5*Math.pow(1024,a-1):0.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-
8 | Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return 1>(a*=2)?-0.5*(Math.sqrt(1-a*a)-1):0.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var c,b=0.1;if(0===a)return 0;if(1===a)return 1;!b||1>b?(b=1,c=0.1):c=0.4*Math.asin(1/b)/(2*Math.PI);return-(b*Math.pow(2,10*(a-=1))*Math.sin((a-c)*2*Math.PI/0.4))},Out:function(a){var c,b=0.1;if(0===a)return 0;if(1===a)return 1;!b||1>b?(b=1,c=0.1):c=0.4*Math.asin(1/b)/(2*Math.PI);return b*Math.pow(2,-10*a)*Math.sin((a-c)*
9 | 2*Math.PI/0.4)+1},InOut:function(a){var c,b=0.1;if(0===a)return 0;if(1===a)return 1;!b||1>b?(b=1,c=0.1):c=0.4*Math.asin(1/b)/(2*Math.PI);return 1>(a*=2)?-0.5*b*Math.pow(2,10*(a-=1))*Math.sin((a-c)*2*Math.PI/0.4):0.5*b*Math.pow(2,-10*(a-=1))*Math.sin((a-c)*2*Math.PI/0.4)+1}},Back:{In:function(a){return a*a*(2.70158*a-1.70158)},Out:function(a){return--a*a*(2.70158*a+1.70158)+1},InOut:function(a){return 1>(a*=2)?0.5*a*a*(3.5949095*a-2.5949095):0.5*((a-=2)*a*(3.5949095*a+2.5949095)+2)}},Bounce:{In:function(a){return 1-
10 | TWEEN.Easing.Bounce.Out(1-a)},Out:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+0.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+0.9375:7.5625*(a-=2.625/2.75)*a+0.984375},InOut:function(a){return 0.5>a?0.5*TWEEN.Easing.Bounce.In(2*a):0.5*TWEEN.Easing.Bounce.Out(2*a-1)+0.5}}};
11 | TWEEN.Interpolation={Linear:function(a,c){var b=a.length-1,d=b*c,e=Math.floor(d),g=TWEEN.Interpolation.Utils.Linear;return 0>c?g(a[0],a[1],d):1b?b:e+1],d-e)},Bezier:function(a,c){var b=0,d=a.length-1,e=Math.pow,g=TWEEN.Interpolation.Utils.Bernstein,i;for(i=0;i<=d;i++)b+=e(1-c,d-i)*e(c,i)*a[i]*g(d,i);return b},CatmullRom:function(a,c){var b=a.length-1,d=b*c,e=Math.floor(d),g=TWEEN.Interpolation.Utils.CatmullRom;return a[0]===a[b]?(0>c&&(e=Math.floor(d=b*(1+c))),g(a[(e-
12 | 1+b)%b],a[e],a[(e+1)%b],a[(e+2)%b],d-e)):0>c?a[0]-(g(a[0],a[0],a[1],a[1],-d)-a[0]):1
2 | @segments[3].point.x = @segments[0].point.x + width
3 | @segments[2].point.x = @segments[1].point.x + width
4 |
5 | Path::setHeight = (height)->
6 | @segments[1].point.y = @segments[0].point.y + height
7 | @segments[2].point.y = @segments[3].point.y + height
8 |
9 | Path::reset = ->
10 | @setWidth 0
11 | @setHeight 0
12 | @smooth()
13 |
14 | # Path::copyPath = (path)->
15 | # for i in [path.segments.length-1..0]
16 | # @.add new Point path.segments[i].point
17 |
18 | h =
19 | getRand:(min,max)->
20 | Math.floor((Math.random() * ((max + 1) - min)) + min)
21 |
22 |
23 |
24 | window.PaperSections ?= {}
25 | window.PaperSections.$container = $('#wrapper')
26 | window.PaperSections.i = 0
27 | window.PaperSections.next = 0
28 | window.PaperSections.prev = 0
29 | window.PaperSections.scrollSpeed = 0
30 | window.PaperSections.timeOut = null
31 | window.PaperSections.invertScroll = true
32 |
33 | windowHeight = $(window).outerHeight()
34 |
35 | window.PaperSections.$canvas = $(view.canvas)
36 | window.PaperSections.data = window.PaperSections.$canvas.data()
37 | window.PaperSections.data.colors = window.PaperSections.data.colors.split ':'
38 | window.PaperSections.data.sectionscount ?= window.PaperSections.data.colors.length
39 | view.setViewSize $(window).outerWidth(), (window.PaperSections.data.sectionheight*(window.PaperSections.data.sectionscount))
40 | window.PaperSections.data.sectionheight = parseInt window.PaperSections.data.sectionheight
41 | window.PaperSections.$content = $("##{window.PaperSections.data.contentid}")
42 | window.PaperSections.$sections = window.PaperSections.$content.children()
43 |
44 |
45 | window.PaperSections.slice = (val, max)->
46 | if val > 0 and val > max then return Math.min val, max
47 | if val < 0 and val < max then return Math.max val, - max
48 | val
49 |
50 | class SSection
51 | constructor:(o)->
52 | @o = o
53 | @w = view.size.width
54 | @h = view.size.height
55 | @ph = 60
56 | @sh = @procent @h, @ph
57 | @wh = 1*@w
58 | @scrollSpeed = 0
59 | @gapSize = @procent @h, (100-@ph)/2
60 | @colors = ['#69d2e7','#A7DBD8','#E0E4CC','#F38630','#FA6900']
61 | @twns = []
62 |
63 | @getPrefix()
64 | @makeBase()
65 | @listenToStop()
66 |
67 | getPrefix:->
68 | styles = window.getComputedStyle(document.documentElement, "")
69 | pre = (Array::slice.call(styles).join("").match(/-(moz|webkit|ms)-/) or (styles.OLink is "" and ["", "o"]))[1]
70 | @prefix = "-" + pre + "-"
71 | @transformPrefix = "#{@prefix}transform"
72 |
73 |
74 | listenToStop:->
75 | window.PaperSections.$container.on 'scroll', =>
76 | window.PaperSections.stop = false
77 | @poped = false
78 | TWEEN.removeAll()
79 |
80 |
81 |
82 |
83 | window.PaperSections.$container.on 'stopScroll', =>
84 | window.PaperSections.stop = true
85 | duration = window.PaperSections.slice(Math.abs(window.PaperSections.scrollSpeed*25), 1400) or 3000
86 | @translatePointY(
87 | point: @base.segments[1].handleOut
88 | to: 0
89 | duration: duration
90 | ).then =>
91 | window.PaperSections.scrollSpeed = 0
92 |
93 | @translatePointY
94 | point: @base.segments[3].handleOut
95 | to: 0
96 | duration: duration
97 |
98 |
99 | translateLine:(o)->
100 | dfr = new $.Deferred
101 | mTW = new TWEEN.Tween(new Point(o.point)).to(new Point(o.to), o.duration)
102 | mTW.easing o.easing or TWEEN.Easing.Elastic.Out
103 | it = @
104 | mTW.onUpdate o.onUpdate or (a)->
105 | o.point.y = @y
106 | o.point2?.y = @y
107 |
108 | mTW.onComplete =>
109 | dfr.resolve()
110 |
111 | mTW.start()
112 | dfr.promise()
113 |
114 |
115 | notListenToStop:->
116 | window.PaperSections.$container.off 'stopScroll'
117 | window.PaperSections.$container.off 'scroll'
118 |
119 |
120 | translatePointY:(o)->
121 | dfr = new $.Deferred
122 | mTW = new TWEEN.Tween(new Point(o.point)).to(new Point(o.to), o.duration)
123 | mTW.easing o.easing or TWEEN.Easing.Elastic.Out
124 | it = @
125 | mTW.onUpdate o.onUpdate or (a)->
126 | o.point.y = @y
127 |
128 | !it.poped and window.PaperSections.$content.attr 'style', "#{it.transformPrefix}: translate3d(0,#{@y/2}px,0);transform: translate3d(0,#{@y/2}px,0);"
129 | (it.poped and !it.popedCenter) and window.PaperSections.$sections.eq(it.index).attr 'style', "#{it.transformPrefix}: translate3d(0,#{@y/2}px,0);transform: translate3d(0,#{@y/2}px,0);"
130 |
131 | mTW.onComplete =>
132 | dfr.resolve()
133 |
134 | mTW.start()
135 | dfr.promise()
136 |
137 |
138 |
139 |
140 | makeBase:->
141 | @base = new Path.Rectangle new Point(0, @o.offset), [@wh, @o.height]
142 | @base.fillColor = @o.color
143 |
144 | toppie:(amount)->
145 | @base.segments[1].handleOut.y = amount
146 | @base.segments[1].handleOut.x = (@wh/2)
147 |
148 | bottie:(amount)->
149 | @base.segments[3].handleOut.y = amount
150 | @base.segments[3].handleOut.x = - @wh/2
151 |
152 |
153 | createPath:(o)->
154 | path = new Path o.points
155 | o.flatten and path.flatten o.flatten
156 | path.fillColor = o.fillColor or 'transparent'
157 | path
158 |
159 | update:->
160 | if !window.PaperSections.stop and !@poped
161 | @toppie window.PaperSections.scrollSpeed
162 | @bottie window.PaperSections.scrollSpeed
163 | # window.PaperSections.$content.css 'top': "#{window.PaperSections.scrollSpeed/2}px"
164 | window.PaperSections.$content.attr 'style', "#{@transformPrefix}: translate3d(0,#{window.PaperSections.scrollSpeed/2}px,0);transform: translate3d(0,#{window.PaperSections.scrollSpeed/2}px,0);"
165 |
166 | TWEEN.update()
167 |
168 | procent:(base, percents)->
169 | (base/100)*percents
170 |
171 | pop:->
172 | @poped = true
173 | @popedCenter = true
174 |
175 | @translatePointY(
176 | point: @base.segments[1].handleOut
177 | to: -window.PaperSections.data.sectionheight/1.75
178 | duration: 100
179 | easing:TWEEN.Easing.Linear.None
180 | ).then =>
181 | @translatePointY(
182 | point: @base.segments[1].handleOut
183 | to: 0
184 | ).then =>
185 |
186 | @translatePointY
187 | point: @base.segments[3].handleOut
188 | to: 0
189 |
190 | @translatePointY
191 | point: @base.segments[3].handleOut
192 | to: window.PaperSections.data.sectionheight/1.75
193 | duration: 100
194 | easing:TWEEN.Easing.Linear.None
195 |
196 |
197 |
198 | popUP:->
199 | @poped = true
200 | @popedCenter = false
201 |
202 | @translatePointY(
203 | point: @base.segments[1].handleOut
204 | to: -window.PaperSections.data.sectionheight/1.75
205 | duration: 100
206 | easing:TWEEN.Easing.Linear.None
207 |
208 | ).then =>
209 | @translatePointY(
210 | point: @base.segments[1].handleOut
211 | to: 0
212 | ).then =>
213 |
214 | @translatePointY
215 | point: @base.segments[3].handleOut
216 | to: 0
217 |
218 | @translatePointY
219 | point: @base.segments[3].handleOut
220 | to: -window.PaperSections.data.sectionheight/1.75
221 | duration: 100
222 | easing:TWEEN.Easing.Linear.None
223 |
224 |
225 |
226 | popDOWN:->
227 | @poped = true
228 | @popedCenter = false
229 | @translatePointY(
230 | point: @base.segments[1].handleOut
231 | to: window.PaperSections.data.sectionheight/1.75
232 | duration: 100
233 | easing:TWEEN.Easing.Linear.None
234 | ).then =>
235 | @translatePointY(
236 | point: @base.segments[1].handleOut
237 | to: 0
238 | ).then =>
239 |
240 | @translatePointY
241 | point: @base.segments[3].handleOut
242 | to: 0
243 |
244 | @translatePointY
245 | point: @base.segments[3].handleOut
246 | to: window.PaperSections.data.sectionheight/1.75
247 | duration: 100
248 | easing:TWEEN.Easing.Linear.None
249 |
250 |
251 |
252 | class Sections
253 | constructor:->
254 | @contents ?= []
255 | for i in [window.PaperSections.data.sectionscount..0]
256 | section = new SSection
257 | offset: (i*window.PaperSections.data.sectionheight) - 5
258 | height: window.PaperSections.data.sectionheight + 5
259 | color: window.PaperSections.data.colors[i]
260 | section.index = i
261 | @contents.push section
262 |
263 | update:->
264 | for it,i in @contents
265 | it.update()
266 |
267 | popSection:(n)->
268 | TWEEN.removeAll()
269 |
270 | for i in [@contents.length-1..0]
271 | if i > @contents.length-n-1
272 | @contents[i].popUP()
273 |
274 | if @contents.length-n-1 is i
275 | @contents[i].pop()
276 |
277 | if i < @contents.length-n-1
278 | @contents[i].popDOWN()
279 |
280 | teardown:->
281 | for i in [@contents.length-1..0]
282 | @contents[i].base.remove()
283 | @contents[i].notListenToStop()
284 | delete @contents[i]
285 |
286 |
287 | window.PaperSections.sections = new Sections
288 |
289 |
290 | onFrame = (e)->
291 | window.PaperSections.sections.update()
292 |
293 | mwheel = (e, d)->
294 | $content = $('#js-content')
295 | $$ = $ @
296 | if $$.scrollTop() is 0 and d > 0
297 | e.stopPropagation()
298 | e.preventDefault()
299 | if d < 0 and ($$.scrollTop() is ($content[0].scrollHeight - window.PaperSections.$container.height()))
300 | e.stopPropagation()
301 | e.preventDefault()
302 |
303 | $(window).on 'throttledresize', ->
304 | window.PaperSections.$container.off 'scroll'
305 | window.PaperSections.$container.off 'mousewheel'
306 | window.PaperSections.sections.teardown()
307 | delete window.PaperSections.sections
308 | window.PaperSections.sections = new Sections
309 | view.setViewSize window.PaperSections.$container.outerWidth(), (window.PaperSections.data.sectionheight*(window.PaperSections.data.sectionscount))
310 | window.PaperSections.$container.scroll window.PaperSections.scrollControl
311 | window.PaperSections.$container.on 'mousewheel', mwheel
312 |
313 | window.PaperSections.$container.on 'mousewheel', mwheel
314 |
315 |
316 |
317 |
318 | window.PaperSections.scrollControl = (e, d)->
319 |
320 | clearTimeout window.PaperSections.timeOut
321 | window.PaperSections.timeOut = setTimeout ->
322 | window.PaperSections.i = 0
323 | window.PaperSections.$container.trigger 'stopScroll'
324 | window.PaperSections.prev = window.PaperSections.$container.scrollTop()
325 | , 50
326 |
327 | if window.PaperSections.i % 4 is 0
328 | direction = if window.PaperSections.invertScroll then -1 else 1
329 | window.PaperSections.next = window.PaperSections.$container.scrollTop()
330 | window.PaperSections.scrollSpeed = direction*window.PaperSections.slice 1.2*(window.PaperSections.next - window.PaperSections.prev), window.PaperSections.data.sectionheight/2
331 | window.PaperSections.prev = window.PaperSections.next
332 | window.PaperSections.i++
333 |
334 | false
335 |
336 | window.PaperSections.$container.scroll window.PaperSections.scrollControl
337 |
338 | gui = new dat.GUI
339 | gui.add window.PaperSections, 'invertScroll'
340 |
341 |
342 |
343 | window.PaperSections.$container.on 'mouseenter', '.section-b', ->
344 | window.PaperSections.currSection = $(@).index()
345 |
346 | window.PaperSections.$container.on 'click', '.section-b', ->
347 | $$ = $(@)
348 | window.PaperSections.sections.popSection $$.index()
349 |
350 | if window.PaperSections.win or window.PaperSections.ff then window.PaperSections.$container.addClass 'is-with-scroll'
351 |
352 |
353 |
354 |
--------------------------------------------------------------------------------
/js/main.js:
--------------------------------------------------------------------------------
1 | // Generated by CoffeeScript 1.6.2
2 | var SSection, Sections, gui, h, mwheel, onFrame, windowHeight, _base, _ref, _ref1;
3 |
4 | Path.prototype.setWidth = function(width) {
5 | this.segments[3].point.x = this.segments[0].point.x + width;
6 | return this.segments[2].point.x = this.segments[1].point.x + width;
7 | };
8 |
9 | Path.prototype.setHeight = function(height) {
10 | this.segments[1].point.y = this.segments[0].point.y + height;
11 | return this.segments[2].point.y = this.segments[3].point.y + height;
12 | };
13 |
14 | Path.prototype.reset = function() {
15 | this.setWidth(0);
16 | this.setHeight(0);
17 | return this.smooth();
18 | };
19 |
20 | h = {
21 | getRand: function(min, max) {
22 | return Math.floor((Math.random() * ((max + 1) - min)) + min);
23 | }
24 | };
25 |
26 | if ((_ref = window.PaperSections) == null) {
27 | window.PaperSections = {};
28 | }
29 |
30 | window.PaperSections.$container = $('#wrapper');
31 |
32 | window.PaperSections.i = 0;
33 |
34 | window.PaperSections.next = 0;
35 |
36 | window.PaperSections.prev = 0;
37 |
38 | window.PaperSections.scrollSpeed = 0;
39 |
40 | window.PaperSections.timeOut = null;
41 |
42 | window.PaperSections.invertScroll = true;
43 |
44 | windowHeight = $(window).outerHeight();
45 |
46 | window.PaperSections.$canvas = $(view.canvas);
47 |
48 | window.PaperSections.data = window.PaperSections.$canvas.data();
49 |
50 | window.PaperSections.data.colors = window.PaperSections.data.colors.split(':');
51 |
52 | if ((_ref1 = (_base = window.PaperSections.data).sectionscount) == null) {
53 | _base.sectionscount = window.PaperSections.data.colors.length;
54 | }
55 |
56 | view.setViewSize($(window).outerWidth(), window.PaperSections.data.sectionheight * window.PaperSections.data.sectionscount);
57 |
58 | window.PaperSections.data.sectionheight = parseInt(window.PaperSections.data.sectionheight);
59 |
60 | window.PaperSections.$content = $("#" + window.PaperSections.data.contentid);
61 |
62 | window.PaperSections.$sections = window.PaperSections.$content.children();
63 |
64 | window.PaperSections.slice = function(val, max) {
65 | if (val > 0 && val > max) {
66 | return Math.min(val, max);
67 | }
68 | if (val < 0 && val < max) {
69 | return Math.max(val, -max);
70 | }
71 | return val;
72 | };
73 |
74 | SSection = (function() {
75 | function SSection(o) {
76 | this.o = o;
77 | this.w = view.size.width;
78 | this.h = view.size.height;
79 | this.ph = 60;
80 | this.sh = this.procent(this.h, this.ph);
81 | this.wh = 1 * this.w;
82 | this.scrollSpeed = 0;
83 | this.gapSize = this.procent(this.h, (100 - this.ph) / 2);
84 | this.colors = ['#69d2e7', '#A7DBD8', '#E0E4CC', '#F38630', '#FA6900'];
85 | this.twns = [];
86 | this.getPrefix();
87 | this.makeBase();
88 | this.listenToStop();
89 | }
90 |
91 | SSection.prototype.getPrefix = function() {
92 | var pre, styles;
93 |
94 | styles = window.getComputedStyle(document.documentElement, "");
95 | pre = (Array.prototype.slice.call(styles).join("").match(/-(moz|webkit|ms)-/) || (styles.OLink === "" && ["", "o"]))[1];
96 | this.prefix = "-" + pre + "-";
97 | return this.transformPrefix = "" + this.prefix + "transform";
98 | };
99 |
100 | SSection.prototype.listenToStop = function() {
101 | var _this = this;
102 |
103 | window.PaperSections.$container.on('scroll', function() {
104 | window.PaperSections.stop = false;
105 | _this.poped = false;
106 | return TWEEN.removeAll();
107 | });
108 | return window.PaperSections.$container.on('stopScroll', function() {
109 | var duration;
110 |
111 | window.PaperSections.stop = true;
112 | duration = window.PaperSections.slice(Math.abs(window.PaperSections.scrollSpeed * 25), 1400) || 3000;
113 | _this.translatePointY({
114 | point: _this.base.segments[1].handleOut,
115 | to: 0,
116 | duration: duration
117 | }).then(function() {
118 | return window.PaperSections.scrollSpeed = 0;
119 | });
120 | return _this.translatePointY({
121 | point: _this.base.segments[3].handleOut,
122 | to: 0,
123 | duration: duration
124 | });
125 | });
126 | };
127 |
128 | SSection.prototype.translateLine = function(o) {
129 | var dfr, it, mTW,
130 | _this = this;
131 |
132 | dfr = new $.Deferred;
133 | mTW = new TWEEN.Tween(new Point(o.point)).to(new Point(o.to), o.duration);
134 | mTW.easing(o.easing || TWEEN.Easing.Elastic.Out);
135 | it = this;
136 | mTW.onUpdate(o.onUpdate || function(a) {
137 | var _ref2;
138 |
139 | o.point.y = this.y;
140 | return (_ref2 = o.point2) != null ? _ref2.y = this.y : void 0;
141 | });
142 | mTW.onComplete(function() {
143 | return dfr.resolve();
144 | });
145 | mTW.start();
146 | return dfr.promise();
147 | };
148 |
149 | SSection.prototype.notListenToStop = function() {
150 | window.PaperSections.$container.off('stopScroll');
151 | return window.PaperSections.$container.off('scroll');
152 | };
153 |
154 | SSection.prototype.translatePointY = function(o) {
155 | var dfr, it, mTW,
156 | _this = this;
157 |
158 | dfr = new $.Deferred;
159 | mTW = new TWEEN.Tween(new Point(o.point)).to(new Point(o.to), o.duration);
160 | mTW.easing(o.easing || TWEEN.Easing.Elastic.Out);
161 | it = this;
162 | mTW.onUpdate(o.onUpdate || function(a) {
163 | o.point.y = this.y;
164 | !it.poped && window.PaperSections.$content.attr('style', "" + it.transformPrefix + ": translate3d(0," + (this.y / 2) + "px,0);transform: translate3d(0," + (this.y / 2) + "px,0);");
165 | return (it.poped && !it.popedCenter) && window.PaperSections.$sections.eq(it.index).attr('style', "" + it.transformPrefix + ": translate3d(0," + (this.y / 2) + "px,0);transform: translate3d(0," + (this.y / 2) + "px,0);");
166 | });
167 | mTW.onComplete(function() {
168 | return dfr.resolve();
169 | });
170 | mTW.start();
171 | return dfr.promise();
172 | };
173 |
174 | SSection.prototype.makeBase = function() {
175 | this.base = new Path.Rectangle(new Point(0, this.o.offset), [this.wh, this.o.height]);
176 | return this.base.fillColor = this.o.color;
177 | };
178 |
179 | SSection.prototype.toppie = function(amount) {
180 | this.base.segments[1].handleOut.y = amount;
181 | return this.base.segments[1].handleOut.x = this.wh / 2;
182 | };
183 |
184 | SSection.prototype.bottie = function(amount) {
185 | this.base.segments[3].handleOut.y = amount;
186 | return this.base.segments[3].handleOut.x = -this.wh / 2;
187 | };
188 |
189 | SSection.prototype.createPath = function(o) {
190 | var path;
191 |
192 | path = new Path(o.points);
193 | o.flatten && path.flatten(o.flatten);
194 | path.fillColor = o.fillColor || 'transparent';
195 | return path;
196 | };
197 |
198 | SSection.prototype.update = function() {
199 | if (!window.PaperSections.stop && !this.poped) {
200 | this.toppie(window.PaperSections.scrollSpeed);
201 | this.bottie(window.PaperSections.scrollSpeed);
202 | window.PaperSections.$content.attr('style', "" + this.transformPrefix + ": translate3d(0," + (window.PaperSections.scrollSpeed / 2) + "px,0);transform: translate3d(0," + (window.PaperSections.scrollSpeed / 2) + "px,0);");
203 | }
204 | return TWEEN.update();
205 | };
206 |
207 | SSection.prototype.procent = function(base, percents) {
208 | return (base / 100) * percents;
209 | };
210 |
211 | SSection.prototype.pop = function() {
212 | var _this = this;
213 |
214 | this.poped = true;
215 | this.popedCenter = true;
216 | this.translatePointY({
217 | point: this.base.segments[1].handleOut,
218 | to: -window.PaperSections.data.sectionheight / 1.75,
219 | duration: 100,
220 | easing: TWEEN.Easing.Linear.None
221 | }).then(function() {
222 | _this.translatePointY({
223 | point: _this.base.segments[1].handleOut,
224 | to: 0
225 | }).then(function() {});
226 | return _this.translatePointY({
227 | point: _this.base.segments[3].handleOut,
228 | to: 0
229 | });
230 | });
231 | return this.translatePointY({
232 | point: this.base.segments[3].handleOut,
233 | to: window.PaperSections.data.sectionheight / 1.75,
234 | duration: 100,
235 | easing: TWEEN.Easing.Linear.None
236 | });
237 | };
238 |
239 | SSection.prototype.popUP = function() {
240 | var _this = this;
241 |
242 | this.poped = true;
243 | this.popedCenter = false;
244 | this.translatePointY({
245 | point: this.base.segments[1].handleOut,
246 | to: -window.PaperSections.data.sectionheight / 1.75,
247 | duration: 100,
248 | easing: TWEEN.Easing.Linear.None
249 | }).then(function() {
250 | _this.translatePointY({
251 | point: _this.base.segments[1].handleOut,
252 | to: 0
253 | }).then(function() {});
254 | return _this.translatePointY({
255 | point: _this.base.segments[3].handleOut,
256 | to: 0
257 | });
258 | });
259 | return this.translatePointY({
260 | point: this.base.segments[3].handleOut,
261 | to: -window.PaperSections.data.sectionheight / 1.75,
262 | duration: 100,
263 | easing: TWEEN.Easing.Linear.None
264 | });
265 | };
266 |
267 | SSection.prototype.popDOWN = function() {
268 | var _this = this;
269 |
270 | this.poped = true;
271 | this.popedCenter = false;
272 | this.translatePointY({
273 | point: this.base.segments[1].handleOut,
274 | to: window.PaperSections.data.sectionheight / 1.75,
275 | duration: 100,
276 | easing: TWEEN.Easing.Linear.None
277 | }).then(function() {
278 | _this.translatePointY({
279 | point: _this.base.segments[1].handleOut,
280 | to: 0
281 | }).then(function() {});
282 | return _this.translatePointY({
283 | point: _this.base.segments[3].handleOut,
284 | to: 0
285 | });
286 | });
287 | return this.translatePointY({
288 | point: this.base.segments[3].handleOut,
289 | to: window.PaperSections.data.sectionheight / 1.75,
290 | duration: 100,
291 | easing: TWEEN.Easing.Linear.None
292 | });
293 | };
294 |
295 | return SSection;
296 |
297 | })();
298 |
299 | Sections = (function() {
300 | function Sections() {
301 | var i, section, _i, _ref2, _ref3;
302 |
303 | if ((_ref2 = this.contents) == null) {
304 | this.contents = [];
305 | }
306 | for (i = _i = _ref3 = window.PaperSections.data.sectionscount; _ref3 <= 0 ? _i <= 0 : _i >= 0; i = _ref3 <= 0 ? ++_i : --_i) {
307 | section = new SSection({
308 | offset: (i * window.PaperSections.data.sectionheight) - 5,
309 | height: window.PaperSections.data.sectionheight + 5,
310 | color: window.PaperSections.data.colors[i]
311 | });
312 | section.index = i;
313 | this.contents.push(section);
314 | }
315 | }
316 |
317 | Sections.prototype.update = function() {
318 | var i, it, _i, _len, _ref2, _results;
319 |
320 | _ref2 = this.contents;
321 | _results = [];
322 | for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) {
323 | it = _ref2[i];
324 | _results.push(it.update());
325 | }
326 | return _results;
327 | };
328 |
329 | Sections.prototype.popSection = function(n) {
330 | var i, _i, _ref2, _results;
331 |
332 | TWEEN.removeAll();
333 | _results = [];
334 | for (i = _i = _ref2 = this.contents.length - 1; _ref2 <= 0 ? _i <= 0 : _i >= 0; i = _ref2 <= 0 ? ++_i : --_i) {
335 | if (i > this.contents.length - n - 1) {
336 | this.contents[i].popUP();
337 | }
338 | if (this.contents.length - n - 1 === i) {
339 | this.contents[i].pop();
340 | }
341 | if (i < this.contents.length - n - 1) {
342 | _results.push(this.contents[i].popDOWN());
343 | } else {
344 | _results.push(void 0);
345 | }
346 | }
347 | return _results;
348 | };
349 |
350 | Sections.prototype.teardown = function() {
351 | var i, _i, _ref2, _results;
352 |
353 | _results = [];
354 | for (i = _i = _ref2 = this.contents.length - 1; _ref2 <= 0 ? _i <= 0 : _i >= 0; i = _ref2 <= 0 ? ++_i : --_i) {
355 | this.contents[i].base.remove();
356 | this.contents[i].notListenToStop();
357 | _results.push(delete this.contents[i]);
358 | }
359 | return _results;
360 | };
361 |
362 | return Sections;
363 |
364 | })();
365 |
366 | window.PaperSections.sections = new Sections;
367 |
368 | onFrame = function(e) {
369 | return window.PaperSections.sections.update();
370 | };
371 |
372 | mwheel = function(e, d) {
373 | var $$, $content;
374 |
375 | $content = $('#js-content');
376 | $$ = $(this);
377 | if ($$.scrollTop() === 0 && d > 0) {
378 | e.stopPropagation();
379 | e.preventDefault();
380 | }
381 | if (d < 0 && ($$.scrollTop() === ($content[0].scrollHeight - window.PaperSections.$container.height()))) {
382 | e.stopPropagation();
383 | return e.preventDefault();
384 | }
385 | };
386 |
387 | $(window).on('throttledresize', function() {
388 | window.PaperSections.$container.off('scroll');
389 | window.PaperSections.$container.off('mousewheel');
390 | window.PaperSections.sections.teardown();
391 | delete window.PaperSections.sections;
392 | window.PaperSections.sections = new Sections;
393 | view.setViewSize(window.PaperSections.$container.outerWidth(), window.PaperSections.data.sectionheight * window.PaperSections.data.sectionscount);
394 | window.PaperSections.$container.scroll(window.PaperSections.scrollControl);
395 | return window.PaperSections.$container.on('mousewheel', mwheel);
396 | });
397 |
398 | window.PaperSections.$container.on('mousewheel', mwheel);
399 |
400 | window.PaperSections.scrollControl = function(e, d) {
401 | var direction;
402 |
403 | clearTimeout(window.PaperSections.timeOut);
404 | window.PaperSections.timeOut = setTimeout(function() {
405 | window.PaperSections.i = 0;
406 | window.PaperSections.$container.trigger('stopScroll');
407 | return window.PaperSections.prev = window.PaperSections.$container.scrollTop();
408 | }, 50);
409 | if (window.PaperSections.i % 4 === 0) {
410 | direction = window.PaperSections.invertScroll ? -1 : 1;
411 | window.PaperSections.next = window.PaperSections.$container.scrollTop();
412 | window.PaperSections.scrollSpeed = direction * window.PaperSections.slice(1.2 * (window.PaperSections.next - window.PaperSections.prev), window.PaperSections.data.sectionheight / 2);
413 | window.PaperSections.prev = window.PaperSections.next;
414 | }
415 | window.PaperSections.i++;
416 | return false;
417 | };
418 |
419 | window.PaperSections.$container.scroll(window.PaperSections.scrollControl);
420 |
421 | gui = new dat.GUI;
422 |
423 | gui.add(window.PaperSections, 'invertScroll');
424 |
425 | window.PaperSections.$container.on('mouseenter', '.section-b', function() {
426 | return window.PaperSections.currSection = $(this).index();
427 | });
428 |
429 | window.PaperSections.$container.on('click', '.section-b', function() {
430 | var $$;
431 |
432 | $$ = $(this);
433 | return window.PaperSections.sections.popSection($$.index());
434 | });
435 |
436 | if (window.PaperSections.win || window.PaperSections.ff) {
437 | window.PaperSections.$container.addClass('is-with-scroll');
438 | }
439 |
440 | /*
441 | //@ sourceMappingURL=main.map
442 | */
443 |
--------------------------------------------------------------------------------
/js/lib/dat.gui.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | * dat-gui JavaScript Controller Library
3 | * http://code.google.com/p/dat-gui
4 | *
5 | * Copyright 2011 Data Arts Team, Google Creative Lab
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | */
13 | var dat=dat||{};dat.gui=dat.gui||{};dat.utils=dat.utils||{};dat.controllers=dat.controllers||{};dat.dom=dat.dom||{};dat.color=dat.color||{};dat.utils.css=function(){return{load:function(e,a){var a=a||document,c=a.createElement("link");c.type="text/css";c.rel="stylesheet";c.href=e;a.getElementsByTagName("head")[0].appendChild(c)},inject:function(e,a){var a=a||document,c=document.createElement("style");c.type="text/css";c.innerHTML=e;a.getElementsByTagName("head")[0].appendChild(c)}}}();
14 | dat.utils.common=function(){var e=Array.prototype.forEach,a=Array.prototype.slice;return{BREAK:{},extend:function(c){this.each(a.call(arguments,1),function(a){for(var f in a)this.isUndefined(a[f])||(c[f]=a[f])},this);return c},defaults:function(c){this.each(a.call(arguments,1),function(a){for(var f in a)this.isUndefined(c[f])&&(c[f]=a[f])},this);return c},compose:function(){var c=a.call(arguments);return function(){for(var d=a.call(arguments),f=c.length-1;f>=0;f--)d=[c[f].apply(this,d)];return d[0]}},
15 | each:function(a,d,f){if(e&&a.forEach===e)a.forEach(d,f);else if(a.length===a.length+0)for(var b=0,n=a.length;b-1?d.length-d.indexOf(".")-1:0};c.superclass=e;a.extend(c.prototype,e.prototype,{setValue:function(a){if(this.__min!==void 0&&athis.__max)a=this.__max;this.__step!==void 0&&a%this.__step!=0&&(a=Math.round(a/this.__step)*this.__step);return c.superclass.prototype.setValue.call(this,a)},min:function(a){this.__min=a;return this},max:function(a){this.__max=a;return this},step:function(a){this.__step=a;return this}});return c}(dat.controllers.Controller,dat.utils.common);
29 | dat.controllers.NumberControllerBox=function(e,a,c){var d=function(f,b,e){function h(){var a=parseFloat(l.__input.value);c.isNaN(a)||l.setValue(a)}function j(a){var b=o-a.clientY;l.setValue(l.getValue()+b*l.__impliedStep);o=a.clientY}function m(){a.unbind(window,"mousemove",j);a.unbind(window,"mouseup",m)}this.__truncationSuspended=false;d.superclass.call(this,f,b,e);var l=this,o;this.__input=document.createElement("input");this.__input.setAttribute("type","text");a.bind(this.__input,"change",h);
30 | a.bind(this.__input,"blur",function(){h();l.__onFinishChange&&l.__onFinishChange.call(l,l.getValue())});a.bind(this.__input,"mousedown",function(b){a.bind(window,"mousemove",j);a.bind(window,"mouseup",m);o=b.clientY});a.bind(this.__input,"keydown",function(a){if(a.keyCode===13)l.__truncationSuspended=true,this.blur(),l.__truncationSuspended=false});this.updateDisplay();this.domElement.appendChild(this.__input)};d.superclass=e;c.extend(d.prototype,e.prototype,{updateDisplay:function(){var a=this.__input,
31 | b;if(this.__truncationSuspended)b=this.getValue();else{b=this.getValue();var c=Math.pow(10,this.__precision);b=Math.round(b*c)/c}a.value=b;return d.superclass.prototype.updateDisplay.call(this)}});return d}(dat.controllers.NumberController,dat.dom.dom,dat.utils.common);
32 | dat.controllers.NumberControllerSlider=function(e,a,c,d,f){var b=function(d,c,f,e,l){function o(b){b.preventDefault();var d=a.getOffset(g.__background),c=a.getWidth(g.__background);g.setValue(g.__min+(g.__max-g.__min)*((b.clientX-d.left)/(d.left+c-d.left)));return false}function y(){a.unbind(window,"mousemove",o);a.unbind(window,"mouseup",y);g.__onFinishChange&&g.__onFinishChange.call(g,g.getValue())}b.superclass.call(this,d,c,{min:f,max:e,step:l});var g=this;this.__background=document.createElement("div");
33 | this.__foreground=document.createElement("div");a.bind(this.__background,"mousedown",function(b){a.bind(window,"mousemove",o);a.bind(window,"mouseup",y);o(b)});a.addClass(this.__background,"slider");a.addClass(this.__foreground,"slider-fg");this.updateDisplay();this.__background.appendChild(this.__foreground);this.domElement.appendChild(this.__background)};b.superclass=e;b.useDefaultStyles=function(){c.inject(f)};d.extend(b.prototype,e.prototype,{updateDisplay:function(){this.__foreground.style.width=
34 | (this.getValue()-this.__min)/(this.__max-this.__min)*100+"%";return b.superclass.prototype.updateDisplay.call(this)}});return b}(dat.controllers.NumberController,dat.dom.dom,dat.utils.css,dat.utils.common,".slider {\n box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);\n height: 1em;\n border-radius: 1em;\n background-color: #eee;\n padding: 0 0.5em;\n overflow: hidden;\n}\n\n.slider-fg {\n padding: 1px 0 2px 0;\n background-color: #aaa;\n height: 1em;\n margin-left: -0.5em;\n padding-right: 0.5em;\n border-radius: 1em 0 0 1em;\n}\n\n.slider-fg:after {\n display: inline-block;\n border-radius: 1em;\n background-color: #fff;\n border: 1px solid #aaa;\n content: '';\n float: right;\n margin-right: -1em;\n margin-top: -1px;\n height: 0.9em;\n width: 0.9em;\n}");
35 | dat.controllers.FunctionController=function(e,a,c){var d=function(c,b,e){d.superclass.call(this,c,b);var h=this;this.__button=document.createElement("div");this.__button.innerHTML=e===void 0?"Fire":e;a.bind(this.__button,"click",function(a){a.preventDefault();h.fire();return false});a.addClass(this.__button,"button");this.domElement.appendChild(this.__button)};d.superclass=e;c.extend(d.prototype,e.prototype,{fire:function(){this.__onChange&&this.__onChange.call(this);this.__onFinishChange&&this.__onFinishChange.call(this,
36 | this.getValue());this.getValue().call(this.object)}});return d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common);
37 | dat.controllers.BooleanController=function(e,a,c){var d=function(c,b){d.superclass.call(this,c,b);var e=this;this.__prev=this.getValue();this.__checkbox=document.createElement("input");this.__checkbox.setAttribute("type","checkbox");a.bind(this.__checkbox,"change",function(){e.setValue(!e.__prev)},false);this.domElement.appendChild(this.__checkbox);this.updateDisplay()};d.superclass=e;c.extend(d.prototype,e.prototype,{setValue:function(a){a=d.superclass.prototype.setValue.call(this,a);this.__onFinishChange&&
38 | this.__onFinishChange.call(this,this.getValue());this.__prev=this.getValue();return a},updateDisplay:function(){this.getValue()===true?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=true):this.__checkbox.checked=false;return d.superclass.prototype.updateDisplay.call(this)}});return d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common);
39 | dat.color.toString=function(e){return function(a){if(a.a==1||e.isUndefined(a.a)){for(a=a.hex.toString(16);a.length<6;)a="0"+a;return"#"+a}else return"rgba("+Math.round(a.r)+","+Math.round(a.g)+","+Math.round(a.b)+","+a.a+")"}}(dat.utils.common);
40 | dat.color.interpret=function(e,a){var c,d,f=[{litmus:a.isString,conversions:{THREE_CHAR_HEX:{read:function(a){a=a.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return a===null?false:{space:"HEX",hex:parseInt("0x"+a[1].toString()+a[1].toString()+a[2].toString()+a[2].toString()+a[3].toString()+a[3].toString())}},write:e},SIX_CHAR_HEX:{read:function(a){a=a.match(/^#([A-F0-9]{6})$/i);return a===null?false:{space:"HEX",hex:parseInt("0x"+a[1].toString())}},write:e},CSS_RGB:{read:function(a){a=a.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);
41 | return a===null?false:{space:"RGB",r:parseFloat(a[1]),g:parseFloat(a[2]),b:parseFloat(a[3])}},write:e},CSS_RGBA:{read:function(a){a=a.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return a===null?false:{space:"RGB",r:parseFloat(a[1]),g:parseFloat(a[2]),b:parseFloat(a[3]),a:parseFloat(a[4])}},write:e}}},{litmus:a.isNumber,conversions:{HEX:{read:function(a){return{space:"HEX",hex:a,conversionName:"HEX"}},write:function(a){return a.hex}}}},{litmus:a.isArray,conversions:{RGB_ARRAY:{read:function(a){return a.length!=
42 | 3?false:{space:"RGB",r:a[0],g:a[1],b:a[2]}},write:function(a){return[a.r,a.g,a.b]}},RGBA_ARRAY:{read:function(a){return a.length!=4?false:{space:"RGB",r:a[0],g:a[1],b:a[2],a:a[3]}},write:function(a){return[a.r,a.g,a.b,a.a]}}}},{litmus:a.isObject,conversions:{RGBA_OBJ:{read:function(b){return a.isNumber(b.r)&&a.isNumber(b.g)&&a.isNumber(b.b)&&a.isNumber(b.a)?{space:"RGB",r:b.r,g:b.g,b:b.b,a:b.a}:false},write:function(a){return{r:a.r,g:a.g,b:a.b,a:a.a}}},RGB_OBJ:{read:function(b){return a.isNumber(b.r)&&
43 | a.isNumber(b.g)&&a.isNumber(b.b)?{space:"RGB",r:b.r,g:b.g,b:b.b}:false},write:function(a){return{r:a.r,g:a.g,b:a.b}}},HSVA_OBJ:{read:function(b){return a.isNumber(b.h)&&a.isNumber(b.s)&&a.isNumber(b.v)&&a.isNumber(b.a)?{space:"HSV",h:b.h,s:b.s,v:b.v,a:b.a}:false},write:function(a){return{h:a.h,s:a.s,v:a.v,a:a.a}}},HSV_OBJ:{read:function(b){return a.isNumber(b.h)&&a.isNumber(b.s)&&a.isNumber(b.v)?{space:"HSV",h:b.h,s:b.s,v:b.v}:false},write:function(a){return{h:a.h,s:a.s,v:a.v}}}}}];return function(){d=
44 | false;var b=arguments.length>1?a.toArray(arguments):arguments[0];a.each(f,function(e){if(e.litmus(b))return a.each(e.conversions,function(e,f){c=e.read(b);if(d===false&&c!==false)return d=c,c.conversionName=f,c.conversion=e,a.BREAK}),a.BREAK});return d}}(dat.color.toString,dat.utils.common);
45 | dat.GUI=dat.gui.GUI=function(e,a,c,d,f,b,n,h,j,m,l,o,y,g,i){function q(a,b,r,c){if(b[r]===void 0)throw Error("Object "+b+' has no property "'+r+'"');c.color?b=new l(b,r):(b=[b,r].concat(c.factoryArgs),b=d.apply(a,b));if(c.before instanceof f)c.before=c.before.__li;t(a,b);g.addClass(b.domElement,"c");r=document.createElement("span");g.addClass(r,"property-name");r.innerHTML=b.property;var e=document.createElement("div");e.appendChild(r);e.appendChild(b.domElement);c=s(a,e,c.before);g.addClass(c,k.CLASS_CONTROLLER_ROW);
46 | g.addClass(c,typeof b.getValue());p(a,c,b);a.__controllers.push(b);return b}function s(a,b,d){var c=document.createElement("li");b&&c.appendChild(b);d?a.__ul.insertBefore(c,params.before):a.__ul.appendChild(c);a.onResize();return c}function p(a,d,c){c.__li=d;c.__gui=a;i.extend(c,{options:function(b){if(arguments.length>1)return c.remove(),q(a,c.object,c.property,{before:c.__li.nextElementSibling,factoryArgs:[i.toArray(arguments)]});if(i.isArray(b)||i.isObject(b))return c.remove(),q(a,c.object,c.property,
47 | {before:c.__li.nextElementSibling,factoryArgs:[b]})},name:function(a){c.__li.firstElementChild.firstElementChild.innerHTML=a;return c},listen:function(){c.__gui.listen(c);return c},remove:function(){c.__gui.remove(c);return c}});if(c instanceof j){var e=new h(c.object,c.property,{min:c.__min,max:c.__max,step:c.__step});i.each(["updateDisplay","onChange","onFinishChange"],function(a){var b=c[a],H=e[a];c[a]=e[a]=function(){var a=Array.prototype.slice.call(arguments);b.apply(c,a);return H.apply(e,a)}});
48 | g.addClass(d,"has-slider");c.domElement.insertBefore(e.domElement,c.domElement.firstElementChild)}else if(c instanceof h){var f=function(b){return i.isNumber(c.__min)&&i.isNumber(c.__max)?(c.remove(),q(a,c.object,c.property,{before:c.__li.nextElementSibling,factoryArgs:[c.__min,c.__max,c.__step]})):b};c.min=i.compose(f,c.min);c.max=i.compose(f,c.max)}else if(c instanceof b)g.bind(d,"click",function(){g.fakeEvent(c.__checkbox,"click")}),g.bind(c.__checkbox,"click",function(a){a.stopPropagation()});
49 | else if(c instanceof n)g.bind(d,"click",function(){g.fakeEvent(c.__button,"click")}),g.bind(d,"mouseover",function(){g.addClass(c.__button,"hover")}),g.bind(d,"mouseout",function(){g.removeClass(c.__button,"hover")});else if(c instanceof l)g.addClass(d,"color"),c.updateDisplay=i.compose(function(a){d.style.borderLeftColor=c.__color.toString();return a},c.updateDisplay),c.updateDisplay();c.setValue=i.compose(function(b){a.getRoot().__preset_select&&c.isModified()&&B(a.getRoot(),true);return b},c.setValue)}
50 | function t(a,b){var c=a.getRoot(),d=c.__rememberedObjects.indexOf(b.object);if(d!=-1){var e=c.__rememberedObjectIndecesToControllers[d];e===void 0&&(e={},c.__rememberedObjectIndecesToControllers[d]=e);e[b.property]=b;if(c.load&&c.load.remembered){c=c.load.remembered;if(c[a.preset])c=c[a.preset];else if(c[w])c=c[w];else return;if(c[d]&&c[d][b.property]!==void 0)d=c[d][b.property],b.initialValue=d,b.setValue(d)}}}function I(a){var b=a.__save_row=document.createElement("li");g.addClass(a.domElement,
51 | "has-save");a.__ul.insertBefore(b,a.__ul.firstChild);g.addClass(b,"save-row");var c=document.createElement("span");c.innerHTML=" ";g.addClass(c,"button gears");var d=document.createElement("span");d.innerHTML="Save";g.addClass(d,"button");g.addClass(d,"save");var e=document.createElement("span");e.innerHTML="New";g.addClass(e,"button");g.addClass(e,"save-as");var f=document.createElement("span");f.innerHTML="Revert";g.addClass(f,"button");g.addClass(f,"revert");var m=a.__preset_select=document.createElement("select");
52 | a.load&&a.load.remembered?i.each(a.load.remembered,function(b,c){C(a,c,c==a.preset)}):C(a,w,false);g.bind(m,"change",function(){for(var b=0;b0){a.preset=this.preset;if(!a.remembered)a.remembered={};a.remembered[this.preset]=z(this)}a.folders={};i.each(this.__folders,function(b,
69 | c){a.folders[c]=b.getSaveObject()});return a},save:function(){if(!this.load.remembered)this.load.remembered={};this.load.remembered[this.preset]=z(this);B(this,false)},saveAs:function(a){if(!this.load.remembered)this.load.remembered={},this.load.remembered[w]=z(this,true);this.load.remembered[a]=z(this);this.preset=a;C(this,a,true)},revert:function(a){i.each(this.__controllers,function(b){this.getRoot().load.remembered?t(a||this.getRoot(),b):b.setValue(b.initialValue)},this);i.each(this.__folders,
70 | function(a){a.revert(a)});a||B(this.getRoot(),false)},listen:function(a){var b=this.__listening.length==0;this.__listening.push(a);b&&E(this.__listening)}});return k}(dat.utils.css,'\n\n Here\'s the new load parameter for your
GUI\'s constructor:\n\n
\n\n
\n\n
Automatically save\n values to
localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n \n
\n \n
\n\n
',
71 | ".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear;border:0;position:absolute;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-x:hidden}.dg.a.has-save ul{margin-top:27px}.dg.a.has-save ul.closed{margin-top:0}.dg.a .save-row{position:fixed;top:0;z-index:1002}.dg li{-webkit-transition:height 0.1s ease-out;-o-transition:height 0.1s ease-out;-moz-transition:height 0.1s ease-out;transition:height 0.1s ease-out}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;overflow:hidden;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li > *{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:9px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2fa1d6}.dg .cr.number input[type=text]{color:#2fa1d6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2fa1d6}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n",
72 | dat.controllers.factory=function(e,a,c,d,f,b,n){return function(h,j,m,l){var o=h[j];if(n.isArray(m)||n.isObject(m))return new e(h,j,m);if(n.isNumber(o))return n.isNumber(m)&&n.isNumber(l)?new c(h,j,m,l):new a(h,j,{min:m,max:l});if(n.isString(o))return new d(h,j);if(n.isFunction(o))return new f(h,j,"");if(n.isBoolean(o))return new b(h,j)}}(dat.controllers.OptionController,dat.controllers.NumberControllerBox,dat.controllers.NumberControllerSlider,dat.controllers.StringController=function(e,a,c){var d=
73 | function(c,b){function e(){h.setValue(h.__input.value)}d.superclass.call(this,c,b);var h=this;this.__input=document.createElement("input");this.__input.setAttribute("type","text");a.bind(this.__input,"keyup",e);a.bind(this.__input,"change",e);a.bind(this.__input,"blur",function(){h.__onFinishChange&&h.__onFinishChange.call(h,h.getValue())});a.bind(this.__input,"keydown",function(a){a.keyCode===13&&this.blur()});this.updateDisplay();this.domElement.appendChild(this.__input)};d.superclass=e;c.extend(d.prototype,
74 | e.prototype,{updateDisplay:function(){if(!a.isActive(this.__input))this.__input.value=this.getValue();return d.superclass.prototype.updateDisplay.call(this)}});return d}(dat.controllers.Controller,dat.dom.dom,dat.utils.common),dat.controllers.FunctionController,dat.controllers.BooleanController,dat.utils.common),dat.controllers.Controller,dat.controllers.BooleanController,dat.controllers.FunctionController,dat.controllers.NumberControllerBox,dat.controllers.NumberControllerSlider,dat.controllers.OptionController,
75 | dat.controllers.ColorController=function(e,a,c,d,f){function b(a,b,c,d){a.style.background="";f.each(j,function(e){a.style.cssText+="background: "+e+"linear-gradient("+b+", "+c+" 0%, "+d+" 100%); "})}function n(a){a.style.background="";a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);";a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);";
76 | a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);";a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);";a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var h=function(e,l){function o(b){q(b);a.bind(window,"mousemove",q);a.bind(window,
77 | "mouseup",j)}function j(){a.unbind(window,"mousemove",q);a.unbind(window,"mouseup",j)}function g(){var a=d(this.value);a!==false?(p.__color.__state=a,p.setValue(p.__color.toOriginal())):this.value=p.__color.toString()}function i(){a.unbind(window,"mousemove",s);a.unbind(window,"mouseup",i)}function q(b){b.preventDefault();var c=a.getWidth(p.__saturation_field),d=a.getOffset(p.__saturation_field),e=(b.clientX-d.left+document.body.scrollLeft)/c,b=1-(b.clientY-d.top+document.body.scrollTop)/c;b>1?b=
78 | 1:b<0&&(b=0);e>1?e=1:e<0&&(e=0);p.__color.v=b;p.__color.s=e;p.setValue(p.__color.toOriginal());return false}function s(b){b.preventDefault();var c=a.getHeight(p.__hue_field),d=a.getOffset(p.__hue_field),b=1-(b.clientY-d.top+document.body.scrollTop)/c;b>1?b=1:b<0&&(b=0);p.__color.h=b*360;p.setValue(p.__color.toOriginal());return false}h.superclass.call(this,e,l);this.__color=new c(this.getValue());this.__temp=new c(0);var p=this;this.domElement=document.createElement("div");a.makeSelectable(this.domElement,
79 | false);this.__selector=document.createElement("div");this.__selector.className="selector";this.__saturation_field=document.createElement("div");this.__saturation_field.className="saturation-field";this.__field_knob=document.createElement("div");this.__field_knob.className="field-knob";this.__field_knob_border="2px solid ";this.__hue_knob=document.createElement("div");this.__hue_knob.className="hue-knob";this.__hue_field=document.createElement("div");this.__hue_field.className="hue-field";this.__input=
80 | document.createElement("input");this.__input.type="text";this.__input_textShadow="0 1px 1px ";a.bind(this.__input,"keydown",function(a){a.keyCode===13&&g.call(this)});a.bind(this.__input,"blur",g);a.bind(this.__selector,"mousedown",function(){a.addClass(this,"drag").bind(window,"mouseup",function(){a.removeClass(p.__selector,"drag")})});var t=document.createElement("div");f.extend(this.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"});
81 | f.extend(this.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:this.__field_knob_border+(this.__color.v<0.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1});f.extend(this.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1});f.extend(this.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"});f.extend(t.style,
82 | {width:"100%",height:"100%",background:"none"});b(t,"top","rgba(0,0,0,0)","#000");f.extend(this.__hue_field.style,{width:"15px",height:"100px",display:"inline-block",border:"1px solid #555",cursor:"ns-resize"});n(this.__hue_field);f.extend(this.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:this.__input_textShadow+"rgba(0,0,0,0.7)"});a.bind(this.__saturation_field,"mousedown",o);a.bind(this.__field_knob,"mousedown",o);a.bind(this.__hue_field,"mousedown",
83 | function(b){s(b);a.bind(window,"mousemove",s);a.bind(window,"mouseup",i)});this.__saturation_field.appendChild(t);this.__selector.appendChild(this.__field_knob);this.__selector.appendChild(this.__saturation_field);this.__selector.appendChild(this.__hue_field);this.__hue_field.appendChild(this.__hue_knob);this.domElement.appendChild(this.__input);this.domElement.appendChild(this.__selector);this.updateDisplay()};h.superclass=e;f.extend(h.prototype,e.prototype,{updateDisplay:function(){var a=d(this.getValue());
84 | if(a!==false){var e=false;f.each(c.COMPONENTS,function(b){if(!f.isUndefined(a[b])&&!f.isUndefined(this.__color.__state[b])&&a[b]!==this.__color.__state[b])return e=true,{}},this);e&&f.extend(this.__color.__state,a)}f.extend(this.__temp.__state,this.__color.__state);this.__temp.a=1;var h=this.__color.v<0.5||this.__color.s>0.5?255:0,j=255-h;f.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toString(),border:this.__field_knob_border+
85 | "rgb("+h+","+h+","+h+")"});this.__hue_knob.style.marginTop=(1-this.__color.h/360)*100+"px";this.__temp.s=1;this.__temp.v=1;b(this.__saturation_field,"left","#fff",this.__temp.toString());f.extend(this.__input.style,{backgroundColor:this.__input.value=this.__color.toString(),color:"rgb("+h+","+h+","+h+")",textShadow:this.__input_textShadow+"rgba("+j+","+j+","+j+",.7)"})}});var j=["-moz-","-o-","-webkit-","-ms-",""];return h}(dat.controllers.Controller,dat.dom.dom,dat.color.Color=function(e,a,c,d){function f(a,
86 | b,c){Object.defineProperty(a,b,{get:function(){if(this.__state.space==="RGB")return this.__state[b];n(this,b,c);return this.__state[b]},set:function(a){if(this.__state.space!=="RGB")n(this,b,c),this.__state.space="RGB";this.__state[b]=a}})}function b(a,b){Object.defineProperty(a,b,{get:function(){if(this.__state.space==="HSV")return this.__state[b];h(this);return this.__state[b]},set:function(a){if(this.__state.space!=="HSV")h(this),this.__state.space="HSV";this.__state[b]=a}})}function n(b,c,e){if(b.__state.space===
87 | "HEX")b.__state[c]=a.component_from_hex(b.__state.hex,e);else if(b.__state.space==="HSV")d.extend(b.__state,a.hsv_to_rgb(b.__state.h,b.__state.s,b.__state.v));else throw"Corrupted color state";}function h(b){var c=a.rgb_to_hsv(b.r,b.g,b.b);d.extend(b.__state,{s:c.s,v:c.v});if(d.isNaN(c.h)){if(d.isUndefined(b.__state.h))b.__state.h=0}else b.__state.h=c.h}var j=function(){this.__state=e.apply(this,arguments);if(this.__state===false)throw"Failed to interpret color arguments";this.__state.a=this.__state.a||
88 | 1};j.COMPONENTS="r,g,b,h,s,v,hex,a".split(",");d.extend(j.prototype,{toString:function(){return c(this)},toOriginal:function(){return this.__state.conversion.write(this)}});f(j.prototype,"r",2);f(j.prototype,"g",1);f(j.prototype,"b",0);b(j.prototype,"h");b(j.prototype,"s");b(j.prototype,"v");Object.defineProperty(j.prototype,"a",{get:function(){return this.__state.a},set:function(a){this.__state.a=a}});Object.defineProperty(j.prototype,"hex",{get:function(){if(!this.__state.space!=="HEX")this.__state.hex=
89 | a.rgb_to_hex(this.r,this.g,this.b);return this.__state.hex},set:function(a){this.__state.space="HEX";this.__state.hex=a}});return j}(dat.color.interpret,dat.color.math=function(){var e;return{hsv_to_rgb:function(a,c,d){var e=a/60-Math.floor(a/60),b=d*(1-c),n=d*(1-e*c),c=d*(1-(1-e)*c),a=[[d,c,b],[n,d,b],[b,d,c],[b,n,d],[c,b,d],[d,b,n]][Math.floor(a/60)%6];return{r:a[0]*255,g:a[1]*255,b:a[2]*255}},rgb_to_hsv:function(a,c,d){var e=Math.min(a,c,d),b=Math.max(a,c,d),e=b-e;if(b==0)return{h:NaN,s:0,v:0};
90 | a=a==b?(c-d)/e:c==b?2+(d-a)/e:4+(a-c)/e;a/=6;a<0&&(a+=1);return{h:a*360,s:e/b,v:b/255}},rgb_to_hex:function(a,c,d){a=this.hex_with_component(0,2,a);a=this.hex_with_component(a,1,c);return a=this.hex_with_component(a,0,d)},component_from_hex:function(a,c){return a>>c*8&255},hex_with_component:function(a,c,d){return d<<(e=c*8)|a&~(255<