@tsparticles/shape-image
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -1,1 +0,11 @@ | ||
export {}; | ||
export var DisposalMethod; | ||
(function (DisposalMethod) { | ||
DisposalMethod[DisposalMethod["Replace"] = 0] = "Replace"; | ||
DisposalMethod[DisposalMethod["Combine"] = 1] = "Combine"; | ||
DisposalMethod[DisposalMethod["RestoreBackground"] = 2] = "RestoreBackground"; | ||
DisposalMethod[DisposalMethod["RestorePrevious"] = 3] = "RestorePrevious"; | ||
DisposalMethod[DisposalMethod["UndefinedA"] = 4] = "UndefinedA"; | ||
DisposalMethod[DisposalMethod["UndefinedB"] = 5] = "UndefinedB"; | ||
DisposalMethod[DisposalMethod["UndefinedC"] = 6] = "UndefinedC"; | ||
DisposalMethod[DisposalMethod["UndefinedD"] = 7] = "UndefinedD"; | ||
})(DisposalMethod || (DisposalMethod = {})); |
@@ -1,1 +0,10 @@ | ||
export {}; | ||
export var GIFDataHeaders; | ||
(function (GIFDataHeaders) { | ||
GIFDataHeaders[GIFDataHeaders["Extension"] = 33] = "Extension"; | ||
GIFDataHeaders[GIFDataHeaders["ApplicationExtension"] = 255] = "ApplicationExtension"; | ||
GIFDataHeaders[GIFDataHeaders["GraphicsControlExtension"] = 249] = "GraphicsControlExtension"; | ||
GIFDataHeaders[GIFDataHeaders["PlainTextExtension"] = 1] = "PlainTextExtension"; | ||
GIFDataHeaders[GIFDataHeaders["CommentExtension"] = 254] = "CommentExtension"; | ||
GIFDataHeaders[GIFDataHeaders["Image"] = 44] = "Image"; | ||
GIFDataHeaders[GIFDataHeaders["EndOfFile"] = 59] = "EndOfFile"; | ||
})(GIFDataHeaders || (GIFDataHeaders = {})); |
@@ -0,3 +1,6 @@ | ||
import { loadImage } from "../Utils.js"; | ||
import { InterlaceOffsets, InterlaceSteps } from "./Constants.js"; | ||
import { ByteStream } from "./ByteStream.js"; | ||
import { DisposalMethod } from "./Enums/DisposalMethod.js"; | ||
import { GIFDataHeaders } from "./Types/GIFDataHeaders.js"; | ||
const origin = { | ||
@@ -21,3 +24,3 @@ x: 0, | ||
switch (byteStream.nextByte()) { | ||
case 249: { | ||
case GIFDataHeaders.GraphicsControlExtension: { | ||
const frame = gif.frames[getFrameIndex(false)]; | ||
@@ -38,3 +41,3 @@ byteStream.pos++; | ||
} | ||
case 255: { | ||
case GIFDataHeaders.ApplicationExtension: { | ||
byteStream.pos++; | ||
@@ -49,7 +52,7 @@ const applicationExtension = { | ||
} | ||
case 254: { | ||
case GIFDataHeaders.CommentExtension: { | ||
gif.comments.push([getFrameIndex(false), byteStream.readSubBlocks()]); | ||
break; | ||
} | ||
case 1: { | ||
case GIFDataHeaders.PlainTextExtension: { | ||
if (gif.globalColorTable.length === 0) { | ||
@@ -207,8 +210,8 @@ throw new EvalError("plain text extension without global color table"); | ||
switch (byteStream.nextByte()) { | ||
case 59: | ||
case GIFDataHeaders.EndOfFile: | ||
return true; | ||
case 44: | ||
case GIFDataHeaders.Image: | ||
await parseImageBlock(byteStream, gif, avgAlpha, getFrameIndex, getTransparencyIndex, progressCallback); | ||
break; | ||
case 33: | ||
case GIFDataHeaders.Extension: | ||
parseExtensionBlock(byteStream, gif, getFrameIndex, getTransparencyIndex); | ||
@@ -308,3 +311,3 @@ break; | ||
height: 0, | ||
disposalMethod: 0, | ||
disposalMethod: DisposalMethod.Replace, | ||
image: new ImageData(1, 1, { colorSpace: "srgb" }), | ||
@@ -366,7 +369,7 @@ plainTextData: null, | ||
switch (frame.disposalMethod) { | ||
case 4: | ||
case 5: | ||
case 6: | ||
case 7: | ||
case 0: | ||
case DisposalMethod.UndefinedA: | ||
case DisposalMethod.UndefinedB: | ||
case DisposalMethod.UndefinedC: | ||
case DisposalMethod.UndefinedD: | ||
case DisposalMethod.Replace: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
@@ -376,7 +379,7 @@ context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 1: | ||
case DisposalMethod.Combine: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 2: | ||
case DisposalMethod.RestoreBackground: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
@@ -392,3 +395,3 @@ context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 3: | ||
case DisposalMethod.RestorePrevious: | ||
{ | ||
@@ -419,3 +422,2 @@ const previousImageData = offscreenContext.getImageData(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height); | ||
if (image.type !== "gif") { | ||
const { loadImage } = await import("../Utils.js"); | ||
await loadImage(image); | ||
@@ -422,0 +424,0 @@ return; |
@@ -7,2 +7,3 @@ import { errorPrefix } from "@tsparticles/engine"; | ||
constructor(engine) { | ||
this.validTypes = ["image", "images"]; | ||
this.loadImageShape = async (imageShape) => { | ||
@@ -9,0 +10,0 @@ if (!this._engine.loadImage) { |
@@ -20,3 +20,3 @@ import { Preload } from "./Options/Classes/Preload.js"; | ||
for (const item of source.preload) { | ||
const existing = preloadOptions.find((t) => t.name === item.name || t.src === item.src); | ||
const existing = preloadOptions.find(t => t.name === item.name || t.src === item.src); | ||
if (existing) { | ||
@@ -23,0 +23,0 @@ existing.load(item); |
import { downloadSvgImage, loadImage } from "./Utils.js"; | ||
import { ImageDrawer } from "./ImageDrawer.js"; | ||
import { ImagePreloaderPlugin } from "./ImagePreloader.js"; | ||
import { errorPrefix } from "@tsparticles/engine"; | ||
import { loadGifImage } from "./GifUtils/Utils.js"; | ||
const extLength = 3; | ||
@@ -32,3 +35,2 @@ function addLoadImageToEngine(engine) { | ||
if (data.gif) { | ||
const { loadGifImage } = await import("./GifUtils/Utils.js"); | ||
imageFunc = loadGifImage; | ||
@@ -48,6 +50,5 @@ } | ||
addLoadImageToEngine(engine); | ||
const { ImagePreloaderPlugin } = await import("./ImagePreloader.js"), { ImageDrawer } = await import("./ImageDrawer.js"); | ||
const preloader = new ImagePreloaderPlugin(engine); | ||
await engine.addPlugin(preloader, refresh); | ||
await engine.addShape(["image", "images"], new ImageDrawer(engine), refresh); | ||
await engine.addShape(new ImageDrawer(engine), refresh); | ||
} |
@@ -64,3 +64,3 @@ import { errorPrefix, getLogger, getStyleFromHsl } from "@tsparticles/engine"; | ||
}; | ||
return new Promise((resolve) => { | ||
return new Promise(resolve => { | ||
const svg = new Blob([svgColoredData], { type: "image/svg+xml" }), domUrl = URL || window.URL || window.webkitURL || window, url = domUrl.createObjectURL(svg), img = new Image(); | ||
@@ -67,0 +67,0 @@ img.addEventListener("load", () => { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DisposalMethod = void 0; | ||
var DisposalMethod; | ||
(function (DisposalMethod) { | ||
DisposalMethod[DisposalMethod["Replace"] = 0] = "Replace"; | ||
DisposalMethod[DisposalMethod["Combine"] = 1] = "Combine"; | ||
DisposalMethod[DisposalMethod["RestoreBackground"] = 2] = "RestoreBackground"; | ||
DisposalMethod[DisposalMethod["RestorePrevious"] = 3] = "RestorePrevious"; | ||
DisposalMethod[DisposalMethod["UndefinedA"] = 4] = "UndefinedA"; | ||
DisposalMethod[DisposalMethod["UndefinedB"] = 5] = "UndefinedB"; | ||
DisposalMethod[DisposalMethod["UndefinedC"] = 6] = "UndefinedC"; | ||
DisposalMethod[DisposalMethod["UndefinedD"] = 7] = "UndefinedD"; | ||
})(DisposalMethod || (exports.DisposalMethod = DisposalMethod = {})); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GIFDataHeaders = void 0; | ||
var GIFDataHeaders; | ||
(function (GIFDataHeaders) { | ||
GIFDataHeaders[GIFDataHeaders["Extension"] = 33] = "Extension"; | ||
GIFDataHeaders[GIFDataHeaders["ApplicationExtension"] = 255] = "ApplicationExtension"; | ||
GIFDataHeaders[GIFDataHeaders["GraphicsControlExtension"] = 249] = "GraphicsControlExtension"; | ||
GIFDataHeaders[GIFDataHeaders["PlainTextExtension"] = 1] = "PlainTextExtension"; | ||
GIFDataHeaders[GIFDataHeaders["CommentExtension"] = 254] = "CommentExtension"; | ||
GIFDataHeaders[GIFDataHeaders["Image"] = 44] = "Image"; | ||
GIFDataHeaders[GIFDataHeaders["EndOfFile"] = 59] = "EndOfFile"; | ||
})(GIFDataHeaders || (exports.GIFDataHeaders = GIFDataHeaders = {})); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadGifImage = exports.drawGif = exports.decodeGIF = exports.getGIFLoopAmount = void 0; | ||
const Utils_js_1 = require("../Utils.js"); | ||
const Constants_js_1 = require("./Constants.js"); | ||
const ByteStream_js_1 = require("./ByteStream.js"); | ||
const DisposalMethod_js_1 = require("./Enums/DisposalMethod.js"); | ||
const GIFDataHeaders_js_1 = require("./Types/GIFDataHeaders.js"); | ||
const origin = { | ||
@@ -24,3 +27,3 @@ x: 0, | ||
switch (byteStream.nextByte()) { | ||
case 249: { | ||
case GIFDataHeaders_js_1.GIFDataHeaders.GraphicsControlExtension: { | ||
const frame = gif.frames[getFrameIndex(false)]; | ||
@@ -41,3 +44,3 @@ byteStream.pos++; | ||
} | ||
case 255: { | ||
case GIFDataHeaders_js_1.GIFDataHeaders.ApplicationExtension: { | ||
byteStream.pos++; | ||
@@ -52,7 +55,7 @@ const applicationExtension = { | ||
} | ||
case 254: { | ||
case GIFDataHeaders_js_1.GIFDataHeaders.CommentExtension: { | ||
gif.comments.push([getFrameIndex(false), byteStream.readSubBlocks()]); | ||
break; | ||
} | ||
case 1: { | ||
case GIFDataHeaders_js_1.GIFDataHeaders.PlainTextExtension: { | ||
if (gif.globalColorTable.length === 0) { | ||
@@ -210,8 +213,8 @@ throw new EvalError("plain text extension without global color table"); | ||
switch (byteStream.nextByte()) { | ||
case 59: | ||
case GIFDataHeaders_js_1.GIFDataHeaders.EndOfFile: | ||
return true; | ||
case 44: | ||
case GIFDataHeaders_js_1.GIFDataHeaders.Image: | ||
await parseImageBlock(byteStream, gif, avgAlpha, getFrameIndex, getTransparencyIndex, progressCallback); | ||
break; | ||
case 33: | ||
case GIFDataHeaders_js_1.GIFDataHeaders.Extension: | ||
parseExtensionBlock(byteStream, gif, getFrameIndex, getTransparencyIndex); | ||
@@ -312,3 +315,3 @@ break; | ||
height: 0, | ||
disposalMethod: 0, | ||
disposalMethod: DisposalMethod_js_1.DisposalMethod.Replace, | ||
image: new ImageData(1, 1, { colorSpace: "srgb" }), | ||
@@ -371,7 +374,7 @@ plainTextData: null, | ||
switch (frame.disposalMethod) { | ||
case 4: | ||
case 5: | ||
case 6: | ||
case 7: | ||
case 0: | ||
case DisposalMethod_js_1.DisposalMethod.UndefinedA: | ||
case DisposalMethod_js_1.DisposalMethod.UndefinedB: | ||
case DisposalMethod_js_1.DisposalMethod.UndefinedC: | ||
case DisposalMethod_js_1.DisposalMethod.UndefinedD: | ||
case DisposalMethod_js_1.DisposalMethod.Replace: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
@@ -381,7 +384,7 @@ context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 1: | ||
case DisposalMethod_js_1.DisposalMethod.Combine: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 2: | ||
case DisposalMethod_js_1.DisposalMethod.RestoreBackground: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
@@ -397,3 +400,3 @@ context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 3: | ||
case DisposalMethod_js_1.DisposalMethod.RestorePrevious: | ||
{ | ||
@@ -425,4 +428,3 @@ const previousImageData = offscreenContext.getImageData(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height); | ||
if (image.type !== "gif") { | ||
const { loadImage } = await import("../Utils.js"); | ||
await loadImage(image); | ||
await (0, Utils_js_1.loadImage)(image); | ||
return; | ||
@@ -429,0 +431,0 @@ } |
@@ -10,2 +10,3 @@ "use strict"; | ||
constructor(engine) { | ||
this.validTypes = ["image", "images"]; | ||
this.loadImageShape = async (imageShape) => { | ||
@@ -12,0 +13,0 @@ if (!this._engine.loadImage) { |
@@ -23,3 +23,3 @@ "use strict"; | ||
for (const item of source.preload) { | ||
const existing = preloadOptions.find((t) => t.name === item.name || t.src === item.src); | ||
const existing = preloadOptions.find(t => t.name === item.name || t.src === item.src); | ||
if (existing) { | ||
@@ -26,0 +26,0 @@ existing.load(item); |
@@ -5,3 +5,6 @@ "use strict"; | ||
const Utils_js_1 = require("./Utils.js"); | ||
const ImageDrawer_js_1 = require("./ImageDrawer.js"); | ||
const ImagePreloader_js_1 = require("./ImagePreloader.js"); | ||
const engine_1 = require("@tsparticles/engine"); | ||
const Utils_js_2 = require("./GifUtils/Utils.js"); | ||
const extLength = 3; | ||
@@ -36,4 +39,3 @@ function addLoadImageToEngine(engine) { | ||
if (data.gif) { | ||
const { loadGifImage } = await import("./GifUtils/Utils.js"); | ||
imageFunc = loadGifImage; | ||
imageFunc = Utils_js_2.loadGifImage; | ||
} | ||
@@ -52,7 +54,6 @@ else { | ||
addLoadImageToEngine(engine); | ||
const { ImagePreloaderPlugin } = await import("./ImagePreloader.js"), { ImageDrawer } = await import("./ImageDrawer.js"); | ||
const preloader = new ImagePreloaderPlugin(engine); | ||
const preloader = new ImagePreloader_js_1.ImagePreloaderPlugin(engine); | ||
await engine.addPlugin(preloader, refresh); | ||
await engine.addShape(["image", "images"], new ImageDrawer(engine), refresh); | ||
await engine.addShape(new ImageDrawer_js_1.ImageDrawer(engine), refresh); | ||
} | ||
exports.loadImageShape = loadImageShape; |
@@ -69,3 +69,3 @@ "use strict"; | ||
}; | ||
return new Promise((resolve) => { | ||
return new Promise(resolve => { | ||
const svg = new Blob([svgColoredData], { type: "image/svg+xml" }), domUrl = URL || window.URL || window.webkitURL || window, url = domUrl.createObjectURL(svg), img = new Image(); | ||
@@ -72,0 +72,0 @@ img.addEventListener("load", () => { |
@@ -1,1 +0,11 @@ | ||
export {}; | ||
export var DisposalMethod; | ||
(function (DisposalMethod) { | ||
DisposalMethod[DisposalMethod["Replace"] = 0] = "Replace"; | ||
DisposalMethod[DisposalMethod["Combine"] = 1] = "Combine"; | ||
DisposalMethod[DisposalMethod["RestoreBackground"] = 2] = "RestoreBackground"; | ||
DisposalMethod[DisposalMethod["RestorePrevious"] = 3] = "RestorePrevious"; | ||
DisposalMethod[DisposalMethod["UndefinedA"] = 4] = "UndefinedA"; | ||
DisposalMethod[DisposalMethod["UndefinedB"] = 5] = "UndefinedB"; | ||
DisposalMethod[DisposalMethod["UndefinedC"] = 6] = "UndefinedC"; | ||
DisposalMethod[DisposalMethod["UndefinedD"] = 7] = "UndefinedD"; | ||
})(DisposalMethod || (DisposalMethod = {})); |
@@ -1,1 +0,10 @@ | ||
export {}; | ||
export var GIFDataHeaders; | ||
(function (GIFDataHeaders) { | ||
GIFDataHeaders[GIFDataHeaders["Extension"] = 33] = "Extension"; | ||
GIFDataHeaders[GIFDataHeaders["ApplicationExtension"] = 255] = "ApplicationExtension"; | ||
GIFDataHeaders[GIFDataHeaders["GraphicsControlExtension"] = 249] = "GraphicsControlExtension"; | ||
GIFDataHeaders[GIFDataHeaders["PlainTextExtension"] = 1] = "PlainTextExtension"; | ||
GIFDataHeaders[GIFDataHeaders["CommentExtension"] = 254] = "CommentExtension"; | ||
GIFDataHeaders[GIFDataHeaders["Image"] = 44] = "Image"; | ||
GIFDataHeaders[GIFDataHeaders["EndOfFile"] = 59] = "EndOfFile"; | ||
})(GIFDataHeaders || (GIFDataHeaders = {})); |
@@ -0,3 +1,6 @@ | ||
import { loadImage } from "../Utils.js"; | ||
import { InterlaceOffsets, InterlaceSteps } from "./Constants.js"; | ||
import { ByteStream } from "./ByteStream.js"; | ||
import { DisposalMethod } from "./Enums/DisposalMethod.js"; | ||
import { GIFDataHeaders } from "./Types/GIFDataHeaders.js"; | ||
const origin = { | ||
@@ -21,3 +24,3 @@ x: 0, | ||
switch (byteStream.nextByte()) { | ||
case 249: { | ||
case GIFDataHeaders.GraphicsControlExtension: { | ||
const frame = gif.frames[getFrameIndex(false)]; | ||
@@ -38,3 +41,3 @@ byteStream.pos++; | ||
} | ||
case 255: { | ||
case GIFDataHeaders.ApplicationExtension: { | ||
byteStream.pos++; | ||
@@ -49,7 +52,7 @@ const applicationExtension = { | ||
} | ||
case 254: { | ||
case GIFDataHeaders.CommentExtension: { | ||
gif.comments.push([getFrameIndex(false), byteStream.readSubBlocks()]); | ||
break; | ||
} | ||
case 1: { | ||
case GIFDataHeaders.PlainTextExtension: { | ||
if (gif.globalColorTable.length === 0) { | ||
@@ -207,8 +210,8 @@ throw new EvalError("plain text extension without global color table"); | ||
switch (byteStream.nextByte()) { | ||
case 59: | ||
case GIFDataHeaders.EndOfFile: | ||
return true; | ||
case 44: | ||
case GIFDataHeaders.Image: | ||
await parseImageBlock(byteStream, gif, avgAlpha, getFrameIndex, getTransparencyIndex, progressCallback); | ||
break; | ||
case 33: | ||
case GIFDataHeaders.Extension: | ||
parseExtensionBlock(byteStream, gif, getFrameIndex, getTransparencyIndex); | ||
@@ -308,3 +311,3 @@ break; | ||
height: 0, | ||
disposalMethod: 0, | ||
disposalMethod: DisposalMethod.Replace, | ||
image: new ImageData(1, 1, { colorSpace: "srgb" }), | ||
@@ -366,7 +369,7 @@ plainTextData: null, | ||
switch (frame.disposalMethod) { | ||
case 4: | ||
case 5: | ||
case 6: | ||
case 7: | ||
case 0: | ||
case DisposalMethod.UndefinedA: | ||
case DisposalMethod.UndefinedB: | ||
case DisposalMethod.UndefinedC: | ||
case DisposalMethod.UndefinedD: | ||
case DisposalMethod.Replace: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
@@ -376,7 +379,7 @@ context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 1: | ||
case DisposalMethod.Combine: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 2: | ||
case DisposalMethod.RestoreBackground: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
@@ -392,3 +395,3 @@ context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 3: | ||
case DisposalMethod.RestorePrevious: | ||
{ | ||
@@ -419,3 +422,2 @@ const previousImageData = offscreenContext.getImageData(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height); | ||
if (image.type !== "gif") { | ||
const { loadImage } = await import("../Utils.js"); | ||
await loadImage(image); | ||
@@ -422,0 +424,0 @@ return; |
@@ -7,2 +7,3 @@ import { errorPrefix } from "@tsparticles/engine"; | ||
constructor(engine) { | ||
this.validTypes = ["image", "images"]; | ||
this.loadImageShape = async (imageShape) => { | ||
@@ -9,0 +10,0 @@ if (!this._engine.loadImage) { |
@@ -20,3 +20,3 @@ import { Preload } from "./Options/Classes/Preload.js"; | ||
for (const item of source.preload) { | ||
const existing = preloadOptions.find((t) => t.name === item.name || t.src === item.src); | ||
const existing = preloadOptions.find(t => t.name === item.name || t.src === item.src); | ||
if (existing) { | ||
@@ -23,0 +23,0 @@ existing.load(item); |
import { downloadSvgImage, loadImage } from "./Utils.js"; | ||
import { ImageDrawer } from "./ImageDrawer.js"; | ||
import { ImagePreloaderPlugin } from "./ImagePreloader.js"; | ||
import { errorPrefix } from "@tsparticles/engine"; | ||
import { loadGifImage } from "./GifUtils/Utils.js"; | ||
const extLength = 3; | ||
@@ -32,3 +35,2 @@ function addLoadImageToEngine(engine) { | ||
if (data.gif) { | ||
const { loadGifImage } = await import("./GifUtils/Utils.js"); | ||
imageFunc = loadGifImage; | ||
@@ -48,6 +50,5 @@ } | ||
addLoadImageToEngine(engine); | ||
const { ImagePreloaderPlugin } = await import("./ImagePreloader.js"), { ImageDrawer } = await import("./ImageDrawer.js"); | ||
const preloader = new ImagePreloaderPlugin(engine); | ||
await engine.addPlugin(preloader, refresh); | ||
await engine.addShape(["image", "images"], new ImageDrawer(engine), refresh); | ||
await engine.addShape(new ImageDrawer(engine), refresh); | ||
} |
@@ -64,3 +64,3 @@ import { errorPrefix, getLogger, getStyleFromHsl } from "@tsparticles/engine"; | ||
}; | ||
return new Promise((resolve) => { | ||
return new Promise(resolve => { | ||
const svg = new Blob([svgColoredData], { type: "image/svg+xml" }), domUrl = URL || window.URL || window.webkitURL || window, url = domUrl.createObjectURL(svg), img = new Image(); | ||
@@ -67,0 +67,0 @@ img.addEventListener("load", () => { |
{ | ||
"name": "@tsparticles/shape-image", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "tsParticles image shape", | ||
@@ -62,3 +62,3 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"@tsparticles/engine": "^3.3.0" | ||
"@tsparticles/engine": "^3.4.0" | ||
}, | ||
@@ -65,0 +65,0 @@ "publishConfig": { |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v3.3.0 | ||
* v3.4.0 | ||
*/ | ||
@@ -32,2 +32,82 @@ /* | ||
/***/ "./dist/browser/GifUtils/ByteStream.js": | ||
/*!*********************************************!*\ | ||
!*** ./dist/browser/GifUtils/ByteStream.js ***! | ||
\*********************************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ByteStream: () => (/* binding */ ByteStream)\n/* harmony export */ });\nclass ByteStream {\n constructor(bytes) {\n this.pos = 0;\n this.data = new Uint8ClampedArray(bytes);\n }\n getString(count) {\n const slice = this.data.slice(this.pos, this.pos + count);\n this.pos += slice.length;\n return slice.reduce((acc, curr) => acc + String.fromCharCode(curr), \"\");\n }\n nextByte() {\n return this.data[this.pos++];\n }\n nextTwoBytes() {\n const increment = 2,\n previous = 1,\n shift = 8;\n this.pos += increment;\n return this.data[this.pos - increment] + (this.data[this.pos - previous] << shift);\n }\n readSubBlocks() {\n let blockString = \"\",\n size = 0;\n const minCount = 0,\n emptySize = 0;\n do {\n size = this.data[this.pos++];\n for (let count = size; --count >= minCount; blockString += String.fromCharCode(this.data[this.pos++])) {}\n } while (size !== emptySize);\n return blockString;\n }\n readSubBlocksBin() {\n let size = this.data[this.pos],\n len = 0;\n const emptySize = 0,\n increment = 1;\n for (let offset = 0; size !== emptySize; offset += size + increment, size = this.data[this.pos + offset]) {\n len += size;\n }\n const blockData = new Uint8Array(len);\n size = this.data[this.pos++];\n for (let i = 0; size !== emptySize; size = this.data[this.pos++]) {\n for (let count = size; --count >= emptySize; blockData[i++] = this.data[this.pos++]) {}\n }\n return blockData;\n }\n skipSubBlocks() {\n for (const increment = 1, noData = 0; this.data[this.pos] !== noData; this.pos += this.data[this.pos] + increment) {}\n this.pos++;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/GifUtils/ByteStream.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/GifUtils/Constants.js": | ||
/*!********************************************!*\ | ||
!*** ./dist/browser/GifUtils/Constants.js ***! | ||
\********************************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InterlaceOffsets: () => (/* binding */ InterlaceOffsets),\n/* harmony export */ InterlaceSteps: () => (/* binding */ InterlaceSteps)\n/* harmony export */ });\nconst InterlaceOffsets = [0, 4, 2, 1];\nconst InterlaceSteps = [8, 8, 4, 2];\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/GifUtils/Constants.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/GifUtils/Enums/DisposalMethod.js": | ||
/*!*******************************************************!*\ | ||
!*** ./dist/browser/GifUtils/Enums/DisposalMethod.js ***! | ||
\*******************************************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DisposalMethod: () => (/* binding */ DisposalMethod)\n/* harmony export */ });\nvar DisposalMethod;\n(function (DisposalMethod) {\n DisposalMethod[DisposalMethod[\"Replace\"] = 0] = \"Replace\";\n DisposalMethod[DisposalMethod[\"Combine\"] = 1] = \"Combine\";\n DisposalMethod[DisposalMethod[\"RestoreBackground\"] = 2] = \"RestoreBackground\";\n DisposalMethod[DisposalMethod[\"RestorePrevious\"] = 3] = \"RestorePrevious\";\n DisposalMethod[DisposalMethod[\"UndefinedA\"] = 4] = \"UndefinedA\";\n DisposalMethod[DisposalMethod[\"UndefinedB\"] = 5] = \"UndefinedB\";\n DisposalMethod[DisposalMethod[\"UndefinedC\"] = 6] = \"UndefinedC\";\n DisposalMethod[DisposalMethod[\"UndefinedD\"] = 7] = \"UndefinedD\";\n})(DisposalMethod || (DisposalMethod = {}));\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/GifUtils/Enums/DisposalMethod.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/GifUtils/Types/GIFDataHeaders.js": | ||
/*!*******************************************************!*\ | ||
!*** ./dist/browser/GifUtils/Types/GIFDataHeaders.js ***! | ||
\*******************************************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ GIFDataHeaders: () => (/* binding */ GIFDataHeaders)\n/* harmony export */ });\nvar GIFDataHeaders;\n(function (GIFDataHeaders) {\n GIFDataHeaders[GIFDataHeaders[\"Extension\"] = 33] = \"Extension\";\n GIFDataHeaders[GIFDataHeaders[\"ApplicationExtension\"] = 255] = \"ApplicationExtension\";\n GIFDataHeaders[GIFDataHeaders[\"GraphicsControlExtension\"] = 249] = \"GraphicsControlExtension\";\n GIFDataHeaders[GIFDataHeaders[\"PlainTextExtension\"] = 1] = \"PlainTextExtension\";\n GIFDataHeaders[GIFDataHeaders[\"CommentExtension\"] = 254] = \"CommentExtension\";\n GIFDataHeaders[GIFDataHeaders[\"Image\"] = 44] = \"Image\";\n GIFDataHeaders[GIFDataHeaders[\"EndOfFile\"] = 59] = \"EndOfFile\";\n})(GIFDataHeaders || (GIFDataHeaders = {}));\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/GifUtils/Types/GIFDataHeaders.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/GifUtils/Utils.js": | ||
/*!****************************************!*\ | ||
!*** ./dist/browser/GifUtils/Utils.js ***! | ||
\****************************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ decodeGIF: () => (/* binding */ decodeGIF),\n/* harmony export */ drawGif: () => (/* binding */ drawGif),\n/* harmony export */ getGIFLoopAmount: () => (/* binding */ getGIFLoopAmount),\n/* harmony export */ loadGifImage: () => (/* binding */ loadGifImage)\n/* harmony export */ });\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ \"./dist/browser/GifUtils/Constants.js\");\n/* harmony import */ var _ByteStream_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ByteStream.js */ \"./dist/browser/GifUtils/ByteStream.js\");\n/* harmony import */ var _Enums_DisposalMethod_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Enums/DisposalMethod.js */ \"./dist/browser/GifUtils/Enums/DisposalMethod.js\");\n/* harmony import */ var _Types_GIFDataHeaders_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Types/GIFDataHeaders.js */ \"./dist/browser/GifUtils/Types/GIFDataHeaders.js\");\n\n\n\n\n\nconst origin = {\n x: 0,\n y: 0\n },\n defaultFrame = 0,\n half = 0.5,\n initialTime = 0,\n firstIndex = 0,\n defaultLoopCount = 0;\nfunction parseColorTable(byteStream, count) {\n const colors = [];\n for (let i = 0; i < count; i++) {\n colors.push({\n r: byteStream.data[byteStream.pos],\n g: byteStream.data[byteStream.pos + 1],\n b: byteStream.data[byteStream.pos + 2]\n });\n byteStream.pos += 3;\n }\n return colors;\n}\nfunction parseExtensionBlock(byteStream, gif, getFrameIndex, getTransparencyIndex) {\n switch (byteStream.nextByte()) {\n case _Types_GIFDataHeaders_js__WEBPACK_IMPORTED_MODULE_0__.GIFDataHeaders.GraphicsControlExtension:\n {\n const frame = gif.frames[getFrameIndex(false)];\n byteStream.pos++;\n const packedByte = byteStream.nextByte();\n frame.GCreserved = (packedByte & 0xe0) >>> 5;\n frame.disposalMethod = (packedByte & 0x1c) >>> 2;\n frame.userInputDelayFlag = (packedByte & 2) === 2;\n const transparencyFlag = (packedByte & 1) === 1;\n frame.delayTime = byteStream.nextTwoBytes() * 0xa;\n const transparencyIndex = byteStream.nextByte();\n if (transparencyFlag) {\n getTransparencyIndex(transparencyIndex);\n }\n byteStream.pos++;\n break;\n }\n case _Types_GIFDataHeaders_js__WEBPACK_IMPORTED_MODULE_0__.GIFDataHeaders.ApplicationExtension:\n {\n byteStream.pos++;\n const applicationExtension = {\n identifier: byteStream.getString(8),\n authenticationCode: byteStream.getString(3),\n data: byteStream.readSubBlocksBin()\n };\n gif.applicationExtensions.push(applicationExtension);\n break;\n }\n case _Types_GIFDataHeaders_js__WEBPACK_IMPORTED_MODULE_0__.GIFDataHeaders.CommentExtension:\n {\n gif.comments.push([getFrameIndex(false), byteStream.readSubBlocks()]);\n break;\n }\n case _Types_GIFDataHeaders_js__WEBPACK_IMPORTED_MODULE_0__.GIFDataHeaders.PlainTextExtension:\n {\n if (gif.globalColorTable.length === 0) {\n throw new EvalError(\"plain text extension without global color table\");\n }\n byteStream.pos++;\n gif.frames[getFrameIndex(false)].plainTextData = {\n left: byteStream.nextTwoBytes(),\n top: byteStream.nextTwoBytes(),\n width: byteStream.nextTwoBytes(),\n height: byteStream.nextTwoBytes(),\n charSize: {\n width: byteStream.nextTwoBytes(),\n height: byteStream.nextTwoBytes()\n },\n foregroundColor: byteStream.nextByte(),\n backgroundColor: byteStream.nextByte(),\n text: byteStream.readSubBlocks()\n };\n break;\n }\n default:\n byteStream.skipSubBlocks();\n break;\n }\n}\nasync function parseImageBlock(byteStream, gif, avgAlpha, getFrameIndex, getTransparencyIndex, progressCallback) {\n const frame = gif.frames[getFrameIndex(true)];\n frame.left = byteStream.nextTwoBytes();\n frame.top = byteStream.nextTwoBytes();\n frame.width = byteStream.nextTwoBytes();\n frame.height = byteStream.nextTwoBytes();\n const packedByte = byteStream.nextByte(),\n localColorTableFlag = (packedByte & 0x80) === 0x80,\n interlacedFlag = (packedByte & 0x40) === 0x40;\n frame.sortFlag = (packedByte & 0x20) === 0x20;\n frame.reserved = (packedByte & 0x18) >>> 3;\n const localColorCount = 1 << (packedByte & 7) + 1;\n if (localColorTableFlag) {\n frame.localColorTable = parseColorTable(byteStream, localColorCount);\n }\n const getColor = index => {\n const {\n r,\n g,\n b\n } = (localColorTableFlag ? frame.localColorTable : gif.globalColorTable)[index];\n if (index !== getTransparencyIndex(null)) {\n return {\n r,\n g,\n b,\n a: 255\n };\n }\n return {\n r,\n g,\n b,\n a: avgAlpha ? ~~((r + g + b) / 3) : 0\n };\n };\n const image = (() => {\n try {\n return new ImageData(frame.width, frame.height, {\n colorSpace: \"srgb\"\n });\n } catch (error) {\n if (error instanceof DOMException && error.name === \"IndexSizeError\") {\n return null;\n }\n throw error;\n }\n })();\n if (image == null) {\n throw new EvalError(\"GIF frame size is to large\");\n }\n const minCodeSize = byteStream.nextByte(),\n imageData = byteStream.readSubBlocksBin(),\n clearCode = 1 << minCodeSize;\n const readBits = (pos, len) => {\n const bytePos = pos >>> 3,\n bitPos = pos & 7;\n return (imageData[bytePos] + (imageData[bytePos + 1] << 8) + (imageData[bytePos + 2] << 16) & (1 << len) - 1 << bitPos) >>> bitPos;\n };\n if (interlacedFlag) {\n for (let code = 0, size = minCodeSize + 1, pos = 0, dic = [[0]], pass = 0; pass < 4; pass++) {\n if (_Constants_js__WEBPACK_IMPORTED_MODULE_1__.InterlaceOffsets[pass] < frame.height) {\n let pixelPos = 0,\n lineIndex = 0,\n exit = false;\n while (!exit) {\n const last = code;\n code = readBits(pos, size);\n pos += size + 1;\n if (code === clearCode) {\n size = minCodeSize + 1;\n dic.length = clearCode + 2;\n for (let i = 0; i < dic.length; i++) {\n dic[i] = i < clearCode ? [i] : [];\n }\n } else {\n if (code >= dic.length) {\n dic.push(dic[last].concat(dic[last][0]));\n } else if (last !== clearCode) {\n dic.push(dic[last].concat(dic[code][0]));\n }\n for (const item of dic[code]) {\n const {\n r,\n g,\n b,\n a\n } = getColor(item);\n image.data.set([r, g, b, a], _Constants_js__WEBPACK_IMPORTED_MODULE_1__.InterlaceOffsets[pass] * frame.width + _Constants_js__WEBPACK_IMPORTED_MODULE_1__.InterlaceSteps[pass] * lineIndex + pixelPos % (frame.width * 4));\n pixelPos += 4;\n }\n if (dic.length === 1 << size && size < 0xc) {\n size++;\n }\n }\n if (pixelPos === frame.width * 4 * (lineIndex + 1)) {\n lineIndex++;\n if (_Constants_js__WEBPACK_IMPORTED_MODULE_1__.InterlaceOffsets[pass] + _Constants_js__WEBPACK_IMPORTED_MODULE_1__.InterlaceSteps[pass] * lineIndex >= frame.height) {\n exit = true;\n }\n }\n }\n }\n progressCallback?.(byteStream.pos / (byteStream.data.length - 1), getFrameIndex(false) + 1, image, {\n x: frame.left,\n y: frame.top\n }, {\n width: gif.width,\n height: gif.height\n });\n }\n frame.image = image;\n frame.bitmap = await createImageBitmap(image);\n } else {\n let code = 0,\n size = minCodeSize + 1,\n pos = 0,\n pixelPos = -4,\n exit = false;\n const dic = [[0]];\n while (!exit) {\n const last = code;\n code = readBits(pos, size);\n pos += size;\n if (code === clearCode) {\n size = minCodeSize + 1;\n dic.length = clearCode + 2;\n for (let i = 0; i < dic.length; i++) {\n dic[i] = i < clearCode ? [i] : [];\n }\n } else {\n if (code === clearCode + 1) {\n exit = true;\n break;\n }\n if (code >= dic.length) {\n dic.push(dic[last].concat(dic[last][0]));\n } else if (last !== clearCode) {\n dic.push(dic[last].concat(dic[code][0]));\n }\n for (const item of dic[code]) {\n const {\n r,\n g,\n b,\n a\n } = getColor(item);\n image.data.set([r, g, b, a], pixelPos += 4);\n }\n if (dic.length >= 1 << size && size < 0xc) {\n size++;\n }\n }\n }\n frame.image = image;\n frame.bitmap = await createImageBitmap(image);\n progressCallback?.((byteStream.pos + 1) / byteStream.data.length, getFrameIndex(false) + 1, frame.image, {\n x: frame.left,\n y: frame.top\n }, {\n width: gif.width,\n height: gif.height\n });\n }\n}\nasync function parseBlock(byteStream, gif, avgAlpha, getFrameIndex, getTransparencyIndex, progressCallback) {\n switch (byteStream.nextByte()) {\n case _Types_GIFDataHeaders_js__WEBPACK_IMPORTED_MODULE_0__.GIFDataHeaders.EndOfFile:\n return true;\n case _Types_GIFDataHeaders_js__WEBPACK_IMPORTED_MODULE_0__.GIFDataHeaders.Image:\n await parseImageBlock(byteStream, gif, avgAlpha, getFrameIndex, getTransparencyIndex, progressCallback);\n break;\n case _Types_GIFDataHeaders_js__WEBPACK_IMPORTED_MODULE_0__.GIFDataHeaders.Extension:\n parseExtensionBlock(byteStream, gif, getFrameIndex, getTransparencyIndex);\n break;\n default:\n throw new EvalError(\"undefined block found\");\n }\n return false;\n}\nfunction getGIFLoopAmount(gif) {\n for (const extension of gif.applicationExtensions) {\n if (extension.identifier + extension.authenticationCode !== \"NETSCAPE2.0\") {\n continue;\n }\n return extension.data[1] + (extension.data[2] << 8);\n }\n return NaN;\n}\nasync function decodeGIF(gifURL, progressCallback, avgAlpha) {\n if (!avgAlpha) avgAlpha = false;\n const res = await fetch(gifURL);\n if (!res.ok && res.status === 404) {\n throw new EvalError(\"file not found\");\n }\n const buffer = await res.arrayBuffer();\n const gif = {\n width: 0,\n height: 0,\n totalTime: 0,\n colorRes: 0,\n pixelAspectRatio: 0,\n frames: [],\n sortFlag: false,\n globalColorTable: [],\n backgroundImage: new ImageData(1, 1, {\n colorSpace: \"srgb\"\n }),\n comments: [],\n applicationExtensions: []\n },\n byteStream = new _ByteStream_js__WEBPACK_IMPORTED_MODULE_2__.ByteStream(new Uint8ClampedArray(buffer));\n if (byteStream.getString(6) !== \"GIF89a\") {\n throw new Error(\"not a supported GIF file\");\n }\n gif.width = byteStream.nextTwoBytes();\n gif.height = byteStream.nextTwoBytes();\n const packedByte = byteStream.nextByte(),\n globalColorTableFlag = (packedByte & 0x80) === 0x80;\n gif.colorRes = (packedByte & 0x70) >>> 4;\n gif.sortFlag = (packedByte & 8) === 8;\n const globalColorCount = 1 << (packedByte & 7) + 1,\n backgroundColorIndex = byteStream.nextByte();\n gif.pixelAspectRatio = byteStream.nextByte();\n if (gif.pixelAspectRatio !== 0) {\n gif.pixelAspectRatio = (gif.pixelAspectRatio + 0xf) / 0x40;\n }\n if (globalColorTableFlag) {\n gif.globalColorTable = parseColorTable(byteStream, globalColorCount);\n }\n const backgroundImage = (() => {\n try {\n return new ImageData(gif.width, gif.height, {\n colorSpace: \"srgb\"\n });\n } catch (error) {\n if (error instanceof DOMException && error.name === \"IndexSizeError\") {\n return null;\n }\n throw error;\n }\n })();\n if (backgroundImage == null) {\n throw new Error(\"GIF frame size is to large\");\n }\n const {\n r,\n g,\n b\n } = gif.globalColorTable[backgroundColorIndex];\n backgroundImage.data.set(globalColorTableFlag ? [r, g, b, 255] : [0, 0, 0, 0]);\n for (let i = 4; i < backgroundImage.data.length; i *= 2) {\n backgroundImage.data.copyWithin(i, 0, i);\n }\n gif.backgroundImage = backgroundImage;\n let frameIndex = -1,\n incrementFrameIndex = true,\n transparencyIndex = -1;\n const getframeIndex = increment => {\n if (increment) {\n incrementFrameIndex = true;\n }\n return frameIndex;\n };\n const getTransparencyIndex = newValue => {\n if (newValue != null) {\n transparencyIndex = newValue;\n }\n return transparencyIndex;\n };\n try {\n do {\n if (incrementFrameIndex) {\n gif.frames.push({\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n disposalMethod: _Enums_DisposalMethod_js__WEBPACK_IMPORTED_MODULE_3__.DisposalMethod.Replace,\n image: new ImageData(1, 1, {\n colorSpace: \"srgb\"\n }),\n plainTextData: null,\n userInputDelayFlag: false,\n delayTime: 0,\n sortFlag: false,\n localColorTable: [],\n reserved: 0,\n GCreserved: 0\n });\n frameIndex++;\n transparencyIndex = -1;\n incrementFrameIndex = false;\n }\n } while (!(await parseBlock(byteStream, gif, avgAlpha, getframeIndex, getTransparencyIndex, progressCallback)));\n gif.frames.length--;\n for (const frame of gif.frames) {\n if (frame.userInputDelayFlag && frame.delayTime === 0) {\n gif.totalTime = Infinity;\n break;\n }\n gif.totalTime += frame.delayTime;\n }\n return gif;\n } catch (error) {\n if (error instanceof EvalError) {\n throw new Error(`error while parsing frame ${frameIndex} \"${error.message}\"`);\n }\n throw error;\n }\n}\nfunction drawGif(data) {\n const {\n context,\n radius,\n particle,\n delta\n } = data,\n image = particle.image;\n if (!image?.gifData || !image.gif) {\n return;\n }\n const offscreenCanvas = new OffscreenCanvas(image.gifData.width, image.gifData.height),\n offscreenContext = offscreenCanvas.getContext(\"2d\");\n if (!offscreenContext) {\n throw new Error(\"could not create offscreen canvas context\");\n }\n offscreenContext.imageSmoothingQuality = \"low\";\n offscreenContext.imageSmoothingEnabled = false;\n offscreenContext.clearRect(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);\n if (particle.gifLoopCount === undefined) {\n particle.gifLoopCount = image.gifLoopCount ?? defaultLoopCount;\n }\n let frameIndex = particle.gifFrame ?? defaultFrame;\n const pos = {\n x: -image.gifData.width * half,\n y: -image.gifData.height * half\n },\n frame = image.gifData.frames[frameIndex];\n if (particle.gifTime === undefined) {\n particle.gifTime = initialTime;\n }\n if (!frame.bitmap) {\n return;\n }\n context.scale(radius / image.gifData.width, radius / image.gifData.height);\n switch (frame.disposalMethod) {\n case _Enums_DisposalMethod_js__WEBPACK_IMPORTED_MODULE_3__.DisposalMethod.UndefinedA:\n case _Enums_DisposalMethod_js__WEBPACK_IMPORTED_MODULE_3__.DisposalMethod.UndefinedB:\n case _Enums_DisposalMethod_js__WEBPACK_IMPORTED_MODULE_3__.DisposalMethod.UndefinedC:\n case _Enums_DisposalMethod_js__WEBPACK_IMPORTED_MODULE_3__.DisposalMethod.UndefinedD:\n case _Enums_DisposalMethod_js__WEBPACK_IMPORTED_MODULE_3__.DisposalMethod.Replace:\n offscreenContext.drawImage(frame.bitmap, frame.left, frame.top);\n context.drawImage(offscreenCanvas, pos.x, pos.y);\n offscreenContext.clearRect(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);\n break;\n case _Enums_DisposalMethod_js__WEBPACK_IMPORTED_MODULE_3__.DisposalMethod.Combine:\n offscreenContext.drawImage(frame.bitmap, frame.left, frame.top);\n context.drawImage(offscreenCanvas, pos.x, pos.y);\n break;\n case _Enums_DisposalMethod_js__WEBPACK_IMPORTED_MODULE_3__.DisposalMethod.RestoreBackground:\n offscreenContext.drawImage(frame.bitmap, frame.left, frame.top);\n context.drawImage(offscreenCanvas, pos.x, pos.y);\n offscreenContext.clearRect(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);\n if (!image.gifData.globalColorTable.length) {\n offscreenContext.putImageData(image.gifData.frames[firstIndex].image, pos.x + frame.left, pos.y + frame.top);\n } else {\n offscreenContext.putImageData(image.gifData.backgroundImage, pos.x, pos.y);\n }\n break;\n case _Enums_DisposalMethod_js__WEBPACK_IMPORTED_MODULE_3__.DisposalMethod.RestorePrevious:\n {\n const previousImageData = offscreenContext.getImageData(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);\n offscreenContext.drawImage(frame.bitmap, frame.left, frame.top);\n context.drawImage(offscreenCanvas, pos.x, pos.y);\n offscreenContext.clearRect(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);\n offscreenContext.putImageData(previousImageData, origin.x, origin.y);\n }\n break;\n }\n particle.gifTime += delta.value;\n if (particle.gifTime > frame.delayTime) {\n particle.gifTime -= frame.delayTime;\n if (++frameIndex >= image.gifData.frames.length) {\n if (--particle.gifLoopCount <= defaultLoopCount) {\n return;\n }\n frameIndex = firstIndex;\n offscreenContext.clearRect(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height);\n }\n particle.gifFrame = frameIndex;\n }\n context.scale(image.gifData.width / radius, image.gifData.height / radius);\n}\nasync function loadGifImage(image) {\n if (image.type !== \"gif\") {\n await (0,_Utils_js__WEBPACK_IMPORTED_MODULE_4__.loadImage)(image);\n return;\n }\n image.loading = true;\n try {\n image.gifData = await decodeGIF(image.source);\n image.gifLoopCount = getGIFLoopAmount(image.gifData) ?? defaultLoopCount;\n if (!image.gifLoopCount) {\n image.gifLoopCount = Infinity;\n }\n } catch {\n image.error = true;\n }\n image.loading = false;\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/GifUtils/Utils.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/ImageDrawer.js": | ||
/*!*************************************!*\ | ||
!*** ./dist/browser/ImageDrawer.js ***! | ||
\*************************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ImageDrawer: () => (/* binding */ ImageDrawer)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _GifUtils_Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./GifUtils/Utils.js */ \"./dist/browser/GifUtils/Utils.js\");\n\n\n\nconst double = 2,\n defaultAlpha = 1,\n sides = 12,\n defaultRatio = 1;\nclass ImageDrawer {\n constructor(engine) {\n this.validTypes = [\"image\", \"images\"];\n this.loadImageShape = async imageShape => {\n if (!this._engine.loadImage) {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} image shape not initialized`);\n }\n await this._engine.loadImage({\n gif: imageShape.gif,\n name: imageShape.name,\n replaceColor: imageShape.replaceColor ?? false,\n src: imageShape.src\n });\n };\n this._engine = engine;\n }\n addImage(image) {\n if (!this._engine.images) {\n this._engine.images = [];\n }\n this._engine.images.push(image);\n }\n draw(data) {\n const {\n context,\n radius,\n particle,\n opacity\n } = data,\n image = particle.image,\n element = image?.element;\n if (!image) {\n return;\n }\n context.globalAlpha = opacity;\n if (image.gif && image.gifData) {\n (0,_GifUtils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.drawGif)(data);\n } else if (element) {\n const ratio = image.ratio,\n pos = {\n x: -radius,\n y: -radius\n },\n diameter = radius * double;\n context.drawImage(element, pos.x, pos.y, diameter, diameter / ratio);\n }\n context.globalAlpha = defaultAlpha;\n }\n getSidesCount() {\n return sides;\n }\n async init(container) {\n const options = container.actualOptions;\n if (!options.preload || !this._engine.loadImage) {\n return;\n }\n for (const imageData of options.preload) {\n await this._engine.loadImage(imageData);\n }\n }\n loadShape(particle) {\n if (particle.shape !== \"image\" && particle.shape !== \"images\") {\n return;\n }\n if (!this._engine.images) {\n this._engine.images = [];\n }\n const imageData = particle.shapeData;\n if (!imageData) {\n return;\n }\n const image = this._engine.images.find(t => t.name === imageData.name || t.source === imageData.src);\n if (!image) {\n void this.loadImageShape(imageData).then(() => {\n this.loadShape(particle);\n });\n }\n }\n particleInit(container, particle) {\n if (particle.shape !== \"image\" && particle.shape !== \"images\") {\n return;\n }\n if (!this._engine.images) {\n this._engine.images = [];\n }\n const images = this._engine.images,\n imageData = particle.shapeData;\n if (!imageData) {\n return;\n }\n const color = particle.getFillColor(),\n image = images.find(t => t.name === imageData.name || t.source === imageData.src);\n if (!image) {\n return;\n }\n const replaceColor = imageData.replaceColor ?? image.replaceColor;\n if (image.loading) {\n setTimeout(() => {\n this.particleInit(container, particle);\n });\n return;\n }\n void (async () => {\n let imageRes;\n if (image.svgData && color) {\n imageRes = await (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__.replaceImageColor)(image, imageData, color, particle);\n } else {\n imageRes = {\n color,\n data: image,\n element: image.element,\n gif: image.gif,\n gifData: image.gifData,\n gifLoopCount: image.gifLoopCount,\n loaded: true,\n ratio: imageData.width && imageData.height ? imageData.width / imageData.height : image.ratio ?? defaultRatio,\n replaceColor: replaceColor,\n source: imageData.src\n };\n }\n if (!imageRes.ratio) {\n imageRes.ratio = 1;\n }\n const fill = imageData.fill ?? particle.shapeFill,\n close = imageData.close ?? particle.shapeClose,\n imageShape = {\n image: imageRes,\n fill,\n close\n };\n particle.image = imageShape.image;\n particle.shapeFill = imageShape.fill;\n particle.shapeClose = imageShape.close;\n })();\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/ImageDrawer.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/ImagePreloader.js": | ||
/*!****************************************!*\ | ||
!*** ./dist/browser/ImagePreloader.js ***! | ||
\****************************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ImagePreloaderPlugin: () => (/* binding */ ImagePreloaderPlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Preload_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Preload.js */ \"./dist/browser/Options/Classes/Preload.js\");\n\nclass ImagePreloaderPlugin {\n constructor(engine) {\n this.id = \"imagePreloader\";\n this._engine = engine;\n }\n async getPlugin() {\n await Promise.resolve();\n return {};\n }\n loadOptions(options, source) {\n if (!source?.preload) {\n return;\n }\n if (!options.preload) {\n options.preload = [];\n }\n const preloadOptions = options.preload;\n for (const item of source.preload) {\n const existing = preloadOptions.find(t => t.name === item.name || t.src === item.src);\n if (existing) {\n existing.load(item);\n } else {\n const preload = new _Options_Classes_Preload_js__WEBPACK_IMPORTED_MODULE_0__.Preload();\n preload.load(item);\n preloadOptions.push(preload);\n }\n }\n }\n needsPlugin() {\n return true;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/ImagePreloader.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/Options/Classes/Preload.js": | ||
/*!*************************************************!*\ | ||
!*** ./dist/browser/Options/Classes/Preload.js ***! | ||
\*************************************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Preload: () => (/* binding */ Preload)\n/* harmony export */ });\nclass Preload {\n constructor() {\n this.src = \"\";\n this.gif = false;\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.gif !== undefined) {\n this.gif = data.gif;\n }\n if (data.height !== undefined) {\n this.height = data.height;\n }\n if (data.name !== undefined) {\n this.name = data.name;\n }\n if (data.replaceColor !== undefined) {\n this.replaceColor = data.replaceColor;\n }\n if (data.src !== undefined) {\n this.src = data.src;\n }\n if (data.width !== undefined) {\n this.width = data.width;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/Options/Classes/Preload.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/Utils.js": | ||
@@ -49,3 +129,3 @@ /*!*******************************!*\ | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadImageShape: () => (/* binding */ loadImageShape)\n/* harmony export */ });\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\n\nconst extLength = 3;\nfunction addLoadImageToEngine(engine) {\n if (engine.loadImage) {\n return;\n }\n engine.loadImage = async data => {\n if (!data.name && !data.src) {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} no image source provided`);\n }\n if (!engine.images) {\n engine.images = [];\n }\n if (engine.images.find(t => t.name === data.name || t.source === data.src)) {\n return;\n }\n try {\n const image = {\n gif: data.gif ?? false,\n name: data.name ?? data.src,\n source: data.src,\n type: data.src.substring(data.src.length - extLength),\n error: false,\n loading: true,\n replaceColor: data.replaceColor,\n ratio: data.width && data.height ? data.width / data.height : undefined\n };\n engine.images.push(image);\n let imageFunc;\n if (data.gif) {\n const {\n loadGifImage\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_GifUtils_Utils_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./GifUtils/Utils.js */ \"./dist/browser/GifUtils/Utils.js\"));\n imageFunc = loadGifImage;\n } else {\n imageFunc = data.replaceColor ? _Utils_js__WEBPACK_IMPORTED_MODULE_1__.downloadSvgImage : _Utils_js__WEBPACK_IMPORTED_MODULE_1__.loadImage;\n }\n await imageFunc(image);\n } catch {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} ${data.name ?? data.src} not found`);\n }\n };\n}\nasync function loadImageShape(engine, refresh = true) {\n addLoadImageToEngine(engine);\n const {\n ImagePreloaderPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_ImagePreloader_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ImagePreloader.js */ \"./dist/browser/ImagePreloader.js\")),\n {\n ImageDrawer\n } = await Promise.all(/*! import() */[__webpack_require__.e(\"dist_browser_GifUtils_Utils_js\"), __webpack_require__.e(\"dist_browser_ImageDrawer_js\")]).then(__webpack_require__.bind(__webpack_require__, /*! ./ImageDrawer.js */ \"./dist/browser/ImageDrawer.js\"));\n const preloader = new ImagePreloaderPlugin(engine);\n await engine.addPlugin(preloader, refresh);\n await engine.addShape([\"image\", \"images\"], new ImageDrawer(engine), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/index.js?"); | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadImageShape: () => (/* binding */ loadImageShape)\n/* harmony export */ });\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _ImageDrawer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ImageDrawer.js */ \"./dist/browser/ImageDrawer.js\");\n/* harmony import */ var _ImagePreloader_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ImagePreloader.js */ \"./dist/browser/ImagePreloader.js\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _GifUtils_Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./GifUtils/Utils.js */ \"./dist/browser/GifUtils/Utils.js\");\n\n\n\n\n\nconst extLength = 3;\nfunction addLoadImageToEngine(engine) {\n if (engine.loadImage) {\n return;\n }\n engine.loadImage = async data => {\n if (!data.name && !data.src) {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} no image source provided`);\n }\n if (!engine.images) {\n engine.images = [];\n }\n if (engine.images.find(t => t.name === data.name || t.source === data.src)) {\n return;\n }\n try {\n const image = {\n gif: data.gif ?? false,\n name: data.name ?? data.src,\n source: data.src,\n type: data.src.substring(data.src.length - extLength),\n error: false,\n loading: true,\n replaceColor: data.replaceColor,\n ratio: data.width && data.height ? data.width / data.height : undefined\n };\n engine.images.push(image);\n let imageFunc;\n if (data.gif) {\n imageFunc = _GifUtils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.loadGifImage;\n } else {\n imageFunc = data.replaceColor ? _Utils_js__WEBPACK_IMPORTED_MODULE_2__.downloadSvgImage : _Utils_js__WEBPACK_IMPORTED_MODULE_2__.loadImage;\n }\n await imageFunc(image);\n } catch {\n throw new Error(`${_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.errorPrefix} ${data.name ?? data.src} not found`);\n }\n };\n}\nasync function loadImageShape(engine, refresh = true) {\n addLoadImageToEngine(engine);\n const preloader = new _ImagePreloader_js__WEBPACK_IMPORTED_MODULE_3__.ImagePreloaderPlugin(engine);\n await engine.addPlugin(preloader, refresh);\n await engine.addShape(new _ImageDrawer_js__WEBPACK_IMPORTED_MODULE_4__.ImageDrawer(engine), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/shape-image/./dist/browser/index.js?"); | ||
@@ -90,5 +170,2 @@ /***/ }), | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = __webpack_modules__; | ||
/******/ | ||
/************************************************************************/ | ||
@@ -119,36 +196,2 @@ /******/ /* webpack/runtime/compat get default export */ | ||
/******/ | ||
/******/ /* webpack/runtime/ensure chunk */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.f = {}; | ||
/******/ // This file contains only the entry chunk. | ||
/******/ // The chunk loading function for additional chunks | ||
/******/ __webpack_require__.e = (chunkId) => { | ||
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => { | ||
/******/ __webpack_require__.f[key](chunkId, promises); | ||
/******/ return promises; | ||
/******/ }, [])); | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/get javascript chunk filename */ | ||
/******/ (() => { | ||
/******/ // This function allow to reference async chunks | ||
/******/ __webpack_require__.u = (chunkId) => { | ||
/******/ // return url for filenames based on template | ||
/******/ return "" + chunkId + ".js"; | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/global */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.g = (function() { | ||
/******/ if (typeof globalThis === 'object') return globalThis; | ||
/******/ try { | ||
/******/ return this || new Function('return this')(); | ||
/******/ } catch (e) { | ||
/******/ if (typeof window === 'object') return window; | ||
/******/ } | ||
/******/ })(); | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/hasOwnProperty shorthand */ | ||
@@ -159,48 +202,2 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* webpack/runtime/load script */ | ||
/******/ (() => { | ||
/******/ var inProgress = {}; | ||
/******/ var dataWebpackPrefix = "@tsparticles/shape-image:"; | ||
/******/ // loadScript function to load a script via script tag | ||
/******/ __webpack_require__.l = (url, done, key, chunkId) => { | ||
/******/ if(inProgress[url]) { inProgress[url].push(done); return; } | ||
/******/ var script, needAttach; | ||
/******/ if(key !== undefined) { | ||
/******/ var scripts = document.getElementsByTagName("script"); | ||
/******/ for(var i = 0; i < scripts.length; i++) { | ||
/******/ var s = scripts[i]; | ||
/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; } | ||
/******/ } | ||
/******/ } | ||
/******/ if(!script) { | ||
/******/ needAttach = true; | ||
/******/ script = document.createElement('script'); | ||
/******/ | ||
/******/ script.charset = 'utf-8'; | ||
/******/ script.timeout = 120; | ||
/******/ if (__webpack_require__.nc) { | ||
/******/ script.setAttribute("nonce", __webpack_require__.nc); | ||
/******/ } | ||
/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key); | ||
/******/ | ||
/******/ script.src = url; | ||
/******/ } | ||
/******/ inProgress[url] = [done]; | ||
/******/ var onScriptComplete = (prev, event) => { | ||
/******/ // avoid mem leaks in IE. | ||
/******/ script.onerror = script.onload = null; | ||
/******/ clearTimeout(timeout); | ||
/******/ var doneFns = inProgress[url]; | ||
/******/ delete inProgress[url]; | ||
/******/ script.parentNode && script.parentNode.removeChild(script); | ||
/******/ doneFns && doneFns.forEach((fn) => (fn(event))); | ||
/******/ if(prev) return prev(event); | ||
/******/ } | ||
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000); | ||
/******/ script.onerror = onScriptComplete.bind(null, script.onerror); | ||
/******/ script.onload = onScriptComplete.bind(null, script.onload); | ||
/******/ needAttach && document.head.appendChild(script); | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/make namespace object */ | ||
@@ -217,117 +214,2 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* webpack/runtime/publicPath */ | ||
/******/ (() => { | ||
/******/ var scriptUrl; | ||
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; | ||
/******/ var document = __webpack_require__.g.document; | ||
/******/ if (!scriptUrl && document) { | ||
/******/ if (document.currentScript) | ||
/******/ scriptUrl = document.currentScript.src; | ||
/******/ if (!scriptUrl) { | ||
/******/ var scripts = document.getElementsByTagName("script"); | ||
/******/ if(scripts.length) { | ||
/******/ var i = scripts.length - 1; | ||
/******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; | ||
/******/ } | ||
/******/ } | ||
/******/ } | ||
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration | ||
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic. | ||
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); | ||
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); | ||
/******/ __webpack_require__.p = scriptUrl; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/jsonp chunk loading */ | ||
/******/ (() => { | ||
/******/ // no baseURI | ||
/******/ | ||
/******/ // object to store loaded and loading chunks | ||
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched | ||
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded | ||
/******/ var installedChunks = { | ||
/******/ "tsparticles.shape.image": 0 | ||
/******/ }; | ||
/******/ | ||
/******/ __webpack_require__.f.j = (chunkId, promises) => { | ||
/******/ // JSONP chunk loading for javascript | ||
/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined; | ||
/******/ if(installedChunkData !== 0) { // 0 means "already installed". | ||
/******/ | ||
/******/ // a Promise means "currently loading". | ||
/******/ if(installedChunkData) { | ||
/******/ promises.push(installedChunkData[2]); | ||
/******/ } else { | ||
/******/ if(true) { // all chunks have JS | ||
/******/ // setup Promise in chunk cache | ||
/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); | ||
/******/ promises.push(installedChunkData[2] = promise); | ||
/******/ | ||
/******/ // start chunk loading | ||
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId); | ||
/******/ // create error before stack unwound to get useful stacktrace later | ||
/******/ var error = new Error(); | ||
/******/ var loadingEnded = (event) => { | ||
/******/ if(__webpack_require__.o(installedChunks, chunkId)) { | ||
/******/ installedChunkData = installedChunks[chunkId]; | ||
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined; | ||
/******/ if(installedChunkData) { | ||
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); | ||
/******/ var realSrc = event && event.target && event.target.src; | ||
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'; | ||
/******/ error.name = 'ChunkLoadError'; | ||
/******/ error.type = errorType; | ||
/******/ error.request = realSrc; | ||
/******/ installedChunkData[1](error); | ||
/******/ } | ||
/******/ } | ||
/******/ }; | ||
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId); | ||
/******/ } | ||
/******/ } | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // no prefetching | ||
/******/ | ||
/******/ // no preloaded | ||
/******/ | ||
/******/ // no HMR | ||
/******/ | ||
/******/ // no HMR manifest | ||
/******/ | ||
/******/ // no on chunks loaded | ||
/******/ | ||
/******/ // install a JSONP callback for chunk loading | ||
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { | ||
/******/ var chunkIds = data[0]; | ||
/******/ var moreModules = data[1]; | ||
/******/ var runtime = data[2]; | ||
/******/ // add "moreModules" to the modules object, | ||
/******/ // then flag all "chunkIds" as loaded and fire callback | ||
/******/ var moduleId, chunkId, i = 0; | ||
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { | ||
/******/ for(moduleId in moreModules) { | ||
/******/ if(__webpack_require__.o(moreModules, moduleId)) { | ||
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; | ||
/******/ } | ||
/******/ } | ||
/******/ if(runtime) var result = runtime(__webpack_require__); | ||
/******/ } | ||
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); | ||
/******/ for(;i < chunkIds.length; i++) { | ||
/******/ chunkId = chunkIds[i]; | ||
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { | ||
/******/ installedChunks[chunkId][0](); | ||
/******/ } | ||
/******/ installedChunks[chunkId] = 0; | ||
/******/ } | ||
/******/ | ||
/******/ } | ||
/******/ | ||
/******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_shape_image"] = this["webpackChunk_tsparticles_shape_image"] || []; | ||
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); | ||
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); | ||
/******/ })(); | ||
/******/ | ||
/************************************************************************/ | ||
@@ -334,0 +216,0 @@ /******/ |
/*! For license information please see tsparticles.shape.image.min.js.LICENSE.txt */ | ||
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],r);else{var t="object"==typeof exports?r(require("@tsparticles/engine")):r(e.window);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(this,(e=>(()=>{var r,t,o={764:(e,r,t)=>{t.d(r,{a:()=>c,d:()=>l,loadImage:()=>s});var o=t(303);const a=0,n=1,i=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;async function s(e){return new Promise((r=>{e.loading=!0;const t=new Image;e.element=t,t.addEventListener("load",(()=>{e.loading=!1,r()})),t.addEventListener("error",(()=>{e.element=void 0,e.error=!0,e.loading=!1,(0,o.getLogger)().error(`${o.errorPrefix} loading image: ${e.source}`),r()})),t.src=e.source}))}async function c(e){if("svg"!==e.type)return void await s(e);e.loading=!0;const r=await fetch(e.source);r.ok?e.svgData=await r.text():((0,o.getLogger)().error(`${o.errorPrefix} Image not found`),e.error=!0),e.loading=!1}function l(e,r,t,c){const l=function(e,r,t){const{svgData:n}=e;if(!n)return"";const s=(0,o.getStyleFromHsl)(r,t);if(n.includes("fill"))return n.replace(i,(()=>s));const c=n.indexOf(">");return`${n.substring(a,c)} fill="${s}"${n.substring(c)}`}(e,t,c.opacity?.value??n),d={color:t,gif:r.gif,data:{...e,svgData:l},loaded:!1,ratio:r.width/r.height,replaceColor:r.replaceColor,source:r.src};return new Promise((r=>{const t=new Blob([l],{type:"image/svg+xml"}),o=URL||window.URL||window.webkitURL||window,a=o.createObjectURL(t),n=new Image;n.addEventListener("load",(()=>{d.loaded=!0,d.element=n,r(d),o.revokeObjectURL(a)}));n.addEventListener("error",(()=>{(async()=>{o.revokeObjectURL(a);const t={...e,error:!1,loading:!0};await s(t),d.loaded=!0,d.element=t.element,r(d)})()})),n.src=a}))}},303:r=>{r.exports=e}},a={};function n(e){var r=a[e];if(void 0!==r)return r.exports;var t=a[e]={exports:{}};return o[e](t,t.exports,n),t.exports}n.m=o,n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((r,t)=>(n.f[t](e,r),r)),[])),n.u=e=>e+".min.js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r={},t="@tsparticles/shape-image:",n.l=(e,o,a,i)=>{if(r[e])r[e].push(o);else{var s,c;if(void 0!==a)for(var l=document.getElementsByTagName("script"),d=0;d<l.length;d++){var u=l[d];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==t+a){s=u;break}}s||(c=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,n.nc&&s.setAttribute("nonce",n.nc),s.setAttribute("data-webpack",t+a),s.src=e),r[e]=[o];var g=(t,o)=>{s.onerror=s.onload=null,clearTimeout(f);var a=r[e];if(delete r[e],s.parentNode&&s.parentNode.removeChild(s),a&&a.forEach((e=>e(o))),t)return t(o)},f=setTimeout(g.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=g.bind(null,s.onerror),s.onload=g.bind(null,s.onload),c&&document.head.appendChild(s)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var r=n.g.document;if(!e&&r&&(r.currentScript&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),(()=>{var e={999:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise(((t,a)=>o=e[r]=[t,a]));t.push(o[2]=a);var i=n.p+n.u(r),s=new Error;n.l(i,(t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;s.message="Loading chunk "+r+" failed.\n("+a+": "+i+")",s.name="ChunkLoadError",s.type=a,s.request=i,o[1](s)}}),"chunk-"+r,r)}};var r=(r,t)=>{var o,a,i=t[0],s=t[1],c=t[2],l=0;if(i.some((r=>0!==e[r]))){for(o in s)n.o(s,o)&&(n.m[o]=s[o]);if(c)c(n)}for(r&&r(t);l<i.length;l++)a=i[l],n.o(e,a)&&e[a]&&e[a][0](),e[a]=0},t=this.webpackChunk_tsparticles_shape_image=this.webpackChunk_tsparticles_shape_image||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})();var i={};return(()=>{n.r(i),n.d(i,{loadImageShape:()=>o});var e=n(764),r=n(303);const t=3;async function o(o,a=!0){!function(o){o.loadImage||(o.loadImage=async a=>{if(!a.name&&!a.src)throw new Error(`${r.errorPrefix} no image source provided`);if(o.images||(o.images=[]),!o.images.find((e=>e.name===a.name||e.source===a.src)))try{const r={gif:a.gif??!1,name:a.name??a.src,source:a.src,type:a.src.substring(a.src.length-t),error:!1,loading:!0,replaceColor:a.replaceColor,ratio:a.width&&a.height?a.width/a.height:void 0};let i;if(o.images.push(r),a.gif){const{loadGifImage:e}=await n.e(329).then(n.bind(n,329));i=e}else i=a.replaceColor?e.a:e.loadImage;await i(r)}catch{throw new Error(`${r.errorPrefix} ${a.name??a.src} not found`)}})}(o);const{ImagePreloaderPlugin:i}=await n.e(715).then(n.bind(n,715)),{ImageDrawer:s}=await n.e(33).then(n.bind(n,33)),c=new i(o);await o.addPlugin(c,a),await o.addShape(["image","images"],new s(o),a)}})(),i})())); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var a="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in a)("object"==typeof exports?exports:e)[o]=a[o]}}(this,(e=>(()=>{var t={303:t=>{t.exports=e}},a={};function o(e){var i=a[e];if(void 0!==i)return i.exports;var n=a[e]={exports:{}};return t[e](n,n.exports,o),n.exports}o.d=(e,t)=>{for(var a in t)o.o(t,a)&&!o.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{loadImageShape:()=>E});var e=o(303);const t=0,a=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;async function n(t){return new Promise((a=>{t.loading=!0;const o=new Image;t.element=o,o.addEventListener("load",(()=>{t.loading=!1,a()})),o.addEventListener("error",(()=>{t.element=void 0,t.error=!0,t.loading=!1,(0,e.getLogger)().error(`${e.errorPrefix} loading image: ${t.source}`),a()})),o.src=t.source}))}async function r(t){if("svg"!==t.type)return void await n(t);t.loading=!0;const a=await fetch(t.source);a.ok?t.svgData=await a.text():((0,e.getLogger)().error(`${e.errorPrefix} Image not found`),t.error=!0),t.loading=!1}function s(o,i,r,s){const l=function(o,i,n){const{svgData:r}=o;if(!r)return"";const s=(0,e.getStyleFromHsl)(i,n);if(r.includes("fill"))return r.replace(a,(()=>s));const l=r.indexOf(">");return`${r.substring(t,l)} fill="${s}"${r.substring(l)}`}(o,r,s.opacity?.value??1),c={color:r,gif:i.gif,data:{...o,svgData:l},loaded:!1,ratio:i.width/i.height,replaceColor:i.replaceColor,source:i.src};return new Promise((e=>{const t=new Blob([l],{type:"image/svg+xml"}),a=URL||window.URL||window.webkitURL||window,i=a.createObjectURL(t),r=new Image;r.addEventListener("load",(()=>{c.loaded=!0,c.element=r,e(c),a.revokeObjectURL(i)}));r.addEventListener("error",(()=>{(async()=>{a.revokeObjectURL(i);const t={...o,error:!1,loading:!0};await n(t),c.loaded=!0,c.element=t.element,e(c)})()})),r.src=i}))}const l=[0,4,2,1],c=[8,8,4,2];class g{constructor(e){this.pos=0,this.data=new Uint8ClampedArray(e)}getString(e){const t=this.data.slice(this.pos,this.pos+e);return this.pos+=t.length,t.reduce(((e,t)=>e+String.fromCharCode(t)),"")}nextByte(){return this.data[this.pos++]}nextTwoBytes(){return this.pos+=2,this.data[this.pos-2]+(this.data[this.pos-1]<<8)}readSubBlocks(){let e="",t=0;do{t=this.data[this.pos++];for(let a=t;--a>=0;e+=String.fromCharCode(this.data[this.pos++]));}while(0!==t);return e}readSubBlocksBin(){let e=this.data[this.pos],t=0;for(let a=0;0!==e;a+=e+1,e=this.data[this.pos+a])t+=e;const a=new Uint8Array(t);e=this.data[this.pos++];for(let t=0;0!==e;e=this.data[this.pos++])for(let o=e;--o>=0;a[t++]=this.data[this.pos++]);return a}skipSubBlocks(){for(const e=1,t=0;this.data[this.pos]!==t;this.pos+=this.data[this.pos]+e);this.pos++}}var d,h;!function(e){e[e.Replace=0]="Replace",e[e.Combine=1]="Combine",e[e.RestoreBackground=2]="RestoreBackground",e[e.RestorePrevious=3]="RestorePrevious",e[e.UndefinedA=4]="UndefinedA",e[e.UndefinedB=5]="UndefinedB",e[e.UndefinedC=6]="UndefinedC",e[e.UndefinedD=7]="UndefinedD"}(d||(d={})),function(e){e[e.Extension=33]="Extension",e[e.ApplicationExtension=255]="ApplicationExtension",e[e.GraphicsControlExtension=249]="GraphicsControlExtension",e[e.PlainTextExtension=1]="PlainTextExtension",e[e.CommentExtension=254]="CommentExtension",e[e.Image=44]="Image",e[e.EndOfFile=59]="EndOfFile"}(h||(h={}));const f=0,p=0,m=0;function u(e,t){const a=[];for(let o=0;o<t;o++)a.push({r:e.data[e.pos],g:e.data[e.pos+1],b:e.data[e.pos+2]}),e.pos+=3;return a}async function w(e,t,a,o,i,n){switch(e.nextByte()){case h.EndOfFile:return!0;case h.Image:await async function(e,t,a,o,i,n){const r=t.frames[o(!0)];r.left=e.nextTwoBytes(),r.top=e.nextTwoBytes(),r.width=e.nextTwoBytes(),r.height=e.nextTwoBytes();const s=e.nextByte(),g=128==(128&s),d=64==(64&s);r.sortFlag=32==(32&s),r.reserved=(24&s)>>>3;const h=1<<1+(7&s);g&&(r.localColorTable=u(e,h));const f=e=>{const{r:o,g:n,b:s}=(g?r.localColorTable:t.globalColorTable)[e];return e!==i(null)?{r:o,g:n,b:s,a:255}:{r:o,g:n,b:s,a:a?~~((o+n+s)/3):0}},p=(()=>{try{return new ImageData(r.width,r.height,{colorSpace:"srgb"})}catch(e){if(e instanceof DOMException&&"IndexSizeError"===e.name)return null;throw e}})();if(null==p)throw new EvalError("GIF frame size is to large");const m=e.nextByte(),w=e.readSubBlocksBin(),x=1<<m,y=(e,t)=>{const a=e>>>3,o=7&e;return(w[a]+(w[a+1]<<8)+(w[a+2]<<16)&(1<<t)-1<<o)>>>o};if(d){for(let a=0,i=m+1,s=0,g=[[0]],d=0;d<4;d++){if(l[d]<r.height){let e=0,t=0,o=!1;for(;!o;){const n=a;if(a=y(s,i),s+=i+1,a===x){i=m+1,g.length=x+2;for(let e=0;e<g.length;e++)g[e]=e<x?[e]:[]}else{a>=g.length?g.push(g[n].concat(g[n][0])):n!==x&&g.push(g[n].concat(g[a][0]));for(const o of g[a]){const{r:a,g:i,b:n,a:s}=f(o);p.data.set([a,i,n,s],l[d]*r.width+c[d]*t+e%(4*r.width)),e+=4}g.length===1<<i&&i<12&&i++}e===4*r.width*(t+1)&&(t++,l[d]+c[d]*t>=r.height&&(o=!0))}}n?.(e.pos/(e.data.length-1),o(!1)+1,p,{x:r.left,y:r.top},{width:t.width,height:t.height})}r.image=p,r.bitmap=await createImageBitmap(p)}else{let a=0,i=m+1,s=0,l=-4,c=!1;const g=[[0]];for(;!c;){const e=a;if(a=y(s,i),s+=i,a===x){i=m+1,g.length=x+2;for(let e=0;e<g.length;e++)g[e]=e<x?[e]:[]}else{if(a===x+1){c=!0;break}a>=g.length?g.push(g[e].concat(g[e][0])):e!==x&&g.push(g[e].concat(g[a][0]));for(const e of g[a]){const{r:t,g:a,b:o,a:i}=f(e);p.data.set([t,a,o,i],l+=4)}g.length>=1<<i&&i<12&&i++}}r.image=p,r.bitmap=await createImageBitmap(p),n?.((e.pos+1)/e.data.length,o(!1)+1,r.image,{x:r.left,y:r.top},{width:t.width,height:t.height})}}(e,t,a,o,i,n);break;case h.Extension:!function(e,t,a,o){switch(e.nextByte()){case h.GraphicsControlExtension:{const i=t.frames[a(!1)];e.pos++;const n=e.nextByte();i.GCreserved=(224&n)>>>5,i.disposalMethod=(28&n)>>>2,i.userInputDelayFlag=2==(2&n);const r=1==(1&n);i.delayTime=10*e.nextTwoBytes();const s=e.nextByte();r&&o(s),e.pos++;break}case h.ApplicationExtension:{e.pos++;const a={identifier:e.getString(8),authenticationCode:e.getString(3),data:e.readSubBlocksBin()};t.applicationExtensions.push(a);break}case h.CommentExtension:t.comments.push([a(!1),e.readSubBlocks()]);break;case h.PlainTextExtension:if(0===t.globalColorTable.length)throw new EvalError("plain text extension without global color table");e.pos++,t.frames[a(!1)].plainTextData={left:e.nextTwoBytes(),top:e.nextTwoBytes(),width:e.nextTwoBytes(),height:e.nextTwoBytes(),charSize:{width:e.nextTwoBytes(),height:e.nextTwoBytes()},foregroundColor:e.nextByte(),backgroundColor:e.nextByte(),text:e.readSubBlocks()};break;default:e.skipSubBlocks()}}(e,t,o,i);break;default:throw new EvalError("undefined block found")}return!1}async function x(e){if("gif"===e.type){e.loading=!0;try{e.gifData=await async function(e,t,a){a||(a=!1);const o=await fetch(e);if(!o.ok&&404===o.status)throw new EvalError("file not found");const i=await o.arrayBuffer(),n={width:0,height:0,totalTime:0,colorRes:0,pixelAspectRatio:0,frames:[],sortFlag:!1,globalColorTable:[],backgroundImage:new ImageData(1,1,{colorSpace:"srgb"}),comments:[],applicationExtensions:[]},r=new g(new Uint8ClampedArray(i));if("GIF89a"!==r.getString(6))throw new Error("not a supported GIF file");n.width=r.nextTwoBytes(),n.height=r.nextTwoBytes();const s=r.nextByte(),l=128==(128&s);n.colorRes=(112&s)>>>4,n.sortFlag=8==(8&s);const c=1<<1+(7&s),h=r.nextByte();n.pixelAspectRatio=r.nextByte(),0!==n.pixelAspectRatio&&(n.pixelAspectRatio=(n.pixelAspectRatio+15)/64),l&&(n.globalColorTable=u(r,c));const f=(()=>{try{return new ImageData(n.width,n.height,{colorSpace:"srgb"})}catch(e){if(e instanceof DOMException&&"IndexSizeError"===e.name)return null;throw e}})();if(null==f)throw new Error("GIF frame size is to large");const{r:p,g:m,b:x}=n.globalColorTable[h];f.data.set(l?[p,m,x,255]:[0,0,0,0]);for(let e=4;e<f.data.length;e*=2)f.data.copyWithin(e,0,e);n.backgroundImage=f;let y=-1,b=!0,C=-1;const v=e=>(e&&(b=!0),y),E=e=>(null!=e&&(C=e),C);try{do{b&&(n.frames.push({left:0,top:0,width:0,height:0,disposalMethod:d.Replace,image:new ImageData(1,1,{colorSpace:"srgb"}),plainTextData:null,userInputDelayFlag:!1,delayTime:0,sortFlag:!1,localColorTable:[],reserved:0,GCreserved:0}),y++,C=-1,b=!1)}while(!await w(r,n,a,v,E,t));n.frames.length--;for(const e of n.frames){if(e.userInputDelayFlag&&0===e.delayTime){n.totalTime=1/0;break}n.totalTime+=e.delayTime}return n}catch(e){if(e instanceof EvalError)throw new Error(`error while parsing frame ${y} "${e.message}"`);throw e}}(e.source),e.gifLoopCount=function(e){for(const t of e.applicationExtensions)if(t.identifier+t.authenticationCode==="NETSCAPE2.0")return t.data[1]+(t.data[2]<<8);return NaN}(e.gifData)??m,e.gifLoopCount||(e.gifLoopCount=1/0)}catch{e.error=!0}e.loading=!1}else await n(e)}class y{constructor(t){this.validTypes=["image","images"],this.loadImageShape=async t=>{if(!this._engine.loadImage)throw new Error(`${e.errorPrefix} image shape not initialized`);await this._engine.loadImage({gif:t.gif,name:t.name,replaceColor:t.replaceColor??!1,src:t.src})},this._engine=t}addImage(e){this._engine.images||(this._engine.images=[]),this._engine.images.push(e)}draw(e){const{context:t,radius:a,particle:o,opacity:i}=e,n=o.image,r=n?.element;if(n){if(t.globalAlpha=i,n.gif&&n.gifData)!function(e){const{context:t,radius:a,particle:o,delta:i}=e,n=o.image;if(!n?.gifData||!n.gif)return;const r=new OffscreenCanvas(n.gifData.width,n.gifData.height),s=r.getContext("2d");if(!s)throw new Error("could not create offscreen canvas context");s.imageSmoothingQuality="low",s.imageSmoothingEnabled=!1,s.clearRect(f,p,r.width,r.height),void 0===o.gifLoopCount&&(o.gifLoopCount=n.gifLoopCount??m);let l=o.gifFrame??0;const c={x:.5*-n.gifData.width,y:.5*-n.gifData.height},g=n.gifData.frames[l];if(void 0===o.gifTime&&(o.gifTime=0),g.bitmap){switch(t.scale(a/n.gifData.width,a/n.gifData.height),g.disposalMethod){case d.UndefinedA:case d.UndefinedB:case d.UndefinedC:case d.UndefinedD:case d.Replace:s.drawImage(g.bitmap,g.left,g.top),t.drawImage(r,c.x,c.y),s.clearRect(f,p,r.width,r.height);break;case d.Combine:s.drawImage(g.bitmap,g.left,g.top),t.drawImage(r,c.x,c.y);break;case d.RestoreBackground:s.drawImage(g.bitmap,g.left,g.top),t.drawImage(r,c.x,c.y),s.clearRect(f,p,r.width,r.height),n.gifData.globalColorTable.length?s.putImageData(n.gifData.backgroundImage,c.x,c.y):s.putImageData(n.gifData.frames[0].image,c.x+g.left,c.y+g.top);break;case d.RestorePrevious:{const e=s.getImageData(f,p,r.width,r.height);s.drawImage(g.bitmap,g.left,g.top),t.drawImage(r,c.x,c.y),s.clearRect(f,p,r.width,r.height),s.putImageData(e,f,p)}}if(o.gifTime+=i.value,o.gifTime>g.delayTime){if(o.gifTime-=g.delayTime,++l>=n.gifData.frames.length){if(--o.gifLoopCount<=m)return;l=0,s.clearRect(f,p,r.width,r.height)}o.gifFrame=l}t.scale(n.gifData.width/a,n.gifData.height/a)}}(e);else if(r){const e=n.ratio,o={x:-a,y:-a},i=2*a;t.drawImage(r,o.x,o.y,i,i/e)}t.globalAlpha=1}}getSidesCount(){return 12}async init(e){const t=e.actualOptions;if(t.preload&&this._engine.loadImage)for(const e of t.preload)await this._engine.loadImage(e)}loadShape(e){if("image"!==e.shape&&"images"!==e.shape)return;this._engine.images||(this._engine.images=[]);const t=e.shapeData;if(!t)return;this._engine.images.find((e=>e.name===t.name||e.source===t.src))||this.loadImageShape(t).then((()=>{this.loadShape(e)}))}particleInit(e,t){if("image"!==t.shape&&"images"!==t.shape)return;this._engine.images||(this._engine.images=[]);const a=this._engine.images,o=t.shapeData;if(!o)return;const i=t.getFillColor(),n=a.find((e=>e.name===o.name||e.source===o.src));if(!n)return;const r=o.replaceColor??n.replaceColor;n.loading?setTimeout((()=>{this.particleInit(e,t)})):(async()=>{let e;e=n.svgData&&i?await s(n,o,i,t):{color:i,data:n,element:n.element,gif:n.gif,gifData:n.gifData,gifLoopCount:n.gifLoopCount,loaded:!0,ratio:o.width&&o.height?o.width/o.height:n.ratio??1,replaceColor:r,source:o.src},e.ratio||(e.ratio=1);const a={image:e,fill:o.fill??t.shapeFill,close:o.close??t.shapeClose};t.image=a.image,t.shapeFill=a.fill,t.shapeClose=a.close})()}}class b{constructor(){this.src="",this.gif=!1}load(e){e&&(void 0!==e.gif&&(this.gif=e.gif),void 0!==e.height&&(this.height=e.height),void 0!==e.name&&(this.name=e.name),void 0!==e.replaceColor&&(this.replaceColor=e.replaceColor),void 0!==e.src&&(this.src=e.src),void 0!==e.width&&(this.width=e.width))}}class C{constructor(e){this.id="imagePreloader",this._engine=e}async getPlugin(){return await Promise.resolve(),{}}loadOptions(e,t){if(!t?.preload)return;e.preload||(e.preload=[]);const a=e.preload;for(const e of t.preload){const t=a.find((t=>t.name===e.name||t.src===e.src));if(t)t.load(e);else{const t=new b;t.load(e),a.push(t)}}}needsPlugin(){return!0}}const v=3;async function E(t,a=!0){!function(t){t.loadImage||(t.loadImage=async a=>{if(!a.name&&!a.src)throw new Error(`${e.errorPrefix} no image source provided`);if(t.images||(t.images=[]),!t.images.find((e=>e.name===a.name||e.source===a.src)))try{const e={gif:a.gif??!1,name:a.name??a.src,source:a.src,type:a.src.substring(a.src.length-v),error:!1,loading:!0,replaceColor:a.replaceColor,ratio:a.width&&a.height?a.width/a.height:void 0};let o;t.images.push(e),o=a.gif?x:a.replaceColor?r:n,await o(e)}catch{throw new Error(`${e.errorPrefix} ${a.name??a.src} not found`)}})}(t);const o=new C(t);await t.addPlugin(o,a),await t.addShape(new y(t),a)}})(),i})())); |
@@ -1,1 +0,1 @@ | ||
/*! tsParticles Image Shape v3.3.0 by Matteo Bruni */ | ||
/*! tsParticles Image Shape v3.4.0 by Matteo Bruni */ |
@@ -1,2 +0,2 @@ | ||
export declare const enum DisposalMethod { | ||
export declare enum DisposalMethod { | ||
Replace = 0, | ||
@@ -3,0 +3,0 @@ Combine = 1, |
@@ -1,2 +0,2 @@ | ||
export declare const enum GIFDataHeaders { | ||
export declare enum GIFDataHeaders { | ||
Extension = 33, | ||
@@ -3,0 +3,0 @@ ApplicationExtension = 255, |
import type { IShapeDrawData } from "@tsparticles/engine"; | ||
import type { IImage, ImageParticle } from "../Utils.js"; | ||
import { type IImage, type ImageParticle } from "../Utils.js"; | ||
import type { GIF } from "./Types/GIF.js"; | ||
@@ -4,0 +4,0 @@ import type { GIFProgressCallbackFunction } from "./Types/GIFProgressCallbackFunction.js"; |
@@ -5,2 +5,3 @@ import { type Container, type IShapeDrawData, type IShapeDrawer } from "@tsparticles/engine"; | ||
export declare class ImageDrawer implements IShapeDrawer<ImageParticle> { | ||
readonly validTypes: readonly ["image", "images"]; | ||
private readonly _engine; | ||
@@ -7,0 +8,0 @@ constructor(engine: ImageEngine); |
@@ -12,2 +12,14 @@ (function (factory) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DisposalMethod = void 0; | ||
var DisposalMethod; | ||
(function (DisposalMethod) { | ||
DisposalMethod[DisposalMethod["Replace"] = 0] = "Replace"; | ||
DisposalMethod[DisposalMethod["Combine"] = 1] = "Combine"; | ||
DisposalMethod[DisposalMethod["RestoreBackground"] = 2] = "RestoreBackground"; | ||
DisposalMethod[DisposalMethod["RestorePrevious"] = 3] = "RestorePrevious"; | ||
DisposalMethod[DisposalMethod["UndefinedA"] = 4] = "UndefinedA"; | ||
DisposalMethod[DisposalMethod["UndefinedB"] = 5] = "UndefinedB"; | ||
DisposalMethod[DisposalMethod["UndefinedC"] = 6] = "UndefinedC"; | ||
DisposalMethod[DisposalMethod["UndefinedD"] = 7] = "UndefinedD"; | ||
})(DisposalMethod || (exports.DisposalMethod = DisposalMethod = {})); | ||
}); |
@@ -12,2 +12,13 @@ (function (factory) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GIFDataHeaders = void 0; | ||
var GIFDataHeaders; | ||
(function (GIFDataHeaders) { | ||
GIFDataHeaders[GIFDataHeaders["Extension"] = 33] = "Extension"; | ||
GIFDataHeaders[GIFDataHeaders["ApplicationExtension"] = 255] = "ApplicationExtension"; | ||
GIFDataHeaders[GIFDataHeaders["GraphicsControlExtension"] = 249] = "GraphicsControlExtension"; | ||
GIFDataHeaders[GIFDataHeaders["PlainTextExtension"] = 1] = "PlainTextExtension"; | ||
GIFDataHeaders[GIFDataHeaders["CommentExtension"] = 254] = "CommentExtension"; | ||
GIFDataHeaders[GIFDataHeaders["Image"] = 44] = "Image"; | ||
GIFDataHeaders[GIFDataHeaders["EndOfFile"] = 59] = "EndOfFile"; | ||
})(GIFDataHeaders || (exports.GIFDataHeaders = GIFDataHeaders = {})); | ||
}); |
@@ -1,24 +0,1 @@ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
(function (factory) { | ||
@@ -30,11 +7,13 @@ if (typeof module === "object" && typeof module.exports === "object") { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./Constants.js", "./ByteStream.js"], factory); | ||
define(["require", "exports", "../Utils.js", "./Constants.js", "./ByteStream.js", "./Enums/DisposalMethod.js", "./Types/GIFDataHeaders.js"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
var __syncRequire = typeof module === "object" && typeof module.exports === "object"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadGifImage = exports.drawGif = exports.decodeGIF = exports.getGIFLoopAmount = void 0; | ||
const Utils_js_1 = require("../Utils.js"); | ||
const Constants_js_1 = require("./Constants.js"); | ||
const ByteStream_js_1 = require("./ByteStream.js"); | ||
const DisposalMethod_js_1 = require("./Enums/DisposalMethod.js"); | ||
const GIFDataHeaders_js_1 = require("./Types/GIFDataHeaders.js"); | ||
const origin = { | ||
@@ -58,3 +37,3 @@ x: 0, | ||
switch (byteStream.nextByte()) { | ||
case 249: { | ||
case GIFDataHeaders_js_1.GIFDataHeaders.GraphicsControlExtension: { | ||
const frame = gif.frames[getFrameIndex(false)]; | ||
@@ -75,3 +54,3 @@ byteStream.pos++; | ||
} | ||
case 255: { | ||
case GIFDataHeaders_js_1.GIFDataHeaders.ApplicationExtension: { | ||
byteStream.pos++; | ||
@@ -86,7 +65,7 @@ const applicationExtension = { | ||
} | ||
case 254: { | ||
case GIFDataHeaders_js_1.GIFDataHeaders.CommentExtension: { | ||
gif.comments.push([getFrameIndex(false), byteStream.readSubBlocks()]); | ||
break; | ||
} | ||
case 1: { | ||
case GIFDataHeaders_js_1.GIFDataHeaders.PlainTextExtension: { | ||
if (gif.globalColorTable.length === 0) { | ||
@@ -244,8 +223,8 @@ throw new EvalError("plain text extension without global color table"); | ||
switch (byteStream.nextByte()) { | ||
case 59: | ||
case GIFDataHeaders_js_1.GIFDataHeaders.EndOfFile: | ||
return true; | ||
case 44: | ||
case GIFDataHeaders_js_1.GIFDataHeaders.Image: | ||
await parseImageBlock(byteStream, gif, avgAlpha, getFrameIndex, getTransparencyIndex, progressCallback); | ||
break; | ||
case 33: | ||
case GIFDataHeaders_js_1.GIFDataHeaders.Extension: | ||
parseExtensionBlock(byteStream, gif, getFrameIndex, getTransparencyIndex); | ||
@@ -346,3 +325,3 @@ break; | ||
height: 0, | ||
disposalMethod: 0, | ||
disposalMethod: DisposalMethod_js_1.DisposalMethod.Replace, | ||
image: new ImageData(1, 1, { colorSpace: "srgb" }), | ||
@@ -405,7 +384,7 @@ plainTextData: null, | ||
switch (frame.disposalMethod) { | ||
case 4: | ||
case 5: | ||
case 6: | ||
case 7: | ||
case 0: | ||
case DisposalMethod_js_1.DisposalMethod.UndefinedA: | ||
case DisposalMethod_js_1.DisposalMethod.UndefinedB: | ||
case DisposalMethod_js_1.DisposalMethod.UndefinedC: | ||
case DisposalMethod_js_1.DisposalMethod.UndefinedD: | ||
case DisposalMethod_js_1.DisposalMethod.Replace: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
@@ -415,7 +394,7 @@ context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 1: | ||
case DisposalMethod_js_1.DisposalMethod.Combine: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 2: | ||
case DisposalMethod_js_1.DisposalMethod.RestoreBackground: | ||
offscreenContext.drawImage(frame.bitmap, frame.left, frame.top); | ||
@@ -431,3 +410,3 @@ context.drawImage(offscreenCanvas, pos.x, pos.y); | ||
break; | ||
case 3: | ||
case DisposalMethod_js_1.DisposalMethod.RestorePrevious: | ||
{ | ||
@@ -459,4 +438,3 @@ const previousImageData = offscreenContext.getImageData(origin.x, origin.y, offscreenCanvas.width, offscreenCanvas.height); | ||
if (image.type !== "gif") { | ||
const { loadImage } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("../Utils.js"))) : new Promise((resolve_1, reject_1) => { require(["../Utils.js"], resolve_1, reject_1); }).then(__importStar)); | ||
await loadImage(image); | ||
await (0, Utils_js_1.loadImage)(image); | ||
return; | ||
@@ -463,0 +441,0 @@ } |
@@ -19,2 +19,3 @@ (function (factory) { | ||
constructor(engine) { | ||
this.validTypes = ["image", "images"]; | ||
this.loadImageShape = async (imageShape) => { | ||
@@ -21,0 +22,0 @@ if (!this._engine.loadImage) { |
@@ -32,3 +32,3 @@ (function (factory) { | ||
for (const item of source.preload) { | ||
const existing = preloadOptions.find((t) => t.name === item.name || t.src === item.src); | ||
const existing = preloadOptions.find(t => t.name === item.name || t.src === item.src); | ||
if (existing) { | ||
@@ -35,0 +35,0 @@ existing.load(item); |
@@ -1,24 +0,1 @@ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
(function (factory) { | ||
@@ -30,11 +7,13 @@ if (typeof module === "object" && typeof module.exports === "object") { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./Utils.js", "@tsparticles/engine"], factory); | ||
define(["require", "exports", "./Utils.js", "./ImageDrawer.js", "./ImagePreloader.js", "@tsparticles/engine", "./GifUtils/Utils.js"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
var __syncRequire = typeof module === "object" && typeof module.exports === "object"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadImageShape = void 0; | ||
const Utils_js_1 = require("./Utils.js"); | ||
const ImageDrawer_js_1 = require("./ImageDrawer.js"); | ||
const ImagePreloader_js_1 = require("./ImagePreloader.js"); | ||
const engine_1 = require("@tsparticles/engine"); | ||
const Utils_js_2 = require("./GifUtils/Utils.js"); | ||
const extLength = 3; | ||
@@ -69,4 +48,3 @@ function addLoadImageToEngine(engine) { | ||
if (data.gif) { | ||
const { loadGifImage } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./GifUtils/Utils.js"))) : new Promise((resolve_1, reject_1) => { require(["./GifUtils/Utils.js"], resolve_1, reject_1); }).then(__importStar)); | ||
imageFunc = loadGifImage; | ||
imageFunc = Utils_js_2.loadGifImage; | ||
} | ||
@@ -85,8 +63,7 @@ else { | ||
addLoadImageToEngine(engine); | ||
const { ImagePreloaderPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./ImagePreloader.js"))) : new Promise((resolve_2, reject_2) => { require(["./ImagePreloader.js"], resolve_2, reject_2); }).then(__importStar)), { ImageDrawer } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./ImageDrawer.js"))) : new Promise((resolve_3, reject_3) => { require(["./ImageDrawer.js"], resolve_3, reject_3); }).then(__importStar)); | ||
const preloader = new ImagePreloaderPlugin(engine); | ||
const preloader = new ImagePreloader_js_1.ImagePreloaderPlugin(engine); | ||
await engine.addPlugin(preloader, refresh); | ||
await engine.addShape(["image", "images"], new ImageDrawer(engine), refresh); | ||
await engine.addShape(new ImageDrawer_js_1.ImageDrawer(engine), refresh); | ||
} | ||
exports.loadImageShape = loadImageShape; | ||
}); |
@@ -78,3 +78,3 @@ (function (factory) { | ||
}; | ||
return new Promise((resolve) => { | ||
return new Promise(resolve => { | ||
const svg = new Blob([svgColoredData], { type: "image/svg+xml" }), domUrl = URL || window.URL || window.webkitURL || window, url = domUrl.createObjectURL(svg), img = new Image(); | ||
@@ -81,0 +81,0 @@ img.addEventListener("load", () => { |
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
489793
100
4147
20
Updated@tsparticles/engine@^3.4.0