Socket
Socket
Sign inDemoInstall

three.texttexture

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

three.texttexture - npm Package Compare versions

Comparing version 18.7.14 to 18.8.5

6

package.json
{
"name": "three.texttexture",
"version": "18.7.14",
"version": "18.8.5",
"description": "A texture for writing text on its canvas.",

@@ -28,7 +28,7 @@ "main": "THREE.TextTexture.js",

"dependencies": {
"three": "^0.94.0"
"three": "^0.95.0"
},
"devDependencies": {
"@seregpie/rollup-plugin-resolve": "^18.6.13",
"rollup": "^0.62.0",
"rollup": "^0.63.5",
"rollup-plugin-buble": "^0.19.2",

@@ -35,0 +35,0 @@ "rollup-plugin-uglify": "^4.0.0"

@@ -40,6 +40,7 @@ # THREE.TextTexture

`.constructor({autoRedraw, text, textAlign, textLineHeight, fontFamily, fontSize, fontWeight, fontVariant, fontStyle, fillStyle, lineWidth, strokeStyle, padding, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy})`
`.constructor({autoRedraw, pixelRatio, text, textAlign, textLineHeight, fontFamily, fontSize, fontWeight, fontVariant, fontStyle, fillStyle, lineWidth, strokeStyle, padding, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy})`
```javascript
let texture = new THREE.TextTexture({
pixelRatio: devicePixelRatio,
text: 'Carpe Diem',

@@ -58,2 +59,10 @@ fontFamily: '"Times New Roman", Times, serif',

`.pixelRatio = 1`
the device pixel ratio.
Changing the value will redraw the canvas if `autoRedraw` is `true`.
---
`.text = ''`

@@ -60,0 +69,0 @@

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

!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("three")):"function"==typeof define&&define.amd?define(["three"],i):(t.THREE=t.THREE||{},t.THREE.TextTexture=i(t.THREE))}(this,function(m){"use strict";function P(){return document.createElement("canvas")}function e(t){return void 0===t}function n(t,i){if(t.length){var e=P().getContext("2d");return e.font=i,function(t){if(0<t.length)return t.reduce(function(t,i){return Math.max(t,i)})}(t.map(function(t){return e.measureText(t).width}))}return 0}return function(S){function t(t){void 0===t&&(t={});var i=t.autoRedraw;void 0===i&&(i=!0);var e=t.text;void 0===e&&(e="");var n=t.textAlign;void 0===n&&(n="center");var o=t.textLineHeight;void 0===o&&(o=1.15);var s=t.fontFamily;void 0===s&&(s="sans-serif");var h=t.fontSize;void 0===h&&(h=16);var r=t.fontWeight;void 0===r&&(r="normal");var l=t.fontVariant;void 0===l&&(l="normal");var a=t.fontStyle;void 0===a&&(a="normal");var f=t.fillStyle;void 0===f&&(f="white");var g=t.lineWidth;void 0===g&&(g=0);var x=t.strokeStyle;void 0===x&&(x="black");var d=t.padding;void 0===d&&(d=.25);var u=t.magFilter;void 0===u&&(u=m.LinearFilter);var c=t.minFilter;void 0===c&&(c=m.LinearFilter);var _=t.mapping,I=t.wrapS,v=t.wrapT,y=t.format,W=t.type,p=t.anisotropy;S.call(this,P(),_,I,v,u,c,y,W,p),this.autoRedraw=i,this._text=e,this._textAlign=n,this._textLineHeight=o,this._fontFamily=s,this._fontSize=h,this._fontWeight=r,this._fontVariant=l,this._fontStyle=a,this._fillStyle=f,this._lineWidth=g,this._strokeStyle=x,this._padding=d,this.redraw()}S&&(t.__proto__=S);var i={text:{configurable:!0},textAlign:{configurable:!0},textLines:{configurable:!0},textLineHeight:{configurable:!0},textLineHeightInPixels:{configurable:!0},fontFamily:{configurable:!0},fontSize:{configurable:!0},fontWeight:{configurable:!0},fontVariant:{configurable:!0},fontStyle:{configurable:!0},font:{configurable:!0},fillStyle:{configurable:!0},lineWidth:{configurable:!0},lineWidthInPixels:{configurable:!0},strokeStyle:{configurable:!0},textBoxWidthInPixels:{configurable:!0},textBoxHeight:{configurable:!0},textBoxHeightInPixels:{configurable:!0},padding:{configurable:!0},paddingInPixels:{configurable:!0},imageWidthInPixels:{configurable:!0},imageHeight:{configurable:!0},imageHeightInPixels:{configurable:!0},imageAspect:{configurable:!0}};return((t.prototype=Object.create(S&&S.prototype)).constructor=t).prototype.redraw=function(){var i=this,e=this.image.getContext("2d");if(e.clearRect(0,0,e.canvas.width,e.canvas.height),this.textBoxWidthInPixels&&this.textBoxHeightInPixels){var n;switch(e.canvas.width=this.imageWidthInPixels,e.canvas.height=this.imageHeightInPixels,e.font=this.font,e.textBaseline="middle",this.textAlign){case"left":e.textAlign="left",n=this.paddingInPixels+this.lineWidthInPixels/2;break;case"right":e.textAlign="right",n=this.paddingInPixels+this.lineWidthInPixels/2+this.textBoxWidthInPixels;break;case"center":e.textAlign="center",n=this.paddingInPixels+this.lineWidthInPixels/4+this.textBoxWidthInPixels/2}var o=this.paddingInPixels+this.lineWidthInPixels/2+this.fontSize/2;e.fillStyle=this.fillStyle,e.miterLimit=1,e.lineWidth=this.lineWidthInPixels,e.strokeStyle=this.strokeStyle,this.textLines.forEach(function(t){i.lineWidth&&e.strokeText(t,n,o),e.fillText(t,n,o),o+=i.textLineHeightInPixels})}else e.canvas.width=e.canvas.height=1;this.needsUpdate=!0},t.prototype._redrawIfAuto=function(){this.autoRedraw&&this.redraw()},i.text.get=function(){return this._text},i.text.set=function(t){this._text!==t&&(this._text=t,this._textLines=void 0,this._textBoxWidthInPixels=void 0,this._redrawIfAuto())},i.textAlign.get=function(){return this._textAlign},i.textAlign.set=function(t){this._textAlign!==t&&(this._textAlign=t,this._redrawIfAuto())},i.textLines.get=function(){var t;return e(this._textLines)&&(this._textLines=(t=this.text)?t.split("\n"):[]),this._textLines},i.textLineHeight.get=function(){return this._textLineHeight},i.textLineHeight.set=function(t){this._textLineHeight!==t&&(this._textLineHeight=t,this._redrawIfAuto())},i.textLineHeightInPixels.get=function(){return this.fontSize*this.textLineHeight},i.fontFamily.get=function(){return this._fontFamily},i.fontFamily.set=function(t){this._fontFamily!==t&&(this._fontFamily=t,this._textBoxWidthInPixels=void 0,this._redrawIfAuto())},i.fontSize.get=function(){return this._fontSize},i.fontSize.set=function(t){this._fontSize!==t&&(this._fontSize=t,this._textBoxWidthInPixels=void 0,this._redrawIfAuto())},i.fontWeight.get=function(){return this._fontWeight},i.fontWeight.set=function(t){this._fontWeight!==t&&(this._fontWeight=t,this._textBoxWidthInPixels=void 0,this._redrawIfAuto())},i.fontVariant.get=function(){return this._fontVariant},i.fontVariant.set=function(t){this._fontVariant!==t&&(this._fontVariant=t,this._textBoxWidthInPixels=void 0,this._redrawIfAuto())},i.fontStyle.get=function(){return this._fontStyle},i.fontStyle.set=function(t){this._fontStyle!==t&&(this._fontStyle=t,this._textBoxWidthInPixels=void 0,this._redrawIfAuto())},i.font.get=function(){return t=this.fontStyle,i=this.fontVariant,e=this.fontWeight,n=this.fontSize,o=this.fontFamily,[t,i,e,n+"px",o].join(" ");var t,i,e,n,o},i.fillStyle.get=function(){return this._fillStyle},i.fillStyle.set=function(t){this._fillStyle!==t&&(this._fillStyle=t,this._redrawIfAuto())},i.lineWidth.get=function(){return this._lineWidth},i.lineWidth.set=function(t){this._lineWidth!==t&&(this._lineWidth=t,this._redrawIfAuto())},i.lineWidthInPixels.get=function(){return this._lineWidth*this.fontSize},i.strokeStyle.get=function(){return this._strokeStyle},i.strokeStyle.set=function(t){this._strokeStyle!==t&&(this._strokeStyle=t,this._redrawIfAuto())},i.textBoxWidthInPixels.get=function(){return e(this._textBoxWidthInPixels)&&(this._textBoxWidthInPixels=n(this.textLines,this.font)),this._textBoxWidthInPixels},i.textBoxHeight.get=function(){return this.textLineHeight*(this.textLines.length-1)+1},i.textBoxHeightInPixels.get=function(){return this.textBoxHeight*this.fontSize},i.padding.get=function(){return this._padding},i.padding.set=function(t){this._padding!==t&&(this._padding=t,this._redrawIfAuto())},i.paddingInPixels.get=function(){return this.padding*this.fontSize},i.imageWidthInPixels.get=function(){return this.textBoxWidthInPixels+this.lineWidthInPixels+2*this.paddingInPixels},i.imageHeight.get=function(){return this.textBoxHeight+this.lineWidth+2*this.padding},i.imageHeightInPixels.get=function(){return this.imageHeight*this.fontSize},i.imageAspect.get=function(){return this.image.width&&this.image.height?this.image.width/this.image.height:1},Object.defineProperties(t.prototype,i),t}(m.Texture)});
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("three")):"function"==typeof define&&define.amd?define(["three"],i):(t.THREE=t.THREE||{},t.THREE.TextTexture=i(t.THREE))}(this,function(S){"use strict";function b(){return document.createElement("canvas")}function e(t){return void 0===t}function n(t,i){if(t.length){var e=b().getContext("2d");return e.font=i,function(t){if(0<t.length)return t.reduce(function(t,i){return Math.max(t,i)})}(t.map(function(t){return e.measureText(t).width}))}return 0}return function(P){function t(t){void 0===t&&(t={});var i=t.autoRedraw;void 0===i&&(i=!0);var e=t.pixelRatio;void 0===e&&(e=1);var n=t.text;void 0===n&&(n="");var s=t.textAlign;void 0===s&&(s="center");var h=t.textLineHeight;void 0===h&&(h=1.15);var o=t.fontFamily;void 0===o&&(o="sans-serif");var r=t.fontSize;void 0===r&&(r=16);var l=t.fontWeight;void 0===l&&(l="normal");var a=t.fontVariant;void 0===a&&(a="normal");var f=t.fontStyle;void 0===f&&(f="normal");var g=t.fillStyle;void 0===g&&(g="white");var d=t.lineWidth;void 0===d&&(d=0);var u=t.strokeStyle;void 0===u&&(u="black");var x=t.padding;void 0===x&&(x=.25);var c=t.magFilter;void 0===c&&(c=S.LinearFilter);var _=t.minFilter;void 0===_&&(_=S.LinearFilter);var p=t.mapping,v=t.wrapS,I=t.wrapT,y=t.format,W=t.type,m=t.anisotropy;P.call(this,b(),p,v,I,c,_,y,W,m),this.autoRedraw=i,this._pixelRatio=e,this._text=n,this._textAlign=s,this._textLineHeight=h,this._fontFamily=o,this._fontSize=r,this._fontWeight=l,this._fontVariant=a,this._fontStyle=f,this._fillStyle=g,this._lineWidth=d,this._strokeStyle=u,this._padding=x,this.redraw()}P&&(t.__proto__=P);var i={pixelRatio:{configurable:!0},text:{configurable:!0},textAlign:{configurable:!0},textLines:{configurable:!0},textLineHeight:{configurable:!0},textLineHeightInPixels:{configurable:!0},fontFamily:{configurable:!0},fontSize:{configurable:!0},fontWeight:{configurable:!0},fontVariant:{configurable:!0},fontStyle:{configurable:!0},font:{configurable:!0},fillStyle:{configurable:!0},lineWidth:{configurable:!0},lineWidthInPixels:{configurable:!0},strokeStyle:{configurable:!0},textWidthInPixels:{configurable:!0},textHeight:{configurable:!0},textHeightInPixels:{configurable:!0},padding:{configurable:!0},paddingInPixels:{configurable:!0},imageWidthInPixels:{configurable:!0},imageHeight:{configurable:!0},imageHeightInPixels:{configurable:!0},imageAspect:{configurable:!0}};return((t.prototype=Object.create(P&&P.prototype)).constructor=t).prototype.redraw=function(){var i=this,e=this.image.getContext("2d");if(e.clearRect(0,0,e.canvas.width,e.canvas.height),this.textWidthInPixels&&this.textHeightInPixels){var n;switch(e.canvas.width=this.imageWidthInPixels*this.pixelRatio,e.canvas.height=this.imageHeightInPixels*this.pixelRatio,e.canvas.style.width=this.imageWidthInPixels+"px",e.canvas.style.height=this.imageHeightInPixels+"px",e.scale(this.pixelRatio,this.pixelRatio),e.font=this.font,e.textBaseline="middle",this.textAlign){case"left":e.textAlign="left",n=this.paddingInPixels+this.lineWidthInPixels/2;break;case"right":e.textAlign="right",n=this.paddingInPixels+this.lineWidthInPixels/2+this.textWidthInPixels;break;case"center":e.textAlign="center",n=this.paddingInPixels+this.lineWidthInPixels/4+this.textWidthInPixels/2}var s=this.paddingInPixels+this.lineWidthInPixels/2+this.fontSize/2;e.fillStyle=this.fillStyle,e.miterLimit=1,e.lineWidth=this.lineWidthInPixels,e.strokeStyle=this.strokeStyle,this.textLines.forEach(function(t){i.lineWidth&&e.strokeText(t,n,s),e.fillText(t,n,s),s+=i.textLineHeightInPixels})}else e.canvas.width=e.canvas.height=1;this.needsUpdate=!0},t.prototype._redrawIfAuto=function(){this.autoRedraw&&this.redraw()},i.pixelRatio.get=function(){return this._pixelRatio},i.pixelRatio.set=function(t){this._pixelRatio!==t&&(this._pixelRatio=t,this._redrawIfAuto())},i.text.get=function(){return this._text},i.text.set=function(t){this._text!==t&&(this._text=t,this._textLines=void 0,this._textWidthInPixels=void 0,this._redrawIfAuto())},i.textAlign.get=function(){return this._textAlign},i.textAlign.set=function(t){this._textAlign!==t&&(this._textAlign=t,this._redrawIfAuto())},i.textLines.get=function(){var t;return e(this._textLines)&&(this._textLines=(t=this.text)?t.split("\n"):[]),this._textLines},i.textLineHeight.get=function(){return this._textLineHeight},i.textLineHeight.set=function(t){this._textLineHeight!==t&&(this._textLineHeight=t,this._redrawIfAuto())},i.textLineHeightInPixels.get=function(){return this.fontSize*this.textLineHeight},i.fontFamily.get=function(){return this._fontFamily},i.fontFamily.set=function(t){this._fontFamily!==t&&(this._fontFamily=t,this._textWidthInPixels=void 0,this._redrawIfAuto())},i.fontSize.get=function(){return this._fontSize},i.fontSize.set=function(t){this._fontSize!==t&&(this._fontSize=t,this._textWidthInPixels=void 0,this._redrawIfAuto())},i.fontWeight.get=function(){return this._fontWeight},i.fontWeight.set=function(t){this._fontWeight!==t&&(this._fontWeight=t,this._textWidthInPixels=void 0,this._redrawIfAuto())},i.fontVariant.get=function(){return this._fontVariant},i.fontVariant.set=function(t){this._fontVariant!==t&&(this._fontVariant=t,this._textWidthInPixels=void 0,this._redrawIfAuto())},i.fontStyle.get=function(){return this._fontStyle},i.fontStyle.set=function(t){this._fontStyle!==t&&(this._fontStyle=t,this._textWidthInPixels=void 0,this._redrawIfAuto())},i.font.get=function(){return t=this.fontStyle,i=this.fontVariant,e=this.fontWeight,n=this.fontSize,s=this.fontFamily,[t,i,e,n+"px",s].join(" ");var t,i,e,n,s},i.fillStyle.get=function(){return this._fillStyle},i.fillStyle.set=function(t){this._fillStyle!==t&&(this._fillStyle=t,this._redrawIfAuto())},i.lineWidth.get=function(){return this._lineWidth},i.lineWidth.set=function(t){this._lineWidth!==t&&(this._lineWidth=t,this._redrawIfAuto())},i.lineWidthInPixels.get=function(){return this._lineWidth*this.fontSize},i.strokeStyle.get=function(){return this._strokeStyle},i.strokeStyle.set=function(t){this._strokeStyle!==t&&(this._strokeStyle=t,this._redrawIfAuto())},i.textWidthInPixels.get=function(){return e(this._textWidthInPixels)&&(this._textWidthInPixels=n(this.textLines,this.font)),this._textWidthInPixels},i.textHeight.get=function(){return this.textLineHeight*(this.textLines.length-1)+1},i.textHeightInPixels.get=function(){return this.textHeight*this.fontSize},i.padding.get=function(){return this._padding},i.padding.set=function(t){this._padding!==t&&(this._padding=t,this._redrawIfAuto())},i.paddingInPixels.get=function(){return this.padding*this.fontSize},i.imageWidthInPixels.get=function(){return this.textWidthInPixels+this.lineWidthInPixels+2*this.paddingInPixels},i.imageHeight.get=function(){return this.textHeight+this.lineWidth+2*this.padding},i.imageHeightInPixels.get=function(){return this.imageHeight*this.fontSize},i.imageAspect.get=function(){return this.image.width&&this.image.height?this.image.width/this.image.height:1},Object.defineProperties(t.prototype,i),t}(S.Texture)});
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