File size: 58,228 Bytes
e9d4572
1
__require=function e(n,t,o){function i(a,c){if(!t[a]){if(!n[a]){var d=a.split("/");if(d=d[d.length-1],!n[d]){var s="function"==typeof __require&&__require;if(!c&&s)return s(d,!0);if(r)return r(d,!0);throw new Error("Cannot find module '"+a+"'")}}var w=t[a]={exports:{}};n[a][0].call(w.exports,function(e){return i(n[a][1][e]||e)},w,w.exports,e,n,t,o)}return t[a].exports}for(var r="function"==typeof __require&&__require,a=0;a<o.length;a++)i(o[a]);return i}({BoxCanvas:[function(e,n,t){"use strict";cc._RF.push(n,"fe52erRfo9NV5lQabMArD3F","BoxCanvas"),n.exports=function(e){var n=Object();return n.spriteFrame=new cc.SpriteFrame,n.texture2d=null,n.canvas=document.createElement("canvas"),n.canvas.id="canvas_"+e,n.ini=function(e,t){return n.canvas.width=parseInt(e),n.canvas.height=parseInt(t),n.ctx=n.canvas.getContext("2d"),n.ctx.fillStyle=n.ctx.createPattern(window.boxLoader.image,"repeat"),n.ctx.fillRect(0,0,n.canvas.width,n.canvas.height),n.texture2d=new cc.Texture2D,n.spriteFrame.setTexture(n.texture2d),n.texture2d.initWithElement(n.canvas),n.texture2d.handleLoadedTexture(!0),n.spriteFrame},n},cc._RF.pop()},{}],CreativeCanvas:[function(e,n,t){"use strict";cc._RF.push(n,"e7a806R1yBHDIRZPIq8JNfk","CreativeCanvas"),n.exports=function(e){var n=Object();return n.spriteFrame=new cc.SpriteFrame,n.texture2d=null,n.canvas=document.createElement("canvas"),n.canvas.id="canvas_"+e,n.finalData=null,n.points_XYRGBR=[],n.current_index=0,n.records=[],n.time_line=0,n.prex=0,n.prey=0,n.re=!1,n.rex=0,n.rey=0,n.in_drag=!1,n.ctx=null,n.create_k=function(){n.records=n.records.splice(0,n.time_line+1),n.records.push(JSON.stringify(window.creativeCanvas.points_XYRGBR)),n.time_line++,this.flush_bg()},n.undo=function(){n.time_line--,n.time_line<0&&(n.time_line=0),n.do(),this.flush_bg()},n.redo=function(){n.time_line++,n.time_line>n.records.length-1&&(n.time_line=n.records.length-1),n.do(),this.flush_bg()},n.do=function(){window.creativeCanvas.points_XYRGBR=JSON.parse(n.records[n.time_line]),n.finish()},n.ini=function(e,t){return n.canvas.width=parseInt(e),n.canvas.height=parseInt(t),n.ctx=n.canvas.getContext("2d"),n.ctx.clearRect(0,0,n.canvas.width,n.canvas.height),n.source=n.ctx.getImageData(0,0,n.canvas.width,n.canvas.height),n.texture2d=new cc.Texture2D,n.spriteFrame.setTexture(n.texture2d),n.texture2d.initWithElement(n.canvas),n.texture2d.handleLoadedTexture(!0),n.records=[JSON.stringify([])],n.points_XYRGBR=[],n.time_line=0,n.finish(),n.spriteFrame},n.ini_image=function(e,t,o){return ctx=n.canvas.getContext("2d"),n.canvas.width=parseInt(t),n.canvas.height=parseInt(o),ctx.drawImage(e,0,0,n.canvas.width,n.canvas.height),n.source=ctx.getImageData(0,0,n.canvas.width,n.canvas.height),n.texture2d=new cc.Texture2D,n.spriteFrame.setTexture(n.texture2d),n.texture2d.initWithElement(n.canvas),n.texture2d.handleLoadedTexture(!0),n.create_k(),this.flush_bg(),n.spriteFrame},n.flush=function(){var e=n.canvas.getContext("2d");n.source=e.getImageData(0,0,n.canvas.width,n.canvas.height)},n.flush_bg=function(){},n.kill_preview=function(){window.pendingNode.active=!1,window.previewNode.opacity=255},n.get_color=function(e,t){if(null==n.source)return new[0,0,0,0];var o=0;return o=parseInt((1-t)*n.canvas.height),o=parseInt(o*n.canvas.width),o=parseInt(o+e*n.canvas.width),o=parseInt(4*o),[n.source.data[o+0],n.source.data[o+1],n.source.data[o+2],n.source.data[o+3]]},n.set_big_point=function(e,t,o,i,r,a,c){n.ctx.fillStyle="rgba("+o+","+i+","+r+","+a+")",n.ctx.fillRect(e-c,t-c,2*c+1,2*c+1)},n.set_line=function(e,t,o,i,r,a,c,d,s){for(var w=Math.abs(o-e),l=Math.abs(i-t),u=e<o?1:-1,h=t<i?1:-1,g=w-l;n.set_big_point(e,t,r,a,c,d,s),e!=o||t!=i;){var p=2*g;p>-l&&(g-=l,e+=u),p<w&&(g+=w,t+=h)}},n.clear_points=function(){n.points_XYRGBR=[]},n.add_point=function(){5==window.minecraft.index?n.points_XYRGBR.push([n.rex,n.rey,0,233,1]):6==window.minecraft.index?n.points_XYRGBR.push([n.rex,n.rey,1,233,0]):n.points_XYRGBR.push([n.rex,n.rey,window.pickCanvas.currentColor[0],window.pickCanvas.currentColor[1],window.pickCanvas.currentColor[2]]),n.current_index=n.points_XYRGBR.length-1},n.relocate_current_point=function(){n.current_index>-1&&n.current_index<n.points_XYRGBR.length&&(n.points_XYRGBR[n.current_index][0]=n.rex,n.points_XYRGBR[n.current_index][1]=n.rey)},n.refresh_current_point_index=function(e){n.current_index=-1;var t=parseInt(50/(window.drag_target.scaleX+1e-6));for(var o in window.isPen&&(t/=2),n.points_XYRGBR){var i=(n.points_XYRGBR[o][0]-n.rex)*n.canvas.width,r=(n.points_XYRGBR[o][1]-n.rey)*n.canvas.height;i*i+r*r<t*t&&n.if_point_in_color(o)==window.in_color&&(n.current_index=o)}n.current_index>-1?document.body.style.cursor="move":document.body.style.cursor="auto"},n.if_point_in_color=function(e){var t=n.points_XYRGBR[e],o=t[2],i=t[3],r=t[4];return(1!=o||233!=i||0!=r)&&(0!=o||233!=i||1!=r)},n.finish=function(){if(null!=n.ctx){n.ctx.clearRect(0,0,n.canvas.width,n.canvas.height);for(var e=0;e<n.points_XYRGBR.length;e++){var t=n.points_XYRGBR[e],o=parseInt(t[0]*n.canvas.width),i=parseInt((1-t[1])*n.canvas.height),r=t[2],a=t[3],c=t[4];if(1==r&&233==a&&0==c){if(window.in_color)continue;n.ctx.strokeStyle="#000000",n.ctx.lineWidth=4.5,n.ctx.beginPath(),n.ctx.moveTo(o-12,i-12),n.ctx.lineTo(o+12,i+12),n.ctx.closePath(),n.ctx.stroke(),n.ctx.beginPath(),n.ctx.moveTo(o+12,i-12),n.ctx.lineTo(o-12,i+12),n.ctx.closePath(),n.ctx.stroke(),n.ctx.strokeStyle="#ffffff",n.ctx.lineWidth=1.5,n.ctx.beginPath(),n.ctx.moveTo(o-10,i-10),n.ctx.lineTo(o+10,i+10),n.ctx.closePath(),n.ctx.stroke(),n.ctx.beginPath(),n.ctx.moveTo(o+10,i-10),n.ctx.lineTo(o-10,i+10),n.ctx.closePath(),n.ctx.stroke()}else if(0==r&&233==a&&1==c){if(window.in_color)continue;n.ctx.strokeStyle="#000000",n.ctx.lineWidth=4.5,n.ctx.beginPath(),n.ctx.arc(o,i,10,0,2*Math.PI),n.ctx.closePath(),n.ctx.stroke(),n.ctx.strokeStyle="#ffffff",n.ctx.lineWidth=1.5,n.ctx.beginPath(),n.ctx.arc(o,i,10,0,2*Math.PI),n.ctx.closePath(),n.ctx.stroke()}else{if(!window.in_color)continue;n.ctx.strokeStyle="rgba("+(255-r).toString()+","+(255-a).toString()+","+(255-c).toString()+",1.0)",n.ctx.fillStyle="rgba("+r.toString()+","+a.toString()+","+c.toString()+",1.0)",n.ctx.lineWidth=1.5,n.ctx.beginPath(),n.ctx.moveTo(o-7,i-7),n.ctx.lineTo(o-7,i+7),n.ctx.lineTo(o+7,i+7),n.ctx.lineTo(o+7,i-7),n.ctx.closePath(),n.ctx.fill(),n.ctx.stroke()}}}},n}(),cc._RF.pop()},{}],FileInputs:[function(e,n,t){"use strict";cc._RF.push(n,"905c5qeemxJLpQ8dr1wfPNY","FileInputs"),n.exports=function(){var e=Object();return e.html_obj=document.createElement("input"),e.html_obj.id="FileSelector",e.html_obj.type="file",e.html_obj.accept="image/*",e.html_obj.style.height="0px",e.html_obj.style.display="block",e.html_obj.style.overflow="hidden",document.body.insertBefore(e.html_obj,document.body.firstChild),e.actural_callback=null,e.url="",e.fake_callback=function(n){void 0!==window.URL?e.url=window.URL.createObjectURL(n.target.files[0]):e.url=window.webkitURL.createObjectURL(n.target.files[0]),e.actural_callback(e.url)},e.html_obj.addEventListener("change",e.fake_callback,!1),e.activate=function(n){e.actural_callback=n,e.html_obj.click()},e}(),cc._RF.pop()},{}],ImageCanvas:[function(e,n,t){"use strict";cc._RF.push(n,"8fc68P9vqxERoq8iKAIOEEI","ImageCanvas"),n.exports=function(e){var n=Object();return n.spriteFrame=new cc.SpriteFrame,n.texture2d=null,n.source=null,n.canvas=document.createElement("canvas"),n.canvas.id="canvas_"+e,n.image=null,n.load_image=function(e,t,o){n.image=e,n.canvas.width=parseInt(t),n.canvas.height=parseInt(o);var i=n.canvas.getContext("2d");return i.drawImage(e,0,0,n.canvas.width,n.canvas.height),n.dataurl=n.canvas.toDataURL("image/png"),n.source=i.getImageData(0,0,n.canvas.width,n.canvas.height),n.texture2d=new cc.Texture2D,n.spriteFrame.setTexture(n.texture2d),n.texture2d.initWithElement(n.canvas),n.texture2d.handleLoadedTexture(!0),n.spriteFrame},n.load_canvas=function(e){n.canvas.width=e.width,n.canvas.height=e.height;var t=n.canvas.getContext("2d");return t.drawImage(e,0,0,n.canvas.width,n.canvas.height),n.source=t.getImageData(0,0,n.canvas.width,n.canvas.height),n.texture2d=new cc.Texture2D,n.spriteFrame.setTexture(n.texture2d),n.texture2d.initWithElement(n.canvas),n.texture2d.handleLoadedTexture(!0),n.spriteFrame},n.clear=function(){n.canvas.width=100,n.canvas.height=100;var e=n.canvas.getContext("2d");return e.clearRect(0,0,100,100),n.source=e.getImageData(0,0,n.canvas.width,n.canvas.height),n.texture2d=new cc.Texture2D,n.spriteFrame.setTexture(n.texture2d),n.texture2d.initWithElement(n.canvas),n.texture2d.handleLoadedTexture(!0),n.spriteFrame},n.dark=function(){n.canvas.width=100,n.canvas.height=100;var e=n.canvas.getContext("2d");return e.fillStyle="rgba(0,0,0,0.5)",e.fillRect(0,0,100,100),n.source=e.getImageData(0,0,n.canvas.width,n.canvas.height),n.texture2d=new cc.Texture2D,n.spriteFrame.setTexture(n.texture2d),n.texture2d.initWithElement(n.canvas),n.texture2d.handleLoadedTexture(!0),n.spriteFrame},n.load_alpha=function(e,t,o){n.image=e,n.canvas.width=parseInt(t),n.canvas.height=parseInt(o);var i=n.canvas.getContext("2d");i.drawImage(e,0,0,n.canvas.width,n.canvas.height),n.dataurl=n.canvas.toDataURL("image/png"),n.source=i.getImageData(0,0,n.canvas.width,n.canvas.height);for(var r=0;r<o;r++)for(var a=0;a<t;a++){var c=4*(a+r*t),d=c+1,s=c+2,w=c+3,l=n.source.data[c],u=n.source.data[d],h=n.source.data[s],g=n.source.data[w],p=Math.max((1*l+1*u+1*h)/3,255-g);n.source.data[c]=0,n.source.data[d]=0,n.source.data[s]=0,n.source.data[w]=255-p}return i.putImageData(n.source,0,0),n.texture2d=new cc.Texture2D,n.spriteFrame.setTexture(n.texture2d),n.texture2d.initWithElement(n.canvas),n.texture2d.handleLoadedTexture(!0),n.spriteFrame},n.get_color=function(e,t){if(null==n.source)return new cc.color(255,255,255);var o=0;return o=parseInt((1-t)*n.canvas.height),o=parseInt(o*n.canvas.width),o=parseInt(o+e*n.canvas.width),o=parseInt(4*o),new cc.color(n.source.data[o],n.source.data[o+1],n.source.data[o+2])},n},cc._RF.pop()},{}],ImageLoader:[function(e,n,t){"use strict";cc._RF.push(n,"28e74s7diBLh5Ox7WgbLlpC","ImageLoader"),n.exports=function(e){var n=Object(),t="tempDiv"+e,o="imgHead"+e,i=document.createElement("div");return i.style.position="absolute",i.id=t,i.innerHTML="<img id="+o+">",i.style.display="none",i.style.visibility="hidden",document.body.appendChild(i),n.image=document.getElementById(o),n.on_process=null,n.on_error=null,n.on_finish=null,n.load_url=function(e,t){n.image.onload=function(){t(document.getElementById(o))},n.image.onerror=function(){null!=n.on_error&&n.on_error()};var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onprogress=function(t){t.lengthComputable&&(console.log(e+" - "+t.loaded+" / "+t.total),null!=n.on_process&&n.on_process(t.loaded/t.total))},i.onreadystatechange=function(){if(4==i.readyState&&200==i.status)try{null!=n.on_finish&&(console.log(e+" - on_finish called"),n.on_finish());var t=i.getAllResponseHeaders().match(/^Content-Type\:\s*(.*?)$/im)[1]||"image/png",o=new Blob([this.response],{type:t});console.log(e+" - finished"),n.image.src=window.URL.createObjectURL(o),console.log(e+" - blobed")}catch(e){console.log(e),null!=n.on_error&&n.on_error(),window.controller.net_unlock("error")}else 4==i.readyState&&null!=n.on_error&&n.on_error()};try{i.send(),console.log(e+"->xmlHTTP.send();"),window.controller.net_unlock("finished")}catch(e){console.log(e),null!=n.on_error&&n.on_error(),window.controller.net_unlock("error")}},n.load_result=function(e,t){console.log(e),n.name=e,n.image.onload=function(){t(document.getElementById(o))},n.image.onerror=function(){null!=n.on_error&&n.on_error()};var i=new XMLHttpRequest;i.open("POST",window.server_url.split("/file")[0]+"/run/download_result",!0),i.setRequestHeader("Content-Type","application/json;"),i.onreadystatechange=function(){if(4==i.readyState&&200==i.status){var e=JSON.parse(i.responseText).data[0];n.image.src=e}else 4==i.readyState&&null!=n.on_error&&n.on_error()},i.send(JSON.stringify({data:[e,null]}))},n},cc._RF.pop()},{}],PickCanvas:[function(e,n,t){"use strict";cc._RF.push(n,"076a0aT+NZGT7xs77Y6v1Zy","PickCanvas"),n.exports=function(e){var n=Object();return n.spriteFrame=new cc.SpriteFrame,n.texture2d=null,n.source=null,n.canvas=document.createElement("canvas"),n.canvas.id="canvas_"+e,n.canvas.width=300,n.canvas.height=1078,n.currentColor=new Array(255,230,200),n.floatingColor=new Array(0,255,0),n.bigall=[47079079,112128144,119136153,105105105,169169169,211211211,220220220,176196222,139,25025112,72061139,75000130,205,123104238,65105225,100149237,139187,70130180,30144255,191255,135206250,135206235,173216230,255255,95158160,32178170,102205170,206209,72209204,64224208,176224230,175238238,107142035,85107047,1e5,34139034,46139087,60179113,50205050,154205050,127255212,250154,255127,124252e3,127255e3,173255047,144238144,152251152,139000139,106090205,138043226,148000211,153050204,186085211,147112219,143188143,139e6,139069019,165042042,178034034,160082045,205092092,210105030,189183107,220020060,255020147,255105180,255000255,218112214,238130238,221160221,216191216,188143143,199021133,219112147,233150122,240128128,255160122,255182193,255192203,255069e3,255099071,255079080,250128114,25514e4,255165e3,244164096,230230250,184134011,205133063,218165032,210180140,222184135,255215e3,255228225,224255255,240230140,238232170,250250210,255250205,245245220,255248220,255255224,255218185,245222179,255222173,255228181,255228196,255235205,255239213,250235215,255240245,240221195,234182156,240221208,247206181,238187153,240208182,234169143,221169143,247217214,226199179,247195156,221169130,234208182,240186173,166149141,240221182,234195169,212128107,158139130,234182143,247208195,247182156,235178133,247195169,247208182,240195169,195116077,240208169,234195182,240169130,69042029,247208169,247221195,240182143,236221202,249249249],n.record=[],n.ctx=n.canvas.getContext("2d"),n.ring=null,n.tring=null,n.ini=function(e){return n.ctx.drawImage(e,0,0,300,300),n.ring=n.ctx.getImageData(0,0,300,300),n.tring=n.ctx.getImageData(0,0,164,164),n.source=n.ctx.getImageData(0,0,n.canvas.width,n.canvas.height),n.texture2d=new cc.Texture2D,n.spriteFrame.setTexture(n.texture2d),n.texture2d.initWithElement(n.canvas),n.texture2d.handleLoadedTexture(!0),n.ctx=n.texture2d.getHtmlElementObj().getContext("2d"),n.finish(),n.spriteFrame},n.finish=function(e){if(null!=n.ring){var t=0;n.ctx.fillStyle="rgb(80, 80, 80)",n.ctx.fillRect(0,0,n.canvas.width,n.canvas.height),n.ctx.putImageData(n.ring,0,t),t+=300;for(var o=1*Math.min(Math.min(n.currentColor[0],n.currentColor[1]),n.currentColor[2]),i=1*Math.max(Math.max(n.currentColor[0],n.currentColor[1]),n.currentColor[2])-o+1e-4,r=(1*n.currentColor[0]-o+1e-4)/i*255,a=(1*n.currentColor[1]-o+1e-4)/i*255,c=(1*n.currentColor[2]-o+1e-4)/i*255,d=0;d<164;d++)for(var s=0;s<164;s++){var w=4*(164*d+163-s),l=w+1,u=w+2,h=w+3,g=1*d/164*255,p=1*s/164*(255-g)/255;n.tring.data[w]=g+r*p,n.tring.data[l]=g+a*p,n.tring.data[u]=g+c*p,n.tring.data[h]=255}n.ctx.putImageData(n.tring,68,68),t+=0,n.ctx.fillStyle="rgb("+n.currentColor[0]+","+n.currentColor[1]+", "+n.currentColor[2]+")",n.ctx.fillRect(8,t+5,142,30),n.ctx.fillStyle="rgb("+n.floatingColor[0]+","+n.floatingColor[1]+", "+n.floatingColor[2]+")",n.ctx.fillRect(150,t+5,142,30),t+=40;for(var _=0;_<n.record.length;_++){var v=parseInt(_%8),f=parseInt(_/8),m=n.record[n.record.length-1-_],x=m%1e3,C=(m=parseInt(m/1e3))%1e3,k=(m=parseInt(m/1e3))%1e3;n.ctx.beginPath(),n.ctx.fillStyle="rgb("+k+","+C+", "+x+")",n.ctx.arc(parseInt(38*v+19),parseInt(t+38*f+19),16,0,2*Math.PI,!0),n.ctx.closePath(),n.ctx.fill()}n.source=n.ctx.getImageData(0,0,n.canvas.width,n.canvas.height)}},n.finish_float=function(e){if(null!=n.ring){n.ctx.fillStyle="rgb("+n.floatingColor[0]+","+n.floatingColor[1]+", "+n.floatingColor[2]+")",n.ctx.fillRect(150,305,142,30)}},n.get_color=function(e,t){if(null==n.source)return new cc.color(255,255,255);var o=0;return o=parseInt((1-t)*n.canvas.height),o=parseInt(o*n.canvas.width),o=parseInt(o+e*n.canvas.width),o=parseInt(4*o),new cc.color(n.source.data[o],n.source.data[o+1],n.source.data[o+2])},n},cc._RF.pop()},{}],SizeRegulator:[function(e,n,t){"use strict";cc._RF.push(n,"45ffcOaBs5DwLbHaSSfzUG/","SizeRegulator"),n.exports.minRegulate=function(e,n){var t=parseFloat(e[0]),o=parseFloat(e[1]);return o<t?(t*=n/o,o=n):(o*=n/t,t=n),[parseInt(t),parseInt(o)]},n.exports.maxRegulate=function(e,n){var t=parseFloat(e[0]),o=parseFloat(e[1]);return o>t?(t*=n/o,o=n):(o*=n/t,t=n),[parseInt(t),parseInt(o)]},cc._RF.pop()},{}],TripleCanvas:[function(e,n,t){"use strict";cc._RF.push(n,"7319cMXNsxIhLHpuS9egChN","TripleCanvas"),n.exports=function(e){var n=Object();return n.spriteFrame=new cc.SpriteFrame,n.texture2d=null,n.spriteFrame_p=new cc.SpriteFrame,n.texture2d_p=null,n.source=null,n.source_light=null,n.source_color=null,n.canvas=document.createElement("canvas"),n.canvas.id="canvas_"+e,n.canvas_light=document.createElement("canvas"),n.canvas_light.id="canvas_light"+e,n.canvas_sketch=document.createElement("canvas"),n.canvas_sketch.id="canvas_sketch"+e,n.canvas_color=document.createElement("canvas"),n.canvas_color.id="canvas_color"+e,n.canvas_preview=document.createElement("canvas"),n.canvas_preview.id="canvas_preview"+e,n.canvas_render=document.createElement("canvas"),n.canvas_render.id="canvas_render"+e,n.canvas_shade=document.createElement("canvas"),n.canvas_shade.id="canvas_shade"+e,n.load_image=function(e,t,o){var i=null,r=parseInt(t/3);n.canvas_preview.width=parseInt(t),n.canvas_preview.height=parseInt(o),n.canvas.width=parseInt(r),n.canvas.height=parseInt(o),n.canvas_sketch.width=parseInt(r),n.canvas_sketch.height=parseInt(o),n.canvas_light.width=parseInt(r),n.canvas_light.height=parseInt(o),n.canvas_color.width=parseInt(r),n.canvas_color.height=parseInt(o),n.canvas_render.width=parseInt(r),n.canvas_render.height=parseInt(o),n.canvas_shade.width=parseInt(r),n.canvas_shade.height=parseInt(o),(i=n.canvas_preview.getContext("2d")).drawImage(e,0,0,n.canvas_preview.width,n.canvas_preview.height),n.source_sketch=i.getImageData(0,0,n.canvas.width,n.canvas.height),n.texture2d_p=new cc.Texture2D,n.spriteFrame_p.setTexture(n.texture2d_p),n.texture2d_p.initWithElement(n.canvas_preview),n.texture2d_p.handleLoadedTexture(!0),(i=n.canvas_sketch.getContext("2d")).drawImage(n.canvas_preview,0,0,n.canvas.width,n.canvas.height,0,0,n.canvas.width,n.canvas.height),(i=n.canvas.getContext("2d")).drawImage(n.canvas_preview,r,0,n.canvas.width,n.canvas.height,0,0,n.canvas.width,n.canvas.height),n.texture2d=new cc.Texture2D,n.spriteFrame.setTexture(n.texture2d),n.texture2d.initWithElement(n.canvas),n.texture2d.handleLoadedTexture(!0),(i=n.canvas_render.getContext("2d")).drawImage(n.canvas_preview,2*r,0,n.canvas.width,n.canvas.height,0,0,n.canvas.width,n.canvas.height),i=n.canvas.getContext("2d"),n.source=i.getImageData(0,0,n.canvas.width,n.canvas.height),n.source_light=i.getImageData(0,0,n.canvas.width,n.canvas.height),n.source_color=i.getImageData(0,0,n.canvas.width,n.canvas.height);for(var a=0;a<o;a++)for(var c=0;c<r;c++){var d=4*(c+a*r),s=d+1,w=d+2,l=d+3,u=n.source.data[d],h=n.source.data[s],g=n.source.data[w],p=(n.source.data[l],n.source_sketch.data[d]),_=Math.max(u,h,g),v=Math.min(_,p);n.source_light.data[d]=v,n.source_light.data[s]=v,n.source_light.data[w]=v,n.source_light.data[l]=255,_<15&&(u=_,h=_,g=_),n.source_color.data[d]=parseInt((1*u+1e-4)/(1*_+1e-4)*255),n.source_color.data[s]=parseInt((1*h+1e-4)/(1*_+1e-4)*255),n.source_color.data[w]=parseInt((1*g+1e-4)/(1*_+1e-4)*255),n.source_color.data[l]=255}n.canvas_light.getContext("2d").putImageData(n.source_light,0,0),n.canvas_color.getContext("2d").putImageData(n.source_color,0,0),n.source=n.canvas_shade.getContext("2d").getImageData(0,0,n.canvas.width,n.canvas.height),n.source_from=n.canvas.getContext("2d").getImageData(0,0,n.canvas.width,n.canvas.height),n.source_to=n.canvas_render.getContext("2d").getImageData(0,0,n.canvas.width,n.canvas.height);for(var f=0;f<o;f++)for(var m=0;m<r;m++){var x=4*(m+f*r),C=x+1,k=x+2,I=x+3,y=n.source_from.data[x],N=n.source_from.data[C],b=n.source_from.data[k],S=(1*n.source_to.data[x]+1e-4)/(1*y+1e-4)*255,R=(1*n.source_to.data[C]+1e-4)/(1*N+1e-4)*255,F=(1*n.source_to.data[k]+1e-4)/(1*b+1e-4)*255;S>255&&(S=255),R>255&&(R=255),F>255&&(F=255),n.source.data[x]=parseInt(S),n.source.data[C]=parseInt(R),n.source.data[k]=parseInt(F),n.source.data[I]=255}n.canvas_shade.getContext("2d").putImageData(n.source,0,0)},n},cc._RF.pop()},{}],colorpicker:[function(e,n,t){"use strict";cc._RF.push(n,"292e9Clf/5EoYjj7Il6urD/","colorpicker"),Array.prototype.indexOf=function(e){for(var n=0;n<this.length;n++)if(this[n]==e)return n;return-1},Array.prototype.remove=function(e){var n=this.indexOf(e);n>-1&&this.splice(n,1)},cc.Class({extends:cc.Component,properties:{dropNode:{default:null,type:cc.Node}},onLoad:function(){window.color_picker_main=this},start:function(){var n=e("./ImageLoader"),t=e("./PickCanvas");window.pickCanvas=t("paletteImage"),window.right_color_picker=this.getComponent("cc.Sprite"),window.right_color_picker_node=this.node,window.color_picker_main=this,window.dropper_node=this.dropNode,this.last_record=0,n("paletteImage").load_url(window.server_url+"/res/Texture/ring.png",function(e){window.right_color_picker.spriteFrame=window.pickCanvas.ini(e),window.right_color_picker_node.on("mousemove",function(e){window.mousePosition=e.getLocation();var n=window.right_color_picker_node,t=(n.convertToWorldSpace(n.position),cc.winSize.width-300),o=window.mousePosition.x-t,i=window.mousePosition.y-362;if(o>0&&i>0&&o<n.width&&i<n.height){window.mouseRelativeX=o/n.width,window.mouseRelativeY=i/n.height;var r=window.pickCanvas.get_color(window.mouseRelativeX,window.mouseRelativeY);80==r.r&&80==r.g&&80==r.b&&(r.r=255,r.g=255,r.b=255),window.color_picker_main.float_do(r)}}),window.right_color_picker_node.on("mousedown",function(e){window.color_picker_main.pick_do()})}),window.dropper_node.on(cc.Node.EventType.MOUSE_DOWN,this.onDropDown,this),window.dropper_node.on(cc.Node.EventType.MOUSE_UP,this.onDropUp,this),window.dropper_node.on(cc.Node.EventType.TOUCH_MOVE,this.onDropMove,this),window.in_dropping=!1},float_do:function(e){window.pickCanvas.floatingColor[0]=e.r,window.pickCanvas.floatingColor[1]=e.g,window.pickCanvas.floatingColor[2]=e.b,window.dropper_node.color=e,window.pickCanvas.finish_float()},pick_do:function(){window.dropper_node.x=122,window.dropper_node.y=268,window.minecraft.go_pen(),window.color_picker_main.pick_float(),window.minecraft.set_cur_color(window.pickCanvas.currentColor)},onDropDown:function(e){window.in_dropping=!0},onDropUp:function(e){window.in_dropping=!1,window.color_picker_main.pick_do()},onDropMove:function(e){if(window.in_dropping){var n=e.touch.getDelta();window.dropper_node.x+=n.x,window.dropper_node.y+=n.y;var t=.5*window.leftNode.width+1*window.drag_target.x-.5*window.drag_target.width*window.drag_target.scaleX+300,o=.5*window.leftNode.height+1*window.drag_target.y-.5*window.drag_target.height*window.drag_target.scaleX,i=(window.mousePosition.x-t)/(window.drag_target.width*window.drag_target.scaleX),r=(window.mousePosition.y-o)/(window.drag_target.height*window.drag_target.scaleX);if(i>0&&r>0&&i<1&&r<1)if(window.creativeCanvas.re=!0,window.creativeCanvas.rex=i,window.creativeCanvas.rey=r,window.creativeCanvas.refresh_current_point_index(),window.creativeCanvas.current_index>-1){var a=window.creativeCanvas.points_XYRGBR[window.creativeCanvas.current_index],c=[a[2],a[3],a[4]];window.color_picker_main.float_do(new cc.color(c[0],c[1],c[2])),window.minecraft.set_cur_color([c[0],c[1],c[2]])}else{var d=window.previewImageCanvas;window.girdNode.active&&(d=window.girdImageCanvas);var s=d.get_color(i,r);window.color_picker_main.float_do(s),window.minecraft.set_cur_color([s.r,s.g,s.b])}else window.creativeCanvas.re=!1}},pick_float:function(){window.controller.on_pen(),window.pickCanvas.currentColor[0]=window.pickCanvas.floatingColor[0],window.pickCanvas.currentColor[1]=window.pickCanvas.floatingColor[1],window.pickCanvas.currentColor[2]=window.pickCanvas.floatingColor[2],window.pickCanvas.finish()},make_record:function(){var e=1e6*window.pickCanvas.currentColor[0]+1e3*window.pickCanvas.currentColor[1]+window.pickCanvas.currentColor[2];this.last_record!=e&&(window.pickCanvas.record.remove(e),window.pickCanvas.record.push(e),window.pickCanvas.finish(),this.last_record=e)}}),cc._RF.pop()},{"./ImageLoader":"ImageLoader","./PickCanvas":"PickCanvas"}],controller:[function(e,n,t){"use strict";cc._RF.push(n,"a55dcSJ4f1CEaD9OSsdYeLl","controller"),cc.Class({extends:cc.Component,properties:{sketchNode:{default:null,type:cc.Node},alphaSketchNode:{default:null,type:cc.Node},hintNode:{default:null,type:cc.Node},bghintNode:{default:null,type:cc.Node},girdNode:{default:null,type:cc.Node},previewNode:{default:null,type:cc.Node},labelNode:{default:null,type:cc.Node},pendingNode:{default:null,type:cc.Node},fileBtnNode:{default:null,type:cc.Node},aiBtnNode:{default:null,type:cc.Node},magicBtnNode:{default:null,type:cc.Node},leftNode:{default:null,type:cc.Node},confirmNode:{default:null,type:cc.Node},logoNode:{default:null,type:cc.Node},cpNode:{default:null,type:cc.Node},lightNode:{default:null,type:cc.Node},processingNode:{default:null,type:cc.Node},V4_toggle:{default:null,type:cc.Toggle}},show_light:function(){window.controller.lightNode.y=181,window.in_color=!1,window.bghintNode.active=!0,window.creativeCanvas.finish(),window.minecraft.shift(),window.girdNode.active=!1,0==window.hasRender&&window.faceSeletor.flush_preview_light(),console.log("show_light")},hide_light:function(){window.controller.lightNode.y=4096,window.in_color=!0,window.bghintNode.active=!1,window.creativeCanvas.finish(),window.minecraft.shift(),window.girdNode.active=!1,console.log("hide_light")},to_gird:function(){this.hide_light(),window.girdNode.active=!0,console.log("to_gird")},on_pen:function(){window.isPen=!0,window.in_move=!1,window.eraser_masker.active=!1,console.log("on_pen")},on_eraser:function(){window.isPen=!1,window.in_move=!1,window.minecraft.set_index(-233),window.eraser_masker.active=!0,console.log("on_eraser")},on_upload_hints:function(){if(0!=window.hasSketch){var e=prompt("Points?");null!=e&&(window.creativeCanvas.points_XYRGBR=JSON.parse(e),window.creativeCanvas.finish(),window.creativeCanvas.create_k())}},on_download_hints:function(){if(0!=window.hasSketch){var e=window.open("about:blank").document;e.body.style.backgroundColor="#000000",e.writeln(JSON.stringify(window.creativeCanvas.points_XYRGBR))}},on_logo:function(){var e="https://style2paints.github.io/";"zh"==navigator.language.substring(0,2)&&(e="https://style2paints.github.io/README_zh"),"ja"==navigator.language.substring(0,2)&&(e="https://style2paints.github.io/README_ja"),window.open(e)},on_logo_en:function(){window.open("https://style2paints.github.io/")},on_logo_zh:function(){window.open("https://style2paints.github.io/README_zh")},on_logo_ja:function(){window.open("https://style2paints.github.io/README_ja")},on_twitter:function(){window.open("https://twitter.com/hashtag/style2paints?f=tweets&vertical=default")},on_github:function(){window.open("https://github.com/lllyasviel/style2paints")},on_file:function(){window.uploading||window.fileSelector.activate(window.controller.load_sketch)},on_result:function(){var e="",n=[window.current_room+"/YUV."+window.current_step,window.current_room+"/composition."+window.current_step,window.current_room+"/gird."+window.current_step,window.current_room+"/DEL."+window.current_step,window.current_room+"/HSV."+window.current_step],t=[],o=!0,i=!1,r=void 0;try{for(var a,c=n[Symbol.iterator]();!(o=(a=c.next()).done);o=!0){var d=a.value,s=fetch(window.server_url.split("/file")[0]+"/run/download_result",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:[d,null]})}).then(function(e){return e.json()}).then(function(e){return e.data[0]});t.push(s)}}catch(e){i=!0,r=e}finally{try{!o&&c.return&&c.return()}finally{if(i)throw r}}Promise.all(t).then(function(n){e+="<div><img src="+window.tripleCanvas.canvas.toDataURL('"image/png')+' width="512"></div>',e+="<div><img src="+n[0]+' width="512"></div>',e+="<div><img src="+window.tripleCanvas.canvas_render.toDataURL('"image/png')+' width="512"></div>',e+="<div><img src="+window.tripleCanvas.canvas_color.toDataURL('"image/png')+' width="512"></div>',e+="<div><img src="+window.tripleCanvas.canvas_light.toDataURL('"image/png')+' width="512"></div>',e+="<div><img src="+window.tripleCanvas.canvas_shade.toDataURL('"image/png')+' width="512"></div>',e+="<div><img src="+n[1]+' width="512"></div>',e+="<div><img src="+n[2]+' width="512"></div>',e+="<div><img src="+n[3]+' width="512"></div>',e+="<div><img src="+n[4]+' width="512"></div>',e+="<div><img src="+window.tripleCanvas.canvas_sketch.toDataURL('"image/png')+' width="512"></div>',e+="<div>"+JSON.stringify(window.creativeCanvas.points_XYRGBR)+"</div>",window.confirmNode.active=!1,window.open("about:blank").document.writeln('<html><head></head><body style="background-color:#C8C8C8">'+e+"</body></html>")})},on_result_cancel:function(){window.confirmNode.active=!1},on_magic:function(){window.faceSeletor.flush_preview()},on_ai:function(){if(!window.uploading&&0!=window.hasSketch){window.controller.net_lock("uploading",0);var e=new XMLHttpRequest;e.open("POST",window.server_url.split("/file")[0]+"/run/request_result",!0),e.setRequestHeader("Content-Type","application/json;"),e.upload.onprogress=function(e){if(e.lengthComputable){var n=e.loaded/e.total;n>.8?window.controller.net_lock("painting",0):window.controller.net_lock("uploading",n)}},e.onreadystatechange=function(){if(4==e.readyState&&200==e.status){window.controller.net_lock("downloading",0);var n=JSON.parse(e.responseText).data[0].split("_");window.current_room=n[0],window.current_step=n[1],console.log("get room id "+window.current_room),console.log("get step id "+window.current_step),window.resultImageLoader.on_process=function(e){window.controller.net_lock("downloading",e)},window.resultImageLoader.on_error=function(e){window.controller.net_unlock("error")},window.resultImageLoader.on_finish=function(e){window.controller.net_unlock("finished")},window.resultImageLoader.load_result(window.current_room+"/preview."+window.current_step,function(e){window.tripleCanvas.load_image(e,e.width,e.height),window.confirmNode.active=!0,window.cpNode.width=cc.winSize.width-100,window.cpNode.height=cc.winSize.height-300,window.cpNodeSprite.spriteFrame=window.tripleCanvas.spriteFrame_p;var n=1*window.cpNode.width/(1*window.tripleCanvas.canvas_preview.width),t=1*window.cpNode.height/(1*window.tripleCanvas.canvas_preview.height),o=Math.min(n,t);window.cpNode.width=parseInt(1*window.tripleCanvas.canvas_preview.width*o),window.cpNode.height=parseInt(1*window.tripleCanvas.canvas_preview.height*o),window.previewSprite.spriteFrame=window.previewImageCanvas.load_canvas(window.tripleCanvas.canvas),window.bghintSprite.spriteFrame=window.renderImageCanvas.load_canvas(window.tripleCanvas.canvas_render),window.hasRender=!0,window.controller.net_unlock("finished"),window.girdImageLoader.on_error=null,window.girdImageLoader.on_process=null,window.girdImageLoader.on_finish=null,window.girdImageLoader.load_result(window.current_room+"/gird."+window.current_step,function(e){window.girdSprite.spriteFrame=window.girdImageCanvas.load_image(e,e.width,e.height)})})}else 4==e.readyState&&window.controller.net_unlock("error")},e.send(JSON.stringify({data:[JSON.stringify({room:window.current_room,points:JSON.stringify(window.creativeCanvas.points_XYRGBR),face:window.faceID<0?window.faceImageCanvas.canvas.toDataURL("image/png"):null,faceID:window.faceID+65535,need_render:1,skipper:null,inv4:window.V4_toggle.isChecked?1:0,r:window.lighter.light_R_slider.progress,g:window.lighter.light_G_slider.progress,b:window.lighter.light_B_slider.progress,h:window.lighter.light_H_slider.progress,d:window.light_direction}),null]})),console.log("request sended")}},on_big_error:function(){var e="Network error. Please refresh this page.";"zh"==navigator.language.substring(0,2)&&(e="\u4e25\u91cd\u7f51\u7edc\u9519\u8bef\uff0c\u8bf7\u5237\u65b0\u3002"),"ja"==navigator.language.substring(0,2)&&(e="\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a8\u30e9\u30fc\u3001\u30da\u30fc\u30b8\u3092\u66f4\u65b0\u3057\u3066\u304f\u3060\u3055\u3044\u3002"),alert(e)},net_lock:function(e,n){console.log(e+" - net_lock -"+n),window.uploading=!0,window.fileBtnNode.active=!1,window.aiBtnNode.active=!1,window.magicBtnNode.active=!1,window.processingNode.active=!0,window.state_label.change(e,n)},net_unlock:function(e){try{console.log(e+" - net_unlock"),window.uploading=!1,window.fileBtnNode.active=!0,window.aiBtnNode.active=!0,window.magicBtnNode.active=!0,window.processingNode.active=!1,window.state_label.change(e,1)}catch(e){console.log(e)}},onLoad:function(){window.controller=this,window.uploading=!1,window.server_url=window.location.href.split("/file/")[0]+"/file",window.fileSelector=e("./FileInputs"),window.regulator=e("./SizeRegulator"),window.fileBtnNode=this.fileBtnNode,window.aiBtnNode=this.aiBtnNode,window.magicBtnNode=this.magicBtnNode,window.confirmNode=this.confirmNode,window.confirmNode.active=!1,window.sketchNode=this.sketchNode,window.sketchSprite=this.sketchNode.getComponent("cc.Sprite"),window.alphaSketchNode=this.alphaSketchNode,window.alphaSketchSprite=this.alphaSketchNode.getComponent("cc.Sprite"),window.cpNode=this.cpNode,window.cpNodeSprite=this.cpNode.getComponent("cc.Sprite"),window.hasSketch=!1,window.hasRender=!1,window.in_color=!0,window.hintNode=this.hintNode,window.hintSprite=this.hintNode.getComponent("cc.Sprite"),window.bghintNode=this.bghintNode,window.bghintSprite=this.bghintNode.getComponent("cc.Sprite"),window.bghintNode.active=!1,window.girdNode=this.girdNode,window.girdSprite=this.girdNode.getComponent("cc.Sprite"),window.girdNode.active=!1,window.previewNode=this.previewNode,window.previewSprite=this.previewNode.getComponent("cc.Sprite"),window.state_label=this.labelNode.getComponent("fake_bar"),window.pendingNode=this.pendingNode,window.pendingNode.active=!1,window.V4_toggle=this.V4_toggle;var n=e("./ImageLoader"),t=e("./ImageCanvas"),o=e("./BoxCanvas"),i=e("./TripleCanvas");window.sketchImageLoader=n("sketchImage"),window.sketchImageCanvas=t("sketchImage"),window.renderImageLoader=n("renderImage"),window.renderImageCanvas=t("renderImage"),window.girdImageLoader=n("girdImage"),window.girdImageCanvas=t("girdImage"),window.sketchBoxCanvas=o("sketchBox"),window.tripleCanvas=i("tripleCanvas"),window.hintImageLoader=n("hintImage"),window.resultImageLoader=n("resultImage"),window.previewImageLoader=n("previewImage"),window.previewImageCanvas=t("previewImage"),window.creativeCanvas=e("./CreativeCanvas"),window.boxLoader=n("boxLoader"),window.boxLoader.load_url(window.server_url+"/res/Texture/board.png",function(e){}),window.leftNode=this.leftNode,window.isPen=!0,window.in_move=!1,window.current_room="new",window.current_step="new",window.logoNode=this.logoNode,window.processingNode=this.processingNode,window.processingNode.active=!1},start:function(){setTimeout(this.on_pen,500),setTimeout(this.hide_light,500)},load_sketch:function(e){window.sketchImageLoader.load_url(e,function(e){if(!(e.width>3*e.height||e.height>3*e.width)){window.previewSprite.spriteFrame=window.previewImageCanvas.clear(),window.current_room="new",window.current_step="new";var n=window.regulator.minRegulate([e.width,e.height],2048);window.sketchSprite.spriteFrame=window.sketchBoxCanvas.ini(e.width,e.height),window.alphaSketchSprite.spriteFrame=window.sketchImageCanvas.load_alpha(e,e.width,e.height),window.hintSprite.spriteFrame=window.creativeCanvas.ini(n[0],n[1]),window.bghintSprite.spriteFrame=window.renderImageCanvas.clear(),window.girdSprite.spriteFrame=window.girdImageCanvas.clear(),window.sketchNode.width=n[0],window.sketchNode.height=n[1],window.sketchNode.scaleX=1*(cc.winSize.height-300)/window.sketchNode.height*1,window.sketchNode.scaleY=window.sketchNode.scaleX,window.sketchNode.x=0,window.sketchNode.y=.5*cc.winSize.height-window.sketchNode.scaleY*window.sketchNode.height*.5-100,window.hasSketch=!0,window.logoNode.active=!1,window.controller.uploadSketch()}})},load_hints:function(e){window.sketchImageLoader.load_url(e,function(e){window.previewSprite.spriteFrame=window.previewImageCanvas.clear(),window.hintSprite.spriteFrame=window.creativeCanvas.ini_image(e,e.width,e.height)})},uploadSketch:function(){if(!window.uploading&&null!=window.sketchImageCanvas.source){window.controller.net_lock("initializing",0),window.current_room="new",window.current_step="new",window.creativeCanvas.kill_preview();var e=new XMLHttpRequest;e.open("POST",window.server_url.split("/file")[0]+"/run/upload_sketch",!0),e.setRequestHeader("Content-Type","application/json;"),e.upload.onprogress=function(e){if(e.lengthComputable){var n=e.loaded/e.total;n>.8?window.controller.net_lock("preparing",0):window.controller.net_lock("initializing",n)}},e.onreadystatechange=function(){if(4==e.readyState&&200==e.status){var n=JSON.parse(e.responseText).data[0].split("_");window.current_room=n[0],window.current_step=n[1],console.log("get room id "+window.current_room),console.log("get step id "+window.current_step),window.controller.net_unlock("finished"),window.controller.hide_light(),window.creativeCanvas.flush_bg(),window.faceSeletor.flush_preview()}else 4==e.readyState&&(window.state_label.change("error",1),window.controller.on_big_error(),window.location.reload())},e.send(JSON.stringify({data:[JSON.stringify({room:window.current_room,sketch:window.sketchImageCanvas.dataurl}),null]})),console.log("sketch uploaded")}}}),cc._RF.pop()},{"./BoxCanvas":"BoxCanvas","./CreativeCanvas":"CreativeCanvas","./FileInputs":"FileInputs","./ImageCanvas":"ImageCanvas","./ImageLoader":"ImageLoader","./SizeRegulator":"SizeRegulator","./TripleCanvas":"TripleCanvas"}],dragbox:[function(e,n,t){"use strict";cc._RF.push(n,"6591e257m1DWrS+H2/IDVmm","dragbox"),cc.Class({extends:cc.Component,properties:{},onLoad:function(){window.drag_box=this},start:function(){window.mouse_l=!1,window.mouse_r=!1,window.mouse_m=!1,window.ctrl=!1,window.alt=!1,window.drag_box=this,this.node.on(cc.Node.EventType.MOUSE_DOWN,this.onMouseDown,this),this.node.on(cc.Node.EventType.MOUSE_UP,this.onMouseUp,this),this.node.on(cc.Node.EventType.MOUSE_WHEEL,this.onMouseWheel,this),this.node.on(cc.Node.EventType.TOUCH_MOVE,this.onTouchMove,this),this.node.on("mousemove",function(e){window.mousePosition=e.getLocation();var n=.5*window.leftNode.width+1*window.drag_target.x-.5*window.drag_target.width*window.drag_target.scaleX+300,t=.5*window.leftNode.height+1*window.drag_target.y-.5*window.drag_target.height*window.drag_target.scaleX,o=(window.mousePosition.x-n)/(window.drag_target.width*window.drag_target.scaleX),i=(window.mousePosition.y-t)/(window.drag_target.height*window.drag_target.scaleX);o>0&&i>0&&o<1&&i<1?(window.creativeCanvas.re=!0,window.creativeCanvas.rex=o,window.creativeCanvas.rey=i,window.creativeCanvas.in_drag||window.creativeCanvas.refresh_current_point_index()):window.creativeCanvas.re=!1,window.alt&&(window.mouse_l||window.mouse_r||window.mouse_m||window.in_color&&window.drag_box.do_picking())}),cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN,function(e){e.keyCode==cc.KEY.z&&window.creativeCanvas.undo()}),cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN,function(e){e.keyCode==cc.KEY.y&&window.creativeCanvas.redo()}),cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN,function(e){switch(e.keyCode){case cc.KEY.ctrl:window.ctrl=!0;break;case cc.KEY.alt:window.alt||(window.alt=!0,window.in_color&&(window.drag_box.begin_picking(),window.drag_box.do_picking()))}},this),cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP,function(e){switch(e.keyCode){case cc.KEY.ctrl:window.ctrl=!1;break;case cc.KEY.alt:window.alt=!1,window.in_color&&window.drag_box.end_picking()}},this)},onTouchMove:function(e){if(void 0!==window.drag_target)if(window.mouse_m||window.mouse_r||window.in_move){var n=e.touch.getDelta();window.drag_target.x+=n.x,window.drag_target.y+=n.y}else window.mouse_l&&(window.isPen?window.creativeCanvas.in_drag&&(window.creativeCanvas.relocate_current_point(),window.creativeCanvas.finish()):(window.creativeCanvas.refresh_current_point_index(),window.creativeCanvas.current_index>-1&&window.creativeCanvas.if_point_in_color(window.creativeCanvas.current_index)==window.in_color&&(window.creativeCanvas.points_XYRGBR.splice(window.creativeCanvas.current_index,1),window.creativeCanvas.finish())))},onMouseDown:function(e){var n=e.getButton();n===cc.Event.EventMouse.BUTTON_LEFT?(window.mouse_l=!0,window.creativeCanvas.re&&0==window.in_move&&(window.isPen?(window.creativeCanvas.current_index<0&&(window.creativeCanvas.add_point(),window.creativeCanvas.finish()),window.creativeCanvas.in_drag=!0):(window.creativeCanvas.refresh_current_point_index(),window.creativeCanvas.current_index>-1&&window.creativeCanvas.if_point_in_color(window.creativeCanvas.current_index)==window.in_color&&(window.creativeCanvas.points_XYRGBR.splice(window.creativeCanvas.current_index,1),window.creativeCanvas.finish())))):n===cc.Event.EventMouse.BUTTON_MIDDLE?window.mouse_m=!0:n===cc.Event.EventMouse.BUTTON_RIGHT&&(window.mouse_r=!0)},onMouseUp:function(e){var n=e.getButton();n===cc.Event.EventMouse.BUTTON_LEFT?(window.mouse_l=!1,window.creativeCanvas.in_drag=!1,window.creativeCanvas.create_k()):n===cc.Event.EventMouse.BUTTON_MIDDLE?window.mouse_m=!1:n===cc.Event.EventMouse.BUTTON_RIGHT&&(window.mouse_r=!1)},onMouseWheel:function(e){void 0!==window.drag_target&&(e.getScrollY()>0?window.drag_target.runAction(cc.scaleTo(.1,1.2*window.drag_target.scaleX)):window.drag_target.runAction(cc.scaleTo(.1,window.drag_target.scaleX/1.2)))},begin_picking:function(){void 0!==window.dropper_node&&window.creativeCanvas.flush()},do_picking:function(){if(void 0!==window.dropper_node){window.dropper_node.x=window.mousePosition.x-cc.winSize.width+150+30,window.dropper_node.y=window.mousePosition.y-cc.winSize.height/2-181+30;var e=.5*window.leftNode.width+1*window.drag_target.x-.5*window.drag_target.width*window.drag_target.scaleX+300,n=.5*window.leftNode.height+1*window.drag_target.y-.5*window.drag_target.height*window.drag_target.scaleX,t=(window.mousePosition.x-e)/(window.drag_target.width*window.drag_target.scaleX),o=(window.mousePosition.y-n)/(window.drag_target.height*window.drag_target.scaleX);if(t>0&&o>0&&t<1&&o<1)if(window.creativeCanvas.re=!0,window.creativeCanvas.rex=t,window.creativeCanvas.rey=o,window.creativeCanvas.refresh_current_point_index(),window.creativeCanvas.current_index>-1){var i=window.creativeCanvas.points_XYRGBR[window.creativeCanvas.current_index],r=[i[2],i[3],i[4]];window.color_picker_main.float_do(new cc.color(r[0],r[1],r[2])),window.minecraft.set_cur_color([r[0],r[1],r[2]]),window.pickCanvas.currentColor[0]=r[0],window.pickCanvas.currentColor[1]=r[1],window.pickCanvas.currentColor[2]=r[2]}else{var a=window.previewImageCanvas;window.girdNode.active&&(a=window.girdImageCanvas);var c=a.get_color(t,o);window.color_picker_main.float_do(c),window.minecraft.set_cur_color([c.r,c.g,c.b]),window.pickCanvas.currentColor[0]=c.r,window.pickCanvas.currentColor[1]=c.g,window.pickCanvas.currentColor[2]=c.b}}},end_picking:function(){void 0!==window.dropper_node&&(this.do_picking(),window.pickCanvas.floatingColor[0]=window.dropper_node.color.r,window.pickCanvas.floatingColor[1]=window.dropper_node.color.g,window.pickCanvas.floatingColor[2]=window.dropper_node.color.b,window.dropper_node.x=122,window.dropper_node.y=268,window.color_picker_main.pick_do())}}),cc._RF.pop()},{}],dragtarget:[function(e,n,t){"use strict";cc._RF.push(n,"16ac9dXjiBLKrkojVzbW1dk","dragtarget"),cc.Class({extends:cc.Component,properties:{},onLoad:function(){window.drag_target=this.node}}),cc._RF.pop()},{}],eraser_masker:[function(e,n,t){"use strict";cc._RF.push(n,"d389dAkX0JBZruQtEeVulcE","eraser_masker"),cc.Class({extends:cc.Component,properties:{},onLoad:function(){window.eraser_masker=this.node},update:function(e){this.node.x=window.mousePosition.x-cc.winSize.width/2,this.node.y=window.mousePosition.y-cc.winSize.height/2}}),cc._RF.pop()},{}],faceSelector:[function(e,n,t){"use strict";cc._RF.push(n,"8c11b3zCbJK37zCkjWNkHWp","faceSelector"),cc.Class({extends:cc.Component,properties:{bigFaceNode:{default:null,type:cc.Node},faceNodes:{default:[],type:cc.Node}},onLoad:function(){window.faceSeletor=this},start:function(){var n=this;window.faceID=-233,window.faceSeletor=this,window.bigFaceNode=this.bigFaceNode,window.bigFaceSprite=this.bigFaceNode.getComponent("cc.Sprite");for(var t=function(e){n.faceNodes[e].getComponent(cc.Sprite).spriteFrame=new cc.SpriteFrame,n.faceNodes[e].getComponent(cc.Sprite).spriteFrame.setTexture(cc.textureCache.addImage(window.server_url+"/res/face_128/"+(e+1)+".jpg")),n.faceNodes[e].on(cc.Node.EventType.MOUSE_UP,function(n){window.faceSeletor.on_face_selected(e)})},o=0;o<32;o++)t(o);var i=e("./ImageLoader"),r=e("./ImageCanvas");window.faceImageLoader=i("faceImage"),window.faceImageCanvas=r("faceImage"),this.on_face_selected(Math.floor(32*Math.random())),this.bigFaceNode.on("mousemove",function(e){window.mousePosition=e.getLocation();var n=150-.5*window.bigFaceNode.width,t=1290-.5*window.bigFaceNode.height,o=(1*window.mousePosition.x-n)/(1*window.bigFaceNode.width),i=(1*window.mousePosition.y-t)/(1*window.bigFaceNode.height);if(o>0&&i>0&&o<1&&i<1){var r=window.faceImageCanvas.get_color(o,i);window.color_picker_main.float_do(r)}}),this.bigFaceNode.on("mousedown",function(e){window.color_picker_main.pick_do()})},on_face_selected:function(e){window.faceID=e,window.faceImageLoader.load_url(window.server_url+"/res/face_512/"+(e+1)+".jpg",function(e){window.bigFaceSprite.spriteFrame=window.faceImageCanvas.load_image(e,240,240),window.bigFaceNode.width=240,window.bigFaceNode.height=240}),window.girdNode.active?window.controller.to_gird():window.controller.hide_light(),window.creativeCanvas.flush_bg(),this.flush_preview()},on_upload:function(){0!=window.hasSketch&&window.fileSelector.activate(window.faceSeletor.load_reference)},flush_preview:function(){window.in_color?this.flush_preview_color():this.flush_preview_light()},on_toggle_v4v2:function(){window.controller.hide_light(),window.faceSeletor.flush_preview()},flush_preview_color:function(){if(!window.uploading&&0!=window.hasSketch){window.controller.net_lock("uploading",0);var e=new XMLHttpRequest;e.open("POST",window.server_url.split("/file")[0]+"/run/request_result",!0),e.setRequestHeader("Content-Type","application/json;"),e.upload.onprogress=function(e){if(e.lengthComputable){var n=e.loaded/e.total;n>.8?window.controller.net_lock("painting",0):window.controller.net_lock("uploading",n)}},e.onreadystatechange=function(){if(4==e.readyState&&200==e.status){window.controller.net_lock("downloading",0);var n=JSON.parse(e.responseText).data[0].split("_");window.current_room=n[0],window.current_step=n[1],console.log("get room id "+window.current_room),console.log("get step id "+window.current_step),window.girdNode.active?(window.girdImageLoader.on_process=function(e){window.controller.net_lock("downloading",e)},window.girdImageLoader.on_error=function(e){window.controller.net_unlock("error")},window.girdImageLoader.on_finish=function(e){window.controller.net_unlock("finished")},window.girdImageLoader.load_result(window.current_room+"/gird."+window.current_step,function(e){window.girdSprite.spriteFrame=window.girdImageCanvas.load_image(e,e.width,e.height),window.bghintSprite.spriteFrame=window.renderImageCanvas.dark(),window.alphaSketchSprite.spriteFrame=window.sketchImageCanvas.clear(),window.hasRender=!1,window.controller.to_gird(),window.controller.net_unlock("finished"),window.resultImageLoader.on_error=null,window.resultImageLoader.on_process=null,window.resultImageLoader.on_finish=null,window.resultImageLoader.load_result(window.current_room+"/result."+window.current_step,function(e){window.previewSprite.spriteFrame=window.previewImageCanvas.load_image(e,e.width,e.height)})})):(window.resultImageLoader.on_process=function(e){window.controller.net_lock("downloading",e)},window.resultImageLoader.on_error=function(e){window.controller.net_unlock("error")},window.resultImageLoader.on_finish=function(e){window.controller.net_unlock("finished")},window.resultImageLoader.load_result(window.current_room+"/result."+window.current_step,function(e){window.previewSprite.spriteFrame=window.previewImageCanvas.load_image(e,e.width,e.height),window.bghintSprite.spriteFrame=window.renderImageCanvas.dark(),window.alphaSketchSprite.spriteFrame=window.sketchImageCanvas.clear(),window.hasRender=!1,window.controller.hide_light(),window.controller.net_unlock("finished"),window.girdImageLoader.on_error=null,window.girdImageLoader.on_process=null,window.girdImageLoader.on_finish=null,window.girdImageLoader.load_result(window.current_room+"/gird."+window.current_step+".jpg",function(e){window.girdSprite.spriteFrame=window.girdImageCanvas.load_image(e,e.width,e.height)})}))}else 4==e.readyState&&window.controller.net_unlock("error")},e.send(JSON.stringify({data:[JSON.stringify({room:window.current_room,points:JSON.stringify(window.creativeCanvas.points_XYRGBR),face:window.faceID<0?window.faceImageCanvas.canvas.toDataURL("image/png"):null,faceID:window.faceID+65535,need_render:0,skipper:null,inv4:window.V4_toggle.isChecked?1:0,r:window.lighter.light_R_slider.progress,g:window.lighter.light_G_slider.progress,b:window.lighter.light_B_slider.progress,h:window.lighter.light_H_slider.progress,d:window.light_direction}),null]})),console.log("request sended")}},flush_preview_light:function(){if(!window.uploading&&0!=window.hasSketch&&"new"!=window.current_step){window.controller.net_lock("uploading",0);var e=new XMLHttpRequest;e.open("POST",window.server_url.split("/file")[0]+"/run/request_result",!0),e.setRequestHeader("Content-Type","application/json;"),e.upload.onprogress=function(e){if(e.lengthComputable){var n=e.loaded/e.total;n>.8?window.controller.net_lock("painting",0):window.controller.net_lock("uploading",n)}},e.onreadystatechange=function(){if(4==e.readyState&&200==e.status){window.controller.net_lock("downloading",0);var n=JSON.parse(e.responseText).data[0].split("_");window.current_room=n[0],window.current_step=n[1],console.log("get room id "+window.current_room),console.log("get step id "+window.current_step),window.renderImageLoader.on_process=function(e){window.controller.net_lock("downloading",e)},window.renderImageLoader.on_error=function(e){window.controller.net_unlock("error")},window.renderImageLoader.on_finish=function(e){window.controller.net_unlock("finished")},window.renderImageLoader.load_result(window.current_room+"/result."+window.current_step,function(e){window.bghintSprite.spriteFrame=window.renderImageCanvas.load_image(e,e.width,e.height),window.alphaSketchSprite.spriteFrame=window.sketchImageCanvas.clear(),window.hasRender=!0,window.controller.show_light(),window.controller.net_unlock("finished")})}else 4==e.readyState&&window.controller.net_unlock("error")},e.send(JSON.stringify({data:[JSON.stringify({room:window.current_room,points:JSON.stringify(window.creativeCanvas.points_XYRGBR),need_render:2,skipper:window.current_step,inv4:window.V4_toggle.isChecked?1:0,r:window.lighter.light_R_slider.progress,g:window.lighter.light_G_slider.progress,b:window.lighter.light_B_slider.progress,h:window.lighter.light_H_slider.progress,d:window.light_direction}),null]})),console.log("request sended")}},load_reference:function(e){window.faceImageLoader.load_url(e,function(e){if(!(e.width>2.5*e.height||e.height>2.5*e.width)){var n=window.regulator.maxRegulate([e.width,e.height],240);window.bigFaceSprite.spriteFrame=window.faceImageCanvas.load_image(e,n[0],n[1]),window.bigFaceNode.width=n[0],window.bigFaceNode.height=n[1],window.faceID=-233,window.controller.hide_light(),window.faceSeletor.flush_preview()}})}}),cc._RF.pop()},{"./ImageCanvas":"ImageCanvas","./ImageLoader":"ImageLoader"}],fake_bar:[function(e,n,t){"use strict";cc._RF.push(n,"61dcdov4D1Nc6gCTDSTIWPe","fake_bar"),cc.Class({extends:cc.Component,properties:{lab:{default:null,type:cc.Label},lab2:{default:null,type:cc.Label},prof:{default:null,type:cc.Node},prob:{default:null,type:cc.Node}},onLoad:function(){window.fake_bar_pro=this,this.text="finished",this.progress=1},change:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.text=e,this.progress=n},update:function(e){this.progress+=.005*(1-this.progress),this.progress>1&&(this.progress=1),this.lab.string=this.text+" ("+parseInt(100*this.progress)+"%)",this.lab2.string=this.lab.string,this.prof.width=parseInt(this.prob.width*this.progress),this.prob.active=this.progress<1}}),cc._RF.pop()},{}],lighter:[function(e,n,t){"use strict";cc._RF.push(n,"90b3at5d8FPDJEjfZXvwb7o","lighter"),cc.Class({extends:cc.Component,properties:{light_R_slider:{default:null,type:cc.Slider},light_G_slider:{default:null,type:cc.Slider},light_B_slider:{default:null,type:cc.Slider},light_H_slider:{default:null,type:cc.Slider},light_TT_slider:{default:null,type:cc.Toggle},light_TF_slider:{default:null,type:cc.Toggle},light_FT_slider:{default:null,type:cc.Toggle},light_FF_slider:{default:null,type:cc.Toggle},bgs:{default:null,type:cc.Node}},onLoad:function(){window.lighter=this},start:function(){this.light_R_slider.progress=.99,this.light_G_slider.progress=.83,this.light_B_slider.progress=.66,this.light_H_slider.progress=100/600,window.lighter=this,window.light_direction=0,this.reflush()},light_direction_0:function(){window.light_direction=0},light_direction_1:function(){window.light_direction=1},light_direction_2:function(){window.light_direction=2},light_direction_3:function(){window.light_direction=3},reflush:function(){this.bgs.color=cc.color(parseInt(255*this.light_R_slider.progress),parseInt(255*this.light_G_slider.progress),parseInt(255*this.light_B_slider.progress),255)}}),cc._RF.pop()},{}],mc:[function(e,n,t){"use strict";cc._RF.push(n,"9f420tBdblH772q0XTCwvMY","mc"),cc.Class({extends:cc.Component,properties:{c0:{default:null,type:cc.Sprite},c1:{default:null,type:cc.Sprite},c2:{default:null,type:cc.Sprite},c3:{default:null,type:cc.Sprite},c4:{default:null,type:cc.Sprite},c5:{default:null,type:cc.Sprite},c6:{default:null,type:cc.Sprite},c7:{default:null,type:cc.Sprite},c8:{default:null,type:cc.Sprite},kuang:{default:null,type:cc.Sprite}},onLoad:function(){window.minecraft=this},start:function(){this.sps=[this.c0,this.c1,this.c2,this.c3,this.c4,this.c5,this.c6,this.c7,this.c8],window.minecraft=this,this.big9=[[255,255,255],[255,230,200],[137,148,170],[150,164,141],[229,202,209],[249,233,218],[0,233,1],[1,233,0],[154,81,255]],this.reload_all(),this.index=4,this.set_index(0),window.in_color=!0,this.shift(),setTimeout("window.pickCanvas.record=window.pickCanvas.bigall;window.pickCanvas.finish();",200)},set_0:function(){this.set_index(0)},set_1:function(){this.set_index(1)},set_2:function(){this.set_index(2)},set_3:function(){this.set_index(3)},set_4:function(){this.set_index(4)},set_5:function(){this.set_index(5)},set_6:function(){this.set_index(6)},set_7:function(){this.set_index(7)},set_8:function(){this.set_index(8)},refresh:function(){for(var e=0;e<9;e++)this.set_color(e,[0,0,0]);setTimeout("window.minecraft.reload_all();window.minecraft.set_index(window.minecraft.index);",100)},reload_all:function(){for(var e=0;e<9;e++)this.set_color(e,this.big9[e])},set_index:function(e){if(-233==e)return this.index=e,void(this.kuang.node.active=!1);this.kuang.node.active=!0,e<0&&(e=0),e>8&&(e=8),this.index=e,this.kuang.node.x=100*e-400,this.index>-1&&this.index<5&&(window.pickCanvas.floatingColor[0]=this.sps[this.index].node.color.r,window.pickCanvas.floatingColor[1]=this.sps[this.index].node.color.g,window.pickCanvas.floatingColor[2]=this.sps[this.index].node.color.b,window.color_picker_main.pick_float(),window.isPen=!0,window.in_move=!1,window.eraser_masker.active=!1),5==this.index&&(window.isPen=!0,window.in_move=!1,window.eraser_masker.active=!1),6==this.index&&(window.isPen=!0,window.in_move=!1,window.eraser_masker.active=!1),7==this.index&&(window.isPen=!0,window.in_move=!0,window.eraser_masker.active=!1),8==this.index&&(window.isPen=!1,window.in_move=!1,window.eraser_masker.active=!0)},set_color:function(e,n){e>-1&&e<5&&(this.sps[e].node.color=cc.color(n[0],n[1],n[2],255))},shift:function(){for(var e=0;e<5;e++)this.sps[e].node.active=window.in_color;for(var n=5;n<7;n++)this.sps[n].node.active=!window.in_color;7!=this.index&&8!=this.index&&(window.in_color&&this.index>4&&this.set_index(0),window.in_color||this.index<5&&this.set_index(5))},go_pen:function(){5!=this.index&&6!=this.index&&7!=this.index&&8!=this.index||(this.index=0,this.kuang.node.x=-400)},set_cur_color:function(e){this.index>-1&&this.index<5&&(this.sps[this.index].node.color=cc.color(e[0],e[1],e[2],255))}}),cc._RF.pop()},{}],selfrot:[function(e,n,t){"use strict";cc._RF.push(n,"985733m0s1I44Gbui8XNyvc","selfrot"),cc.Class({extends:cc.Component,properties:{},start:function(){},update:function(e){this.node.rotation+=30*e}}),cc._RF.pop()},{}],shift50:[function(e,n,t){"use strict";cc._RF.push(n,"e8cf1Q/isJAM4tJYI+kKutU","shift50"),cc.Class({extends:cc.Component,properties:{},onLoad:function(){window.shifter_50=this},up50:function(){this.node.x=50},down50:function(){this.node.x=-50}}),cc._RF.pop()},{}],shiftlr:[function(e,n,t){"use strict";cc._RF.push(n,"ff80e/rKS5NvaF8zKm4aA06","shiftlr"),cc.Class({extends:cc.Component,properties:{btn_show:{default:null,type:cc.Node},btn_hide:{default:null,type:cc.Node},btn_a:{default:null,type:cc.Node},btn_b:{default:null,type:cc.Node}},show:function(){this.btn_show.active=!1,this.btn_hide.active=!0,this.btn_a.active=!0,this.btn_b.active=!0},hide:function(){this.btn_show.active=!0,this.btn_hide.active=!1,this.btn_a.active=!1,this.btn_b.active=!1}}),cc._RF.pop()},{}]},{},["BoxCanvas","CreativeCanvas","FileInputs","ImageCanvas","ImageLoader","PickCanvas","SizeRegulator","TripleCanvas","colorpicker","controller","dragbox","dragtarget","eraser_masker","faceSelector","fake_bar","lighter","mc","selfrot","shift50","shiftlr"]);