tsparticles-shape-polygon
Advanced tools
Comparing version 2.3.3 to 2.4.0
import { PolygonDrawerBase } from "./PolygonDrawerBase"; | ||
/** | ||
* @category Shape Drawers | ||
*/ | ||
export class PolygonDrawer extends PolygonDrawerBase { | ||
@@ -6,0 +3,0 @@ getCenter(particle, radius) { |
@@ -1,4 +0,1 @@ | ||
/** | ||
* @category Shape Drawers | ||
*/ | ||
export class PolygonDrawerBase { | ||
@@ -8,7 +5,6 @@ draw(context, particle, radius) { | ||
const side = this.getSidesData(particle, radius); | ||
// By Programming Thomas - https://programmingthomas.wordpress.com/2013/04/03/n-sided-shapes/ | ||
const sideCount = side.count.numerator * side.count.denominator; | ||
const decimalSides = side.count.numerator / side.count.denominator; | ||
const interiorAngleDegrees = (180 * (decimalSides - 2)) / decimalSides; | ||
const interiorAngle = Math.PI - (Math.PI * interiorAngleDegrees) / 180; // convert to radians | ||
const interiorAngle = Math.PI - (Math.PI * interiorAngleDegrees) / 180; | ||
if (!context) { | ||
@@ -15,0 +11,0 @@ return; |
import { PolygonDrawerBase } from "./PolygonDrawerBase"; | ||
/** | ||
* @category Shape Drawers | ||
*/ | ||
export class TriangleDrawer extends PolygonDrawerBase { | ||
@@ -6,0 +3,0 @@ getCenter(particle, radius) { |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -6,14 +15,20 @@ exports.loadPolygonShape = exports.loadTriangleShape = exports.loadGenericPolygonShape = void 0; | ||
const TriangleDrawer_1 = require("./TriangleDrawer"); | ||
async function loadGenericPolygonShape(engine) { | ||
await engine.addShape("polygon", new PolygonDrawer_1.PolygonDrawer()); | ||
function loadGenericPolygonShape(engine) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield engine.addShape("polygon", new PolygonDrawer_1.PolygonDrawer()); | ||
}); | ||
} | ||
exports.loadGenericPolygonShape = loadGenericPolygonShape; | ||
async function loadTriangleShape(engine) { | ||
await engine.addShape("triangle", new TriangleDrawer_1.TriangleDrawer()); | ||
function loadTriangleShape(engine) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield engine.addShape("triangle", new TriangleDrawer_1.TriangleDrawer()); | ||
}); | ||
} | ||
exports.loadTriangleShape = loadTriangleShape; | ||
async function loadPolygonShape(engine) { | ||
await loadGenericPolygonShape(engine); | ||
await loadTriangleShape(engine); | ||
function loadPolygonShape(engine) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield loadGenericPolygonShape(engine); | ||
yield loadTriangleShape(engine); | ||
}); | ||
} | ||
exports.loadPolygonShape = loadPolygonShape; |
{ | ||
"name": "tsparticles-shape-polygon", | ||
"version": "2.3.3", | ||
"version": "2.4.0", | ||
"description": "tsParticles polygon shape", | ||
@@ -49,4 +49,4 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"tsparticles-engine": "^2.3.3" | ||
"tsparticles-engine": "^2.4.0" | ||
} | ||
} |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.3.3 | ||
* v2.4.0 | ||
*/ | ||
@@ -67,23 +67,16 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
;// CONCATENATED MODULE: ./dist/browser/PolygonDrawerBase.js | ||
/** | ||
* @category Shape Drawers | ||
*/ | ||
class PolygonDrawerBase { | ||
draw(context, particle, radius) { | ||
const start = this.getCenter(particle, radius); | ||
const side = this.getSidesData(particle, radius); // By Programming Thomas - https://programmingthomas.wordpress.com/2013/04/03/n-sided-shapes/ | ||
const side = this.getSidesData(particle, radius); | ||
const sideCount = side.count.numerator * side.count.denominator; | ||
const decimalSides = side.count.numerator / side.count.denominator; | ||
const interiorAngleDegrees = 180 * (decimalSides - 2) / decimalSides; | ||
const interiorAngle = Math.PI - Math.PI * interiorAngleDegrees / 180; // convert to radians | ||
const interiorAngle = Math.PI - Math.PI * interiorAngleDegrees / 180; | ||
if (!context) { | ||
return; | ||
} | ||
context.beginPath(); | ||
context.translate(start.x, start.y); | ||
context.moveTo(0, 0); | ||
for (let i = 0; i < sideCount; i++) { | ||
@@ -95,17 +88,10 @@ context.lineTo(side.length, 0); | ||
} | ||
getSidesCount(particle) { | ||
var _a, _b; | ||
const polygon = particle.shapeData; | ||
return (_b = (_a = polygon === null || polygon === void 0 ? void 0 : polygon.sides) !== null && _a !== void 0 ? _a : polygon === null || polygon === void 0 ? void 0 : polygon.nb_sides) !== null && _b !== void 0 ? _b : 5; | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/PolygonDrawer.js | ||
/** | ||
* @category Shape Drawers | ||
*/ | ||
class PolygonDrawer extends PolygonDrawerBase { | ||
@@ -119,6 +105,4 @@ getCenter(particle, radius) { | ||
} | ||
getSidesData(particle, radius) { | ||
var _a, _b; | ||
const polygon = particle.shapeData; | ||
@@ -134,10 +118,5 @@ const sides = (_b = (_a = polygon === null || polygon === void 0 ? void 0 : polygon.sides) !== null && _a !== void 0 ? _a : polygon === null || polygon === void 0 ? void 0 : polygon.nb_sides) !== null && _b !== void 0 ? _b : 5; | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/TriangleDrawer.js | ||
/** | ||
* @category Shape Drawers | ||
*/ | ||
class TriangleDrawer extends PolygonDrawerBase { | ||
@@ -150,7 +129,5 @@ getCenter(particle, radius) { | ||
} | ||
getSidesCount() { | ||
return 3; | ||
} | ||
getSidesData(particle, radius) { | ||
@@ -165,3 +142,2 @@ return { | ||
} | ||
} | ||
@@ -168,0 +144,0 @@ ;// CONCATENATED MODULE: ./dist/browser/index.js |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.3.3 | ||
* v2.4.0 | ||
*/ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
309228
616
Updatedtsparticles-engine@^2.4.0