diff --git a/libs/bluepixle.js b/libs/bluepixle.js index f53b615..3a2bf5c 100644 --- a/libs/bluepixle.js +++ b/libs/bluepixle.js @@ -4,7 +4,7 @@ class shape { constructor(type,coordinates,dimentions,rotation,fColor,bColor,bStyle,extraObject) { - this.type = "string" == typeof type ? (["rect","elipse","image"].includes(type) ? type : "rect") : "rect"; + this.type = "string" == typeof type ? (["rect","elipse","image","text"].includes(type) ? type : "rect") : "rect"; this.coordinates = coordinates instanceof vector ? coordinates : new vector([0,0]); this.dimentions = dimentions instanceof vector ? dimentions : new vector([1,1]); this.rotation = rotation instanceof vector ? rotation : new vector([1,0]); @@ -30,6 +30,11 @@ class shape { ]),3,3); this.image = createImageBitmap(this.imageData); } + if ("text" == this.type) { + this.text = + "string" == typeof this.extraObject.text ? + this.extraObject.text : "No Text"; + } } @@ -65,6 +70,13 @@ class shape { ctx.imageSmoothingEnabled = false; ctx.drawImage(image,origin.d[0],origin.d[0],this.dimentions.d[0],this.dimentions.d[1]); }); + } else if ("text" == this.type) { + var oldFont = ctx.font+""; + if (this.extraObject.font) { + ctx.font = this.extraObject.font+""; + } + ctx.fillText(this.text, origin.d[0], origin.d[1], this.dimentions.d[0]); + ctx.font = oldFont+""; } // restore context defaults ctx.translate(origin.d[0],origin.d[1]);