diff --git a/be.js b/be.js new file mode 100644 index 0000000..ca6010b --- /dev/null +++ b/be.js @@ -0,0 +1,87 @@ + +/// Manages block types/* and block properties.*/ +// #disposable +(function(){ + + var propertyTypes = {}; + function typedef(O){ + propertyTypes[O.name]=function(options){ + var o = {},i;for(i in O)o[i]=O[i]; + o.$prop = document.createElement("div"); + o.$prop.className = "property "+O.name; + o.$ = function(q){ + return o.$prop.querySelector(q); + }; + o.init(options); + return o; + }; + } + typedef({ + name: "number", + init: function(options){ + var html = ""; + this.$input = this.$("input"); + }, + getValue: function(){ + return this.$input.value; + }, + setValue: function(value){ + this.$input.value = value; + } + }); + typedef({ + name: "text", + init: function(options){ + this.$prop.innerHTML = ""; + this.$input = this.$("input"); + }, + getValue: function(){ + return this.$input.value; + }, + setValue: function(value){ + this.$input.value = value; + } + }); + + BlockTypeEditor = function(blocktype, gui){ + var be=this; + be.m = this.m || gui.M(); + be.m.title("Block Type Editor").position("center left-ish? idk"); + be.m.onclose=function(){ + be.m=null; + return true; + }; + be.update = function(){ + if(!be.m)return false; + be.m.$c.innerHTML=""; + /*be.m.$c.style.maxHeight="80vh"; + be.m.$c.style.minHeight="200px"; + be.m.$c.style.minWidth="265px"; + be.m.$c.style.overflowY="auto"; + be.m.$c.style.overflowX="hidden";*/ + for(var i in blocktype.properties){ + //var $prop=document.createElement("div"); + + var p=blocktype.properties[i]; + if(p.type && propertyTypes[p.type]){ + var P = propertyTypes[p.type](p); + be.m.$c.appendChild(P.$prop); + }else{ + console.error(p.type, "not supported"); + } + } + }; + be.update(); + be.close = function(){ + be.m && be.m.close(); + be.m = null; + }; + }; + +})(); \ No newline at end of file diff --git a/content/art/README.md b/content/art/README.md old mode 100755 new mode 100644 diff --git a/content/art/dawn-gods.png b/content/art/dawn-gods.png old mode 100755 new mode 100644 diff --git a/content/art/mesa.png b/content/art/mesa.png new file mode 100644 index 0000000..0511fdc Binary files /dev/null and b/content/art/mesa.png differ diff --git a/content/art/mesa_1.png b/content/art/mesa_1.png new file mode 100644 index 0000000..c7ed374 Binary files /dev/null and b/content/art/mesa_1.png differ diff --git a/content/art/platformertiles-original-palette.png b/content/art/platformertiles-original-palette.png old mode 100755 new mode 100644 diff --git a/content/art/platformertiles.png b/content/art/platformertiles.png old mode 100755 new mode 100644 diff --git a/content/art/platshrooms.png b/content/art/platshrooms.png old mode 100755 new mode 100644 diff --git a/content/blocks/README.md b/content/blocks/README.md old mode 100755 new mode 100644 diff --git a/list-content.py b/list-content.py old mode 100755 new mode 100644 diff --git a/pe.js b/pe.js index c32cef4..b7f82f1 100644 --- a/pe.js +++ b/pe.js @@ -162,39 +162,6 @@ PixelEditor = function(gui, img, update, save){ pe.ctx.clearRect(0,0,pe.canvas.width,pe.canvas.height); pe.ctx.drawImage(pe.ocanvas,0,0,pe.canvas.width,pe.canvas.height); - function fill(x,y, r,g,b,a, wr,wg,wb,wa, life){ - if(x<0||y<0||x>=id.width||y>=id.height)return; - var i=(x%id.width+y*id.width)*4; - - if(wr===undefined){ - var wr=id.data[i+0],wg=id.data[i+1],wb=id.data[i+2],wa=id.data[i+3]; - console.log("fill within color",wr,wg,wb); - console.log("fill with color",r,g,b); - if(r==wr&&g==wg&&b==wb&&a==wa){ - console.log("Already that color."); - return false; - } - var life=650; - pe.undoable(); - } - - if(id.data[i+3]==wa - && id.data[i+0]==wr - && id.data[i+1]==wg - && id.data[i+2]==wb){ - id.data[i+0]=r; - id.data[i+1]=g; - id.data[i+2]=b; - id.data[i+3]=a; - }else return; - - if(--life){ - if(x0)fill(x-1,y, r,g,b,a, wr,wg,wb,wa, life); - if(y>0)fill(x,y-1, r,g,b,a, wr,wg,wb,wa, life); - } - } }else if(pe.tool==="Replace Color"){ var _x=pe.m.mouse.x,_y=pe.m.mouse.y; var id=pe.octx.getImageData(0,0,pe.canvas.width,pe.canvas.height); @@ -208,32 +175,68 @@ PixelEditor = function(gui, img, update, save){ pe.ctx.clearRect(0,0,pe.canvas.width,pe.canvas.height); pe.ctx.drawImage(pe.ocanvas,0,0,pe.canvas.width,pe.canvas.height); - function replaceColor(x,y, r,g,b,a){ - if(x<0||y<0||x>=id.width||y>=id.height)return; - var i=(x%id.width+y*id.width)*4; - var wr=id.data[i+0],wg=id.data[i+1],wb=id.data[i+2],wa=id.data[i+3]; - - console.log("replace all",[wr,wg,wb,wa],"with",[r,g,b,a]); - if(r==wr&&g==wg&&b==wb&&a==wa){ - console.log("same color"); - return; - } - pe.undoable(); - - for(var i=0;i=id.width||y>=id.height)return; + var i=(x%id.width+y*id.width)*4; + + if(wr===undefined){ + wr=id.data[i+0]; + wg=id.data[i+1]; + wb=id.data[i+2]; + wa=id.data[i+3]; + console.log("fill within color",wr,wg,wb," with color",r,g,b); + if(r==wr&&g==wg&&b==wb&&a==wa){ + console.log("Already that color."); + return false; } + life=650; + pe.undoable(); + } + + if(id.data[i+3]==wa + && id.data[i+0]==wr + && id.data[i+1]==wg + && id.data[i+2]==wb){ + id.data[i+0]=r; + id.data[i+1]=g; + id.data[i+2]=b; + id.data[i+3]=a; + }else return; + + if(--life){ + if(x0)fill(x-1,y, r,g,b,a, wr,wg,wb,wa, life); + if(y>0)fill(x,y-1, r,g,b,a, wr,wg,wb,wa, life); + } + } + function replaceColor(x,y, r,g,b,a){ + if(x<0||y<0||x>=id.width||y>=id.height)return; + var i=(x%id.width+y*id.width)*4; + var wr=id.data[i+0],wg=id.data[i+1],wb=id.data[i+2],wa=id.data[i+3]; + + console.log("replace all",[wr,wg,wb,wa],"with",[r,g,b,a]); + if(r==wr&&g==wg&&b==wb&&a==wa){ + console.log("same color"); + return; } + pe.undoable(); + for(var i=0;i