New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

three-spritetext

Package Overview
Dependencies
Maintainers
0
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three-spritetext - npm Package Compare versions

Comparing version 1.9.2 to 1.9.3

2

dist/three-spritetext.js

@@ -1,2 +0,2 @@

// Version 1.9.2 three-spritetext - https://github.com/vasturiano/three-spritetext
// Version 1.9.3 three-spritetext - https://github.com/vasturiano/three-spritetext
(function (global, factory) {

@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('three')) :

@@ -1,2 +0,2 @@

// Version 1.9.2 three-spritetext - https://github.com/vasturiano/three-spritetext
// Version 1.9.3 three-spritetext - https://github.com/vasturiano/three-spritetext
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("three")):"function"==typeof define&&define.amd?define(["three"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).SpriteText=e(t.THREE)}(this,(function(t){"use strict";function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function r(t,e,r){return e=n(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,o()?Reflect.construct(e,r||[],n(t).constructor):e.apply(t,r))}function i(t,e,r){return e&&function(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,u(i.key),i)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function o(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(o=function(){return!!t})()}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var i,n,o,a,h=[],s=!0,u=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(i=o.call(r)).done)&&(h.push(i.value),h.length!==e);s=!0);}catch(t){u=!0,n=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw n}}return h}}(t,e)||c(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||c(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function c(t,r){if(t){if("string"==typeof t)return e(t,r);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,r):void 0}}var f="undefined"!=typeof window&&window.THREE?window.THREE:{CanvasTexture:t.CanvasTexture,Sprite:t.Sprite,SpriteMaterial:t.SpriteMaterial,SRGBColorSpace:t.SRGBColorSpace},l=function(t){function e(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgba(255, 255, 255, 1)";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(t=r(this,e,[new f.SpriteMaterial]))._text="".concat(i),t._textHeight=n,t._color=o,t._backgroundColor=!1,t._padding=0,t._borderWidth=0,t._borderRadius=0,t._borderColor="white",t._strokeWidth=0,t._strokeColor="white",t._fontFace="system-ui",t._fontSize=90,t._fontWeight="normal",t._canvas=document.createElement("canvas"),t._genCanvas(),t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}(e,t),i(e,[{key:"text",get:function(){return this._text},set:function(t){this._text=t,this._genCanvas()}},{key:"textHeight",get:function(){return this._textHeight},set:function(t){this._textHeight=t,this._genCanvas()}},{key:"color",get:function(){return this._color},set:function(t){this._color=t,this._genCanvas()}},{key:"backgroundColor",get:function(){return this._backgroundColor},set:function(t){this._backgroundColor=t,this._genCanvas()}},{key:"padding",get:function(){return this._padding},set:function(t){this._padding=t,this._genCanvas()}},{key:"borderWidth",get:function(){return this._borderWidth},set:function(t){this._borderWidth=t,this._genCanvas()}},{key:"borderRadius",get:function(){return this._borderRadius},set:function(t){this._borderRadius=t,this._genCanvas()}},{key:"borderColor",get:function(){return this._borderColor},set:function(t){this._borderColor=t,this._genCanvas()}},{key:"fontFace",get:function(){return this._fontFace},set:function(t){this._fontFace=t,this._genCanvas()}},{key:"fontSize",get:function(){return this._fontSize},set:function(t){this._fontSize=t,this._genCanvas()}},{key:"fontWeight",get:function(){return this._fontWeight},set:function(t){this._fontWeight=t,this._genCanvas()}},{key:"strokeWidth",get:function(){return this._strokeWidth},set:function(t){this._strokeWidth=t,this._genCanvas()}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(t){this._strokeColor=t,this._genCanvas()}},{key:"_genCanvas",value:function(){var t=this,e=this._canvas,r=e.getContext("2d"),i=1/this.textHeight,n=Array.isArray(this.borderWidth)?this.borderWidth:[this.borderWidth,this.borderWidth],o=n.map((function(e){return e*t.fontSize*i})),a=(Array.isArray(this.borderRadius)?this.borderRadius:[this.borderRadius,this.borderRadius,this.borderRadius,this.borderRadius]).map((function(e){return e*t.fontSize*i})),u=Array.isArray(this.padding)?this.padding:[this.padding,this.padding],c=u.map((function(e){return e*t.fontSize*i})),l=this.text.split("\n"),d="".concat(this.fontWeight," ").concat(this.fontSize,"px ").concat(this.fontFace);r.font=d;var g=Math.max.apply(Math,s(l.map((function(t){return r.measureText(t).width})))),p=this.fontSize*l.length;if(e.width=g+2*o[0]+2*c[0],e.height=p+2*o[1]+2*c[1],this.borderWidth){if(r.strokeStyle=this.borderColor,o[0]){var y=o[0]/2;r.lineWidth=o[0],r.beginPath(),r.moveTo(y,a[0]),r.lineTo(y,e.height-a[3]),r.moveTo(e.width-y,a[1]),r.lineTo(e.width-y,e.height-a[2]),r.stroke()}if(o[1]){var b=o[1]/2;r.lineWidth=o[1],r.beginPath(),r.moveTo(Math.max(o[0],a[0]),b),r.lineTo(e.width-Math.max(o[0],a[1]),b),r.moveTo(Math.max(o[0],a[3]),e.height-b),r.lineTo(e.width-Math.max(o[0],a[2]),e.height-b),r.stroke()}if(this.borderRadius){var v=Math.max.apply(Math,s(o)),_=v/2;r.lineWidth=v,r.beginPath(),[!!a[0]&&[a[0],_,_,a[0]],!!a[1]&&[e.width-a[1],e.width-_,_,a[1]],!!a[2]&&[e.width-a[2],e.width-_,e.height-_,e.height-a[2]],!!a[3]&&[a[3],_,e.height-_,e.height-a[3]]].filter((function(t){return t})).forEach((function(t){var e=h(t,4),i=e[0],n=e[1],o=e[2],a=e[3];r.moveTo(i,o),r.quadraticCurveTo(n,o,n,a)})),r.stroke()}}this.backgroundColor&&(r.fillStyle=this.backgroundColor,this.borderRadius?(r.beginPath(),r.moveTo(o[0],a[0]),[[o[0],a[0],e.width-a[1],o[1],o[1],o[1]],[e.width-o[0],e.width-o[0],e.width-o[0],o[1],a[1],e.height-a[2]],[e.width-o[0],e.width-a[2],a[3],e.height-o[1],e.height-o[1],e.height-o[1]],[o[0],o[0],o[0],e.height-o[1],e.height-a[3],a[0]]].forEach((function(t){var e=h(t,6),i=e[0],n=e[1],o=e[2],a=e[3],s=e[4],u=e[5];r.quadraticCurveTo(i,a,n,s),r.lineTo(o,u)})),r.closePath(),r.fill()):r.fillRect(o[0],o[1],e.width-2*o[0],e.height-2*o[1])),r.translate.apply(r,s(o)),r.translate.apply(r,s(c)),r.font=d,r.fillStyle=this.color,r.textBaseline="bottom";var m=this.strokeWidth>0;m&&(r.lineWidth=this.strokeWidth*this.fontSize/10,r.strokeStyle=this.strokeColor),l.forEach((function(e,i){var n=(g-r.measureText(e).width)/2,o=(i+1)*t.fontSize;m&&r.strokeText(e,n,o),r.fillText(e,n,o)})),this.material.map&&this.material.map.dispose(),(this.material.map=new f.CanvasTexture(e)).colorSpace=f.SRGBColorSpace;var w=this.textHeight*l.length+2*n[1]+2*u[1];this.scale.set(w*e.width/e.height,w,0)}},{key:"clone",value:function(){return new this.constructor(this.text,this.textHeight,this.color).copy(this)}},{key:"copy",value:function(t){return f.Sprite.prototype.copy.call(this,t),this.color=t.color,this.backgroundColor=t.backgroundColor,this.padding=t.padding,this.borderWidth=t.borderWidth,this.borderColor=t.borderColor,this.fontFace=t.fontFace,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.strokeWidth=t.strokeWidth,this.strokeColor=t.strokeColor,this}}])}(f.Sprite);return l}));
{
"name": "three-spritetext",
"version": "1.9.2",
"version": "1.9.3",
"description": "A sprite based text component for ThreeJS",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc