some array fns
This commit is contained in:
parent
42db19d748
commit
829b6386da
|
@ -1184,6 +1184,9 @@ Object.defineProperty(Array.prototype, 'unique', {
|
|||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Array.prototype, 'unduped', {
|
||||
value: function() { return [... new Set(this)]; }
|
||||
});
|
||||
|
||||
Object.defineProperty(Array.prototype, 'findIndex', {
|
||||
value: function(fn) {
|
||||
|
@ -1216,6 +1219,15 @@ Object.defineProperty(Array.prototype, 'find', {
|
|||
return ret;
|
||||
}});
|
||||
|
||||
Object.defineProperty(Array.prototype, 'search', {
|
||||
value: function(val) {
|
||||
for (var i = 0; i < this.length; i++)
|
||||
if (this[i] === val) return i;
|
||||
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Array.prototype, 'last', {
|
||||
value: function() { return this[this.length-1]; },
|
||||
});
|
||||
|
|
|
@ -515,10 +515,19 @@ render.text = function(str, pos, size = 1, color = Color.white, wrap = -1, ancho
|
|||
return bb;
|
||||
};
|
||||
|
||||
render.image = function(tex, pos, rotation = 0, color = Color.white, dimensions = [tex.width, tex.height]) {
|
||||
//var scale = [dimensions.x/tex.width, dimensions.y/tex.height];
|
||||
//gui.img(tex,pos, scale, 0.0, false, [0.0,0.0], color);
|
||||
//return bbox.fromcwh([0,0], [tex.width,tex.height]);
|
||||
render.image = function(tex, pos, scale = 1, rotation = 0, color = Color.white, dimensions = [tex.width, tex.height]) {
|
||||
var t = os.make_transform();
|
||||
t.pos = pos;
|
||||
t.scale = [scale,scale];
|
||||
render.setpipeline(render.spriteshader.pipe);
|
||||
render.setunim4(0, render.spriteshader.vs.unimap.model.slot, t);
|
||||
render.shader_apply_material(render.spriteshader, {
|
||||
shade: color,
|
||||
diffuse: tex
|
||||
});
|
||||
var bind = render.sg_bind(render.spriteshader, shape.quad, {diffuse:tex});
|
||||
bind.inst = 1;
|
||||
render.spdraw(bind);
|
||||
}
|
||||
|
||||
render.fontcache = {};
|
||||
|
|
Loading…
Reference in a new issue