@pixi/text-html
Advanced tools
Comparing version 2.0.3 to 2.1.0
/*! | ||
* @pixi/text-html - v2.0.3 | ||
* Compiled Thu, 09 Jun 2022 15:13:58 UTC | ||
* @pixi/text-html - v2.1.0 | ||
* Compiled Fri, 05 Aug 2022 20:21:10 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/text-html is licensed under the MIT License. | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@pixi/sprite"),e=require("@pixi/settings"),i=require("@pixi/core"),o=require("@pixi/math"),s=require("@pixi/utils"),r=require("@pixi/text"),n=function(t){function n(s,r,n){void 0===s&&(s=""),void 0===r&&(r={}),(n=n||document.createElement("canvas")).width=3,n.height=3;var h=i.Texture.from(n,{scaleMode:e.settings.SCALE_MODE});h.orig=new o.Rectangle,h.trim=new o.Rectangle,t.call(this,h);var a="http://www.w3.org/2000/svg",l=document.createElementNS(a,"svg"),d=document.createElementNS(a,"foreignObject"),u=document.createElementNS("http://www.w3.org/1999/xhtml","div");d.setAttribute("height","100%"),d.setAttribute("width","100%"),l.appendChild(d),this._domElement=u,this._svgRoot=l,this._foreignObject=d,this._image=new Image,this.canvas=n,this.context=this.canvas.getContext("2d"),this._resolution=e.settings.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._loading=!1,this.text=s,this.style=r,this.localStyleID=-1}t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n;var h={width:{configurable:!0},height:{configurable:!0},style:{configurable:!0},text:{configurable:!0},resolution:{configurable:!0}};return n.prototype.updateText=function(t){var e=this,i=this.style,o=this.canvas,r=this.context,n=this.resolution;if(this.localStyleID!==i.styleID&&(this.dirty=!0,this.localStyleID=i.styleID),this.dirty||!t){var h="\n display:inline-block;\n color:"+i.fill+";\n font-size: "+i.fontSize+"px;\n font-family:"+i.fontFamily+";\n font-weight:"+i.fontWeight+";\n font-style:"+i.fontStyle+";\n font-variant:"+i.fontVariant+";\n letter-spacing:"+i.letterSpacing+"px;\n text-align:"+i.align+";\n padding:"+i.padding+"px;\n ";if(i.lineHeight&&(h+="line-height:"+i.lineHeight+"px;"),i.wordWrap&&(h+="word-wrap:"+(i.breakWords?"break-all":"break-word")+";",h+="width:"+i.wordWrapWidth+"px;"),i.strokeThickness){var a=i.stroke;"number"==typeof color&&(a=s.hex2string(a)),h+="-webkit-text-stroke-width: "+i.strokeThickness+"px;",h+="-webkit-text-stroke-color: "+a+";",h+="text-stroke-width: "+i.strokeThickness+"px;",h+="text-stroke-color: "+a+";",h+="paint-order: stroke;"}if(i.dropShadow){var l=i.dropShadowAngle,d=i.dropShadowDistance,u=i.dropShadowBlur,c=i.dropShadowColor,p=i.dropShadowAlpha,g=Math.round(Math.cos(l)*d),x=Math.round(Math.sin(l)*d),_=c;if("number"==typeof _&&(_=s.hex2string(_)),"#"===_.charAt(0)&&p<1){var y=s.hex2rgb(parseInt(_.replace("#",""),16));_="rgba("+(255*y[0]|0)+", "+(255*y[1]|0)+", "+(255*y[2]|0)+", "+p+")"}h+="text-shadow: "+g+"px "+x+"px "+u+"px "+_+";"}var f=this._domElement;Object.assign(f,{innerHTML:this._text,style:h}),document.body.appendChild(f);var w=f.getBoundingClientRect(),m=w.width,v=w.height;if(document.body.removeChild(f),this._foreignObject.appendChild(f),this._svgRoot.setAttribute("width",m),this._svgRoot.setAttribute("height",v),o.width=Math.ceil((Math.max(1,m)+2*i.padding)*n),o.height=Math.ceil((Math.max(1,v)+2*i.padding)*n),!this._loading){var b=this._image,S=(new XMLSerializer).serializeToString(this._svgRoot);this._loading=!0,b.src="data:image/svg+xml;charset=utf8,"+encodeURIComponent(S),b.onload=function(){r.scale(n,n),r.clearRect(0,0,o.width,o.height),r.drawImage(b,0,0,m,v,0,0,m,v),b.src="",b.onload=void 0,e._loading=!1,e.updateTexture()}}}},n.prototype.updateTexture=function(){var t=this.canvas,e=this.context,i=this.style,o=this.texture,r=this.resolution;if(i.trim){var n=s.trimCanvas(t),h=n.width,a=n.height,l=n.data;l&&(t.width=h,t.height=a,e.putImageData(l,0,0))}var d=i.trim?0:i.padding,u=o.baseTexture;o.trim.width=o._frame.width=Math.ceil(t.width/r),o.trim.height=o._frame.height=Math.ceil(t.height/r),o.trim.x=-d,o.trim.y=-d,o.orig.width=o._frame.width-2*d,o.orig.height=o._frame.height-2*d,this._onTextureUpdate(),u.setRealSize(t.width,t.height,r),this.dirty=!1},n.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._render.call(this,e)},n.prototype._renderCanvas=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._renderCanvas.call(this,e)},n.prototype.getLocalBounds=function(e){return this.updateText(!0),t.prototype.getLocalBounds.call(this,e)},n.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},n.prototype._onStyleChange=function(){this.dirty=!0},n.prototype.destroy=function(e){void 0===e&&(e=!0),t.prototype.destroy.call(this,e),this.context=null,this.canvas.width=this.canvas.height=0,this.canvas=null,this._style=null,this._svgRoot=null,this._domElement=null,this._foreignObject=null,this._image.onload=null,this._image.src="",this._image=null},h.width.get=function(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width},h.width.set=function(t){this.updateText(!0);var e=s.sign(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t},h.height.get=function(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height},h.height.set=function(t){this.updateText(!0);var e=s.sign(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t},h.style.get=function(){return this._style},h.style.set=function(t){(t=t||{})instanceof r.TextStyle?this._style=t:this._style=new r.TextStyle(t),this.localStyleID=-1,this.dirty=!0},h.text.get=function(){return this._text},h.text.set=function(t){t=String(""===t||null==t?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)},h.resolution.get=function(){return this._resolution},h.resolution.set=function(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)},n.prototype.sanitiseText=function(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")},Object.defineProperties(n.prototype,h),n}(t.Sprite);exports.HTMLText=n; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@pixi/sprite"),e=require("@pixi/settings"),i=require("@pixi/core"),s=require("@pixi/math"),o=require("@pixi/utils"),n=require("@pixi/text"),r=function(t){function r(o,n,r){void 0===o&&(o=""),void 0===n&&(n={}),(r=r||document.createElement("canvas")).width=3,r.height=3;var h=i.Texture.from(r,{scaleMode:e.settings.SCALE_MODE});h.orig=new s.Rectangle,h.trim=new s.Rectangle,t.call(this,h);var a="http://www.w3.org/2000/svg",l=document.createElementNS(a,"svg"),d=document.createElementNS(a,"foreignObject"),u=document.createElementNS("http://www.w3.org/1999/xhtml","div");d.setAttribute("height","100%"),d.setAttribute("width","100%"),l.appendChild(d),this._domElement=u,this._svgRoot=l,this._foreignObject=d,this._image=new Image,this.canvas=r,this.context=this.canvas.getContext("2d"),this._resolution=e.settings.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._loading=!1,this.text=o,this.style=n,this.localStyleID=-1}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var h={width:{configurable:!0},height:{configurable:!0},style:{configurable:!0},text:{configurable:!0},resolution:{configurable:!0}};return r.prototype.updateText=function(t){var e=this,i=this.style,s=this.canvas,n=this.context,r=this.resolution;if(this.localStyleID!==i.styleID&&(this.dirty=!0,this.localStyleID=i.styleID),this.dirty||!t){var h="\n display:inline-block;\n color:"+i.fill+";\n font-size: "+i.fontSize+"px;\n font-family:"+i.fontFamily+";\n font-weight:"+i.fontWeight+";\n font-style:"+i.fontStyle+";\n font-variant:"+i.fontVariant+";\n letter-spacing:"+i.letterSpacing+"px;\n text-align:"+i.align+";\n padding:"+i.padding+"px;\n ";if(i.lineHeight&&(h+="line-height:"+i.lineHeight+"px;"),i.wordWrap&&(h+="word-wrap:"+(i.breakWords?"break-all":"break-word")+";",h+="width:"+i.wordWrapWidth+"px;"),i.strokeThickness){var a=i.stroke;"number"==typeof color&&(a=o.hex2string(a)),h+="-webkit-text-stroke-width: "+i.strokeThickness+"px;",h+="-webkit-text-stroke-color: "+a+";",h+="text-stroke-width: "+i.strokeThickness+"px;",h+="text-stroke-color: "+a+";",h+="paint-order: stroke;"}if(i.dropShadow){var l=i.dropShadowAngle,d=i.dropShadowDistance,u=i.dropShadowBlur,c=i.dropShadowColor,p=i.dropShadowAlpha,g=Math.round(Math.cos(l)*d),x=Math.round(Math.sin(l)*d),y=c;if("number"==typeof y&&(y=o.hex2string(y)),"#"===y.charAt(0)&&p<1){var _=o.hex2rgb(parseInt(y.replace("#",""),16));y="rgba("+(255*_[0]|0)+", "+(255*_[1]|0)+", "+(255*_[2]|0)+", "+p+")"}h+="text-shadow: "+g+"px "+x+"px "+u+"px "+y+";"}var f=this._domElement;Object.assign(f,{innerHTML:this._text,style:h}),document.body.appendChild(f);var w=f.getBoundingClientRect(),m=w.width,v=w.height;if(document.body.removeChild(f),this._foreignObject.appendChild(f),this._svgRoot.setAttribute("width",m),this._svgRoot.setAttribute("height",v),s.width=Math.ceil((Math.max(1,m)+2*i.padding)*r),s.height=Math.ceil((Math.max(1,v)+2*i.padding)*r),!this._loading){var b=this._image,S=(new XMLSerializer).serializeToString(this._svgRoot);this._loading=!0,b.src="data:image/svg+xml;charset=utf8,"+encodeURIComponent(S),b.onload=function(){n.scale(r,r),n.clearRect(0,0,s.width,s.height),n.drawImage(b,0,0,m,v,0,0,m,v),b.src="",b.onload=void 0,e._loading=!1,e.updateTexture()}}}},r.prototype.updateTexture=function(){var t=this.canvas,e=this.context,i=this.style,s=this.texture,n=this.resolution;if(i.trim){var r=o.trimCanvas(t),h=r.width,a=r.height,l=r.data;l&&(t.width=h,t.height=a,e.putImageData(l,0,0))}var d=i.trim?0:i.padding,u=s.baseTexture;s.trim.width=s._frame.width=Math.ceil(t.width/n),s.trim.height=s._frame.height=Math.ceil(t.height/n),s.trim.x=-d,s.trim.y=-d,s.orig.width=s._frame.width-2*d,s.orig.height=s._frame.height-2*d,this._onTextureUpdate(),u.setRealSize(t.width,t.height,n),this.dirty=!1},r.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._render.call(this,e)},r.prototype._renderCanvas=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._renderCanvas.call(this,e)},r.prototype.getLocalBounds=function(e){return this.updateText(!0),t.prototype.getLocalBounds.call(this,e)},r.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},r.prototype._onStyleChange=function(){this.dirty=!0},r.prototype.destroy=function(e){void 0===e&&(e=!0),t.prototype.destroy.call(this,e),this.context=null,this.canvas.width=this.canvas.height=0,this.canvas=null,this._style=null,this._svgRoot=null,this._domElement=null,this._foreignObject=null,this._image.onload=null,this._image.src="",this._image=null},h.width.get=function(){return this.updateText(!0),Math.abs(this.scale.x)*this.canvas.width},h.width.set=function(t){this.updateText(!0);var e=o.sign(this.scale.x)||1;this.scale.x=e*t/this.canvas.width,this._width=t},h.height.get=function(){return this.updateText(!0),Math.abs(this.scale.y)*this.canvas.height},h.height.set=function(t){this.updateText(!0);var e=o.sign(this.scale.y)||1;this.scale.y=e*t/this.canvas.height,this._height=t},h.style.get=function(){return this._style},h.style.set=function(t){(t=t||{})instanceof n.TextStyle?this._style=t:this._style=new n.TextStyle(t),this.localStyleID=-1,this.dirty=!0},h.text.get=function(){return this._text},h.text.set=function(t){t=String(""===t||null==t?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)},h.resolution.get=function(){return this._resolution},h.resolution.set=function(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)},r.prototype.sanitiseText=function(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")},Object.defineProperties(r.prototype,h),r}(t.Sprite);exports.HTMLText=r; | ||
//# sourceMappingURL=html-text.cjs.js.map |
/*! | ||
* @pixi/text-html - v2.0.3 | ||
* Compiled Thu, 09 Jun 2022 15:13:58 UTC | ||
* @pixi/text-html - v2.1.0 | ||
* Compiled Fri, 05 Aug 2022 20:21:10 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/text-html is licensed under the MIT License. | ||
*/ | ||
var _pixi_htmltext=function(t,e,i,o,s,n,r){"use strict";var h=function(t){function e(e,n,r){void 0===e&&(e=""),void 0===n&&(n={}),(r=r||document.createElement("canvas")).width=3,r.height=3;var h=o.Texture.from(r,{scaleMode:i.settings.SCALE_MODE});h.orig=new s.Rectangle,h.trim=new s.Rectangle,t.call(this,h);var a="http://www.w3.org/2000/svg",l=document.createElementNS(a,"svg"),d=document.createElementNS(a,"foreignObject"),u=document.createElementNS("http://www.w3.org/1999/xhtml","div");d.setAttribute("height","100%"),d.setAttribute("width","100%"),l.appendChild(d),this._domElement=u,this._svgRoot=l,this._foreignObject=d,this._image=new Image,this.canvas=r,this.context=this.canvas.getContext("2d"),this._resolution=i.settings.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._loading=!1,this.text=e,this.style=n,this.localStyleID=-1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var h={width:{configurable:!0},height:{configurable:!0},style:{configurable:!0},text:{configurable:!0},resolution:{configurable:!0}};return e.prototype.updateText=function(t){var e=this,i=this.style,o=this.canvas,s=this.context,r=this.resolution;if(this.localStyleID!==i.styleID&&(this.dirty=!0,this.localStyleID=i.styleID),this.dirty||!t){var h="\n display:inline-block;\n color:"+i.fill+";\n font-size: "+i.fontSize+"px;\n font-family:"+i.fontFamily+";\n font-weight:"+i.fontWeight+";\n font-style:"+i.fontStyle+";\n font-variant:"+i.fontVariant+";\n letter-spacing:"+i.letterSpacing+"px;\n text-align:"+i.align+";\n padding:"+i.padding+"px;\n ";if(i.lineHeight&&(h+="line-height:"+i.lineHeight+"px;"),i.wordWrap&&(h+="word-wrap:"+(i.breakWords?"break-all":"break-word")+";",h+="width:"+i.wordWrapWidth+"px;"),i.strokeThickness){var a=i.stroke;"number"==typeof color&&(a=n.hex2string(a)),h+="-webkit-text-stroke-width: "+i.strokeThickness+"px;",h+="-webkit-text-stroke-color: "+a+";",h+="text-stroke-width: "+i.strokeThickness+"px;",h+="text-stroke-color: "+a+";",h+="paint-order: stroke;"}if(i.dropShadow){var l=i.dropShadowAngle,d=i.dropShadowDistance,u=i.dropShadowBlur,c=i.dropShadowColor,g=i.dropShadowAlpha,p=Math.round(Math.cos(l)*d),x=Math.round(Math.sin(l)*d),_=c;if("number"==typeof _&&(_=n.hex2string(_)),"#"===_.charAt(0)&&g<1){var y=n.hex2rgb(parseInt(_.replace("#",""),16));_="rgba("+(255*y[0]|0)+", "+(255*y[1]|0)+", "+(255*y[2]|0)+", "+g+")"}h+="text-shadow: "+p+"px "+x+"px "+u+"px "+_+";"}var f=this._domElement;Object.assign(f,{innerHTML:this._text,style:h}),document.body.appendChild(f);var w=f.getBoundingClientRect(),m=w.width,v=w.height;if(document.body.removeChild(f),this._foreignObject.appendChild(f),this._svgRoot.setAttribute("width",m),this._svgRoot.setAttribute("height",v),o.width=Math.ceil((Math.max(1,m)+2*i.padding)*r),o.height=Math.ceil((Math.max(1,v)+2*i.padding)*r),!this._loading){var b=this._image,I=(new XMLSerializer).serializeToString(this._svgRoot);this._loading=!0,b.src="data:image/svg+xml;charset=utf8,"+encodeURIComponent(I),b.onload=function(){s.scale(r,r),s.clearRect(0,0,o.width,o.height),s.drawImage(b,0,0,m,v,0,0,m,v),b.src="",b.onload=void 0,e._loading=!1,e.updateTexture()}}}},e.prototype.updateTexture=function(){var t=this.canvas,e=this.context,i=this.style,o=this.texture,s=this.resolution;if(i.trim){var r=n.trimCanvas(t),h=r.width,a=r.height,l=r.data;l&&(t.width=h,t.height=a,e.putImageData(l,0,0))}var d=i.trim?0:i.padding,u=o.baseTexture;o.trim.width=o._frame.width=Math.ceil(t.width/s),o.trim.height=o._frame.height=Math.ceil(t.height/s),o.trim.x=-d,o.trim.y=-d,o.orig.width=o._frame.width-2*d,o.orig.height=o._frame.height-2*d,this._onTextureUpdate(),u.setRealSize(t.width,t.height,s),this.dirty=!1},e.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._render.call(this,e)},e.prototype._renderCanvas=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._renderCanvas.call(this,e)},e.prototype.getLocalBounds=function(e){return this.updateText(!0),t.prototype.getLocalBounds.call(this,e)},e.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},e.prototype._onStyleChange=function(){this.dirty=!0},e.prototype.destroy=function(e){void 0===e&&(e=!0),t.prototype.destroy.call(this,e),this.context=null,this.canvas.width=this.canvas.height=0,this.canvas=null,this._style=null,this._svgRoot=null,this._domElement=null,this._foreignObject=null,this._image.onload=null,this._image.src="",this._image=null},h.width.get=function(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width},h.width.set=function(t){this.updateText(!0);var e=n.sign(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t},h.height.get=function(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height},h.height.set=function(t){this.updateText(!0);var e=n.sign(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t},h.style.get=function(){return this._style},h.style.set=function(t){(t=t||{})instanceof r.TextStyle?this._style=t:this._style=new r.TextStyle(t),this.localStyleID=-1,this.dirty=!0},h.text.get=function(){return this._text},h.text.set=function(t){t=String(""===t||null==t?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)},h.resolution.get=function(){return this._resolution},h.resolution.set=function(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)},e.prototype.sanitiseText=function(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")},Object.defineProperties(e.prototype,h),e}(e.Sprite);return t.HTMLText=h,t}({},PIXI,PIXI,PIXI,PIXI,PIXI.utils,PIXI);Object.assign(PIXI,_pixi_htmltext); | ||
var _pixi_htmltext=function(t,e,i,s,o,n,h){"use strict";var r=function(t){function e(e,n,h){void 0===e&&(e=""),void 0===n&&(n={}),(h=h||document.createElement("canvas")).width=3,h.height=3;var r=s.Texture.from(h,{scaleMode:i.settings.SCALE_MODE});r.orig=new o.Rectangle,r.trim=new o.Rectangle,t.call(this,r);var a="http://www.w3.org/2000/svg",l=document.createElementNS(a,"svg"),d=document.createElementNS(a,"foreignObject"),c=document.createElementNS("http://www.w3.org/1999/xhtml","div");d.setAttribute("height","100%"),d.setAttribute("width","100%"),l.appendChild(d),this._domElement=c,this._svgRoot=l,this._foreignObject=d,this._image=new Image,this.canvas=h,this.context=this.canvas.getContext("2d"),this._resolution=i.settings.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._loading=!1,this.text=e,this.style=n,this.localStyleID=-1}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={width:{configurable:!0},height:{configurable:!0},style:{configurable:!0},text:{configurable:!0},resolution:{configurable:!0}};return e.prototype.updateText=function(t){var e=this,i=this.style,s=this.canvas,o=this.context,h=this.resolution;if(this.localStyleID!==i.styleID&&(this.dirty=!0,this.localStyleID=i.styleID),this.dirty||!t){var r="\n display:inline-block;\n color:"+i.fill+";\n font-size: "+i.fontSize+"px;\n font-family:"+i.fontFamily+";\n font-weight:"+i.fontWeight+";\n font-style:"+i.fontStyle+";\n font-variant:"+i.fontVariant+";\n letter-spacing:"+i.letterSpacing+"px;\n text-align:"+i.align+";\n padding:"+i.padding+"px;\n ";if(i.lineHeight&&(r+="line-height:"+i.lineHeight+"px;"),i.wordWrap&&(r+="word-wrap:"+(i.breakWords?"break-all":"break-word")+";",r+="width:"+i.wordWrapWidth+"px;"),i.strokeThickness){var a=i.stroke;"number"==typeof color&&(a=n.hex2string(a)),r+="-webkit-text-stroke-width: "+i.strokeThickness+"px;",r+="-webkit-text-stroke-color: "+a+";",r+="text-stroke-width: "+i.strokeThickness+"px;",r+="text-stroke-color: "+a+";",r+="paint-order: stroke;"}if(i.dropShadow){var l=i.dropShadowAngle,d=i.dropShadowDistance,c=i.dropShadowBlur,u=i.dropShadowColor,g=i.dropShadowAlpha,p=Math.round(Math.cos(l)*d),x=Math.round(Math.sin(l)*d),_=u;if("number"==typeof _&&(_=n.hex2string(_)),"#"===_.charAt(0)&&g<1){var y=n.hex2rgb(parseInt(_.replace("#",""),16));_="rgba("+(255*y[0]|0)+", "+(255*y[1]|0)+", "+(255*y[2]|0)+", "+g+")"}r+="text-shadow: "+p+"px "+x+"px "+c+"px "+_+";"}var f=this._domElement;Object.assign(f,{innerHTML:this._text,style:r}),document.body.appendChild(f);var w=f.getBoundingClientRect(),m=w.width,v=w.height;if(document.body.removeChild(f),this._foreignObject.appendChild(f),this._svgRoot.setAttribute("width",m),this._svgRoot.setAttribute("height",v),s.width=Math.ceil((Math.max(1,m)+2*i.padding)*h),s.height=Math.ceil((Math.max(1,v)+2*i.padding)*h),!this._loading){var b=this._image,I=(new XMLSerializer).serializeToString(this._svgRoot);this._loading=!0,b.src="data:image/svg+xml;charset=utf8,"+encodeURIComponent(I),b.onload=function(){o.scale(h,h),o.clearRect(0,0,s.width,s.height),o.drawImage(b,0,0,m,v,0,0,m,v),b.src="",b.onload=void 0,e._loading=!1,e.updateTexture()}}}},e.prototype.updateTexture=function(){var t=this.canvas,e=this.context,i=this.style,s=this.texture,o=this.resolution;if(i.trim){var h=n.trimCanvas(t),r=h.width,a=h.height,l=h.data;l&&(t.width=r,t.height=a,e.putImageData(l,0,0))}var d=i.trim?0:i.padding,c=s.baseTexture;s.trim.width=s._frame.width=Math.ceil(t.width/o),s.trim.height=s._frame.height=Math.ceil(t.height/o),s.trim.x=-d,s.trim.y=-d,s.orig.width=s._frame.width-2*d,s.orig.height=s._frame.height-2*d,this._onTextureUpdate(),c.setRealSize(t.width,t.height,o),this.dirty=!1},e.prototype._render=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._render.call(this,e)},e.prototype._renderCanvas=function(e){this._autoResolution&&this._resolution!==e.resolution&&(this._resolution=e.resolution,this.dirty=!0),this.updateText(!0),t.prototype._renderCanvas.call(this,e)},e.prototype.getLocalBounds=function(e){return this.updateText(!0),t.prototype.getLocalBounds.call(this,e)},e.prototype._calculateBounds=function(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)},e.prototype._onStyleChange=function(){this.dirty=!0},e.prototype.destroy=function(e){void 0===e&&(e=!0),t.prototype.destroy.call(this,e),this.context=null,this.canvas.width=this.canvas.height=0,this.canvas=null,this._style=null,this._svgRoot=null,this._domElement=null,this._foreignObject=null,this._image.onload=null,this._image.src="",this._image=null},r.width.get=function(){return this.updateText(!0),Math.abs(this.scale.x)*this.canvas.width},r.width.set=function(t){this.updateText(!0);var e=n.sign(this.scale.x)||1;this.scale.x=e*t/this.canvas.width,this._width=t},r.height.get=function(){return this.updateText(!0),Math.abs(this.scale.y)*this.canvas.height},r.height.set=function(t){this.updateText(!0);var e=n.sign(this.scale.y)||1;this.scale.y=e*t/this.canvas.height,this._height=t},r.style.get=function(){return this._style},r.style.set=function(t){(t=t||{})instanceof h.TextStyle?this._style=t:this._style=new h.TextStyle(t),this.localStyleID=-1,this.dirty=!0},r.text.get=function(){return this._text},r.text.set=function(t){t=String(""===t||null==t?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)},r.resolution.get=function(){return this._resolution},r.resolution.set=function(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)},e.prototype.sanitiseText=function(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")},Object.defineProperties(e.prototype,r),e}(e.Sprite);return t.HTMLText=r,t}({},PIXI,PIXI,PIXI,PIXI,PIXI.utils,PIXI);Object.assign(PIXI,_pixi_htmltext); | ||
//# sourceMappingURL=html-text.js.map |
{ | ||
"name": "@pixi/text-html", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "Multi-Style Text Rendering Plugin for PixiJS", | ||
"main": "dist/html-text.cjs.js", | ||
"module": "dist/html-text.es.js", | ||
"module": "dist/html-text.es.mjs", | ||
"bundle": "dist/html-text.js", | ||
"types": "index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/html-text.es.mjs", | ||
"require": "./dist/html-text.cjs.js", | ||
"types": "./index.d.ts" | ||
} | ||
}, | ||
"homepage": "https://pixijs.io/html-text/docs/", | ||
@@ -10,0 +17,0 @@ "bugs": "https://github.com/pixijs/html-text/issues", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80769