This commit is contained in:
2025-01-04 00:34:03 +01:00
parent 41829408dc
commit 0ca14bbc19
18111 changed files with 1871397 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Ivan Popelyshev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,61 @@
'use strict';
var SmoothShader = require('./SmoothShader.js');
const dashFrag = `%PRECISION%
varying vec4 vColor;
varying vec4 vLine1;
varying vec4 vLine2;
varying vec4 vArc;
varying float vType;
varying float vTextureId;
varying vec2 vTextureCoord;
varying vec2 vTravel;
uniform sampler2D uSamplers[%MAX_TEXTURES%];
uniform float dash;
uniform float gap;
%PIXEL_LINE%
void main(void){
%PIXEL_COVERAGE%
float d = dash * vTravel.y;
if (d > 0.0) {
float g = gap * vTravel.y;
if (g > 0.0) {
float t = mod(vTravel.x, d + g);
alpha *= mix(
min(0.5 * d + 0.5 - abs(t - 0.5 * d), 1.0),
max(abs(t - 0.5 * g - d) - 0.5 * g + 0.5, 0.0),
step(d, t)
);
}
} else {
alpha = 0.0;
}
vec4 texColor;
float textureId = floor(vTextureId+0.5);
%FOR_LOOP%
gl_FragColor = vColor * texColor * alpha;
}
`;
class DashLineShader extends SmoothShader.SmoothGraphicsShader {
constructor(dashParams) {
const settings = { maxStyles: 16, maxTextures: 1, pixelLine: 1 };
super(
settings,
void 0,
dashFrag,
dashParams || {
dash: 8,
gap: 5
}
);
}
}
exports.DashLineShader = DashLineShader;
//# sourceMappingURL=DashLineShader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DashLineShader.js","sources":["../src/DashLineShader.ts"],"sourcesContent":["import { SmoothGraphicsShader } from './SmoothShader';\r\n\r\nconst dashFrag = `%PRECISION%\r\nvarying vec4 vColor;\r\nvarying vec4 vLine1;\r\nvarying vec4 vLine2;\r\nvarying vec4 vArc;\r\nvarying float vType;\r\nvarying float vTextureId;\r\nvarying vec2 vTextureCoord;\r\nvarying vec2 vTravel;\r\nuniform sampler2D uSamplers[%MAX_TEXTURES%];\r\nuniform float dash;\r\nuniform float gap;\r\n\r\n%PIXEL_LINE%\r\n\r\nvoid main(void){\r\n %PIXEL_COVERAGE%\r\n\r\n float d = dash * vTravel.y;\r\n if (d > 0.0) {\r\n float g = gap * vTravel.y;\r\n if (g > 0.0) {\r\n float t = mod(vTravel.x, d + g);\r\n alpha *= mix(\r\n min(0.5 * d + 0.5 - abs(t - 0.5 * d), 1.0),\r\n max(abs(t - 0.5 * g - d) - 0.5 * g + 0.5, 0.0),\r\n step(d, t)\r\n );\r\n }\r\n } else {\r\n alpha = 0.0;\r\n }\r\n\r\n vec4 texColor;\r\n float textureId = floor(vTextureId+0.5);\r\n %FOR_LOOP%\r\n\r\n gl_FragColor = vColor * texColor * alpha;\r\n}\r\n`;\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport interface IDashParams\r\n{\r\n dash: number;\r\n gap: number;\r\n}\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class DashLineShader extends SmoothGraphicsShader\r\n{\r\n constructor(dashParams?: IDashParams)\r\n {\r\n const settings = { maxStyles: 16, maxTextures: 1, pixelLine: 1 };\r\n\r\n super(settings, undefined, dashFrag,\r\n dashParams || {\r\n dash: 8.0,\r\n gap: 5.0\r\n });\r\n }\r\n}\r\n"],"names":["SmoothGraphicsShader"],"mappings":";;;;AAEA,MAAM,QAAW,GAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAAA;AAqDV,MAAM,uBAAuBA,iCACpC,CAAA;AAAA,EACI,YAAY,UACZ,EAAA;AACI,IAAA,MAAM,WAAW,EAAE,SAAA,EAAW,IAAI,WAAa,EAAA,CAAA,EAAG,WAAW,CAAE,EAAA,CAAA;AAE/D,IAAA,KAAA;AAAA,MAAM,QAAA;AAAA,MAAU,KAAA,CAAA;AAAA,MAAW,QAAA;AAAA,MACvB,UAAc,IAAA;AAAA,QACV,IAAM,EAAA,CAAA;AAAA,QACN,GAAK,EAAA,CAAA;AAAA,OACT;AAAA,KAAC,CAAA;AAAA,GACT;AACJ;;;;"}

View File

@@ -0,0 +1,59 @@
import { SmoothGraphicsShader } from './SmoothShader.mjs';
const dashFrag = `%PRECISION%
varying vec4 vColor;
varying vec4 vLine1;
varying vec4 vLine2;
varying vec4 vArc;
varying float vType;
varying float vTextureId;
varying vec2 vTextureCoord;
varying vec2 vTravel;
uniform sampler2D uSamplers[%MAX_TEXTURES%];
uniform float dash;
uniform float gap;
%PIXEL_LINE%
void main(void){
%PIXEL_COVERAGE%
float d = dash * vTravel.y;
if (d > 0.0) {
float g = gap * vTravel.y;
if (g > 0.0) {
float t = mod(vTravel.x, d + g);
alpha *= mix(
min(0.5 * d + 0.5 - abs(t - 0.5 * d), 1.0),
max(abs(t - 0.5 * g - d) - 0.5 * g + 0.5, 0.0),
step(d, t)
);
}
} else {
alpha = 0.0;
}
vec4 texColor;
float textureId = floor(vTextureId+0.5);
%FOR_LOOP%
gl_FragColor = vColor * texColor * alpha;
}
`;
class DashLineShader extends SmoothGraphicsShader {
constructor(dashParams) {
const settings = { maxStyles: 16, maxTextures: 1, pixelLine: 1 };
super(
settings,
void 0,
dashFrag,
dashParams || {
dash: 8,
gap: 5
}
);
}
}
export { DashLineShader };
//# sourceMappingURL=DashLineShader.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DashLineShader.mjs","sources":["../src/DashLineShader.ts"],"sourcesContent":["import { SmoothGraphicsShader } from './SmoothShader';\r\n\r\nconst dashFrag = `%PRECISION%\r\nvarying vec4 vColor;\r\nvarying vec4 vLine1;\r\nvarying vec4 vLine2;\r\nvarying vec4 vArc;\r\nvarying float vType;\r\nvarying float vTextureId;\r\nvarying vec2 vTextureCoord;\r\nvarying vec2 vTravel;\r\nuniform sampler2D uSamplers[%MAX_TEXTURES%];\r\nuniform float dash;\r\nuniform float gap;\r\n\r\n%PIXEL_LINE%\r\n\r\nvoid main(void){\r\n %PIXEL_COVERAGE%\r\n\r\n float d = dash * vTravel.y;\r\n if (d > 0.0) {\r\n float g = gap * vTravel.y;\r\n if (g > 0.0) {\r\n float t = mod(vTravel.x, d + g);\r\n alpha *= mix(\r\n min(0.5 * d + 0.5 - abs(t - 0.5 * d), 1.0),\r\n max(abs(t - 0.5 * g - d) - 0.5 * g + 0.5, 0.0),\r\n step(d, t)\r\n );\r\n }\r\n } else {\r\n alpha = 0.0;\r\n }\r\n\r\n vec4 texColor;\r\n float textureId = floor(vTextureId+0.5);\r\n %FOR_LOOP%\r\n\r\n gl_FragColor = vColor * texColor * alpha;\r\n}\r\n`;\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport interface IDashParams\r\n{\r\n dash: number;\r\n gap: number;\r\n}\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class DashLineShader extends SmoothGraphicsShader\r\n{\r\n constructor(dashParams?: IDashParams)\r\n {\r\n const settings = { maxStyles: 16, maxTextures: 1, pixelLine: 1 };\r\n\r\n super(settings, undefined, dashFrag,\r\n dashParams || {\r\n dash: 8.0,\r\n gap: 5.0\r\n });\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAEA,MAAM,QAAW,GAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAAA;AAqDV,MAAM,uBAAuB,oBACpC,CAAA;AAAA,EACI,YAAY,UACZ,EAAA;AACI,IAAA,MAAM,WAAW,EAAE,SAAA,EAAW,IAAI,WAAa,EAAA,CAAA,EAAG,WAAW,CAAE,EAAA,CAAA;AAE/D,IAAA,KAAA;AAAA,MAAM,QAAA;AAAA,MAAU,KAAA,CAAA;AAAA,MAAW,QAAA;AAAA,MACvB,UAAc,IAAA;AAAA,QACV,IAAM,EAAA,CAAA;AAAA,QACN,GAAK,EAAA,CAAA;AAAA,OACT;AAAA,KAAC,CAAA;AAAA,GACT;AACJ;;;;"}

View File

@@ -0,0 +1,543 @@
'use strict';
var core = require('@pixi/core');
var graphics = require('@pixi/graphics');
var SmoothGraphicsGeometry = require('./SmoothGraphicsGeometry.js');
var display = require('@pixi/display');
var FillStyle = require('./core/FillStyle.js');
var LineStyle = require('./core/LineStyle.js');
var SmoothShader = require('./SmoothShader.js');
var settings = require('./settings.js');
const UnsmoothGraphics = graphics.Graphics;
const { BezierUtils, QuadraticUtils, ArcUtils } = graphics.graphicsUtils;
const DEFAULT_SHADERS = {};
const _SmoothGraphics = class extends display.Container {
constructor(geometry = null) {
super();
this._geometry = geometry || new SmoothGraphicsGeometry.SmoothGraphicsGeometry();
this._geometry.refCount++;
this.shader = null;
this.shaderSettings = {
maxStyles: settings.settings.SHADER_MAX_STYLES,
maxTextures: settings.settings.SHADER_MAX_TEXTURES,
pixelLine: settings.settings.PIXEL_LINE
};
this.state = core.State.for2d();
this._fillStyle = new FillStyle.FillStyle();
this._lineStyle = new LineStyle.LineStyle();
this._matrix = null;
this._holeMode = false;
this.currentPath = null;
this.batches = [];
this.batchTint = -1;
this.batchDirty = -1;
this.vertexData = null;
this.pluginName = "smooth";
this._transformID = -1;
this._tintColor = new core.Color(16777215);
this.blendMode = core.BLEND_MODES.NORMAL;
}
get geometry() {
return this._geometry;
}
clone() {
this.finishPoly();
return new _SmoothGraphics(this._geometry);
}
set blendMode(value) {
this.state.blendMode = value;
}
get blendMode() {
return this.state.blendMode;
}
get tint() {
return this._tintColor.value;
}
set tint(value) {
this._tintColor.setValue(value);
}
get fill() {
return this._fillStyle;
}
get line() {
return this._lineStyle;
}
lineStyle(options = null, color = 0, alpha = 1, alignment = 0.5, scaleMode = settings.settings.LINE_SCALE_MODE) {
if (typeof options === "number") {
if (typeof scaleMode === "boolean") {
scaleMode = scaleMode ? LineStyle.LINE_SCALE_MODE.NONE : LineStyle.LINE_SCALE_MODE.NORMAL;
}
options = { width: options, color, alpha, alignment, scaleMode };
} else {
const native = options.native;
if (native !== void 0) {
options.scaleMode = native ? LineStyle.LINE_SCALE_MODE.NONE : LineStyle.LINE_SCALE_MODE.NORMAL;
}
}
return this.lineTextureStyle(options);
}
lineTextureStyle(options) {
options = Object.assign({
width: 0,
texture: core.Texture.WHITE,
color: options && options.texture ? 16777215 : 0,
alpha: 1,
matrix: null,
alignment: 0.5,
native: false,
cap: graphics.LINE_CAP.BUTT,
join: graphics.LINE_JOIN.MITER,
miterLimit: 10,
shader: null,
scaleMode: settings.settings.LINE_SCALE_MODE
}, options);
this.normalizeColor(options);
if (this.currentPath) {
this.startPoly();
}
const visible = options.width > 0 && options.alpha > 0;
if (!visible) {
this._lineStyle.reset();
} else {
if (options.matrix) {
options.matrix = options.matrix.clone();
options.matrix.invert();
}
Object.assign(this._lineStyle, { visible }, options);
}
return this;
}
startPoly() {
if (this.currentPath) {
const points = this.currentPath.points;
const len = this.currentPath.points.length;
if (len > 2) {
this.drawShape(this.currentPath);
this.currentPath = new core.Polygon();
this.currentPath.closeStroke = false;
this.currentPath.points.push(points[len - 2], points[len - 1]);
}
} else {
this.currentPath = new core.Polygon();
this.currentPath.closeStroke = false;
}
}
finishPoly() {
if (this.currentPath) {
if (this.currentPath.points.length > 2) {
this.drawShape(this.currentPath);
this.currentPath = null;
} else {
this.currentPath.points.length = 0;
}
}
}
moveTo(x, y) {
this.startPoly();
this.currentPath.points[0] = x;
this.currentPath.points[1] = y;
return this;
}
lineTo(x, y) {
if (!this.currentPath) {
this.moveTo(0, 0);
}
const points = this.currentPath.points;
const fromX = points[points.length - 2];
const fromY = points[points.length - 1];
if (fromX !== x || fromY !== y) {
points.push(x, y);
}
return this;
}
_initCurve(x = 0, y = 0) {
if (this.currentPath) {
if (this.currentPath.points.length === 0) {
this.currentPath.points = [x, y];
}
} else {
this.moveTo(x, y);
}
}
quadraticCurveTo(cpX, cpY, toX, toY) {
this._initCurve();
const points = this.currentPath.points;
if (points.length === 0) {
this.moveTo(0, 0);
}
QuadraticUtils.curveTo(cpX, cpY, toX, toY, points);
return this;
}
bezierCurveTo(cpX, cpY, cpX2, cpY2, toX, toY) {
this._initCurve();
BezierUtils.curveTo(cpX, cpY, cpX2, cpY2, toX, toY, this.currentPath.points);
return this;
}
arcTo(x1, y1, x2, y2, radius) {
this._initCurve(x1, y1);
const points = this.currentPath.points;
const result = ArcUtils.curveTo(x1, y1, x2, y2, radius, points);
if (result) {
const { cx, cy, radius: radius2, startAngle, endAngle, anticlockwise } = result;
this.arc(cx, cy, radius2, startAngle, endAngle, anticlockwise);
}
return this;
}
arc(cx, cy, radius, startAngle, endAngle, anticlockwise = false) {
if (startAngle === endAngle) {
return this;
}
if (!anticlockwise && endAngle <= startAngle) {
endAngle += core.PI_2;
} else if (anticlockwise && startAngle <= endAngle) {
startAngle += core.PI_2;
}
const sweep = endAngle - startAngle;
if (sweep === 0) {
return this;
}
const startX = cx + Math.cos(startAngle) * radius;
const startY = cy + Math.sin(startAngle) * radius;
const eps = this._geometry.closePointEps;
let points = this.currentPath ? this.currentPath.points : null;
if (points) {
const xDiff = Math.abs(points[points.length - 2] - startX);
const yDiff = Math.abs(points[points.length - 1] - startY);
if (xDiff < eps && yDiff < eps) ; else {
points.push(startX, startY);
}
} else {
this.moveTo(startX, startY);
points = this.currentPath.points;
}
ArcUtils.arc(startX, startY, cx, cy, radius, startAngle, endAngle, anticlockwise, points);
return this;
}
beginFill(color = 0, alpha = 1, smooth = false) {
return this.beginTextureFill({ texture: core.Texture.WHITE, color, alpha, smooth });
}
normalizeColor(options) {
const temp = core.Color.shared.setValue(options.color ?? 0);
options.color = temp.toNumber();
options.alpha ?? (options.alpha = temp.alpha);
}
beginTextureFill(options) {
options = Object.assign({
texture: core.Texture.WHITE,
color: 16777215,
alpha: 1,
matrix: null,
smooth: false
}, options);
this.normalizeColor(options);
if (this.currentPath) {
this.startPoly();
}
const visible = options.alpha > 0;
if (!visible) {
this._fillStyle.reset();
} else {
if (options.matrix) {
options.matrix = options.matrix.clone();
options.matrix.invert();
}
Object.assign(this._fillStyle, { visible }, options);
}
return this;
}
endFill() {
this.finishPoly();
this._fillStyle.reset();
return this;
}
drawRect(x, y, width, height) {
return this.drawShape(new core.Rectangle(x, y, width, height));
}
drawRoundedRect(x, y, width, height, radius) {
return this.drawShape(new core.RoundedRectangle(x, y, width, height, radius));
}
drawCircle(x, y, radius) {
return this.drawShape(new core.Circle(x, y, radius));
}
drawEllipse(x, y, width, height) {
return this.drawShape(new core.Ellipse(x, y, width, height));
}
drawPolygon(...path) {
let points;
let closeStroke = true;
const poly = path[0];
if (poly.points) {
closeStroke = poly.closeStroke;
points = poly.points;
} else if (Array.isArray(path[0])) {
points = path[0];
} else {
points = path;
}
const shape = new core.Polygon(points);
shape.closeStroke = closeStroke;
this.drawShape(shape);
return this;
}
drawShape(shape) {
if (!this._holeMode) {
this._geometry.drawShape(
shape,
this._fillStyle.clone(),
this._lineStyle.clone(),
this._matrix
);
} else {
this._geometry.drawHole(shape, this._matrix);
}
return this;
}
clear() {
this._geometry.clear();
this._lineStyle.reset();
this._fillStyle.reset();
this._boundsID++;
this._matrix = null;
this._holeMode = false;
this.currentPath = null;
return this;
}
isFastRect() {
const data = this._geometry.graphicsData;
return data.length === 1 && data[0].shape.type === core.SHAPES.RECT && !data[0].matrix && !data[0].holes.length && !(data[0].lineStyle.visible && data[0].lineStyle.width);
}
_renderCanvas(renderer) {
UnsmoothGraphics.prototype._renderCanvas.call(this, renderer);
}
_render(renderer) {
this.finishPoly();
const geometry = this._geometry;
const hasuint32 = renderer.context.supports.uint32Indices;
geometry.checkInstancing(renderer.geometry.hasInstance, hasuint32);
geometry.updateBatches(this.shaderSettings);
if (geometry.batchable) {
if (this.batchDirty !== geometry.batchDirty) {
this._populateBatches();
}
this._renderBatched(renderer);
} else {
renderer.batch.flush();
this._renderDirect(renderer);
}
}
_populateBatches() {
const geometry = this._geometry;
const blendMode = this.blendMode;
const len = geometry.batches.length;
this.batchTint = -1;
this._transformID = -1;
this.batchDirty = geometry.batchDirty;
this.batches.length = len;
this.vertexData = new Float32Array(geometry.points);
for (let i = 0; i < len; i++) {
const gI = geometry.batches[i];
const color = gI.style.color;
const vertexData = new Float32Array(
this.vertexData.buffer,
gI.attribStart * 4 * 2,
gI.attribSize * 2
);
const batch = {
vertexData,
blendMode,
// indices,
// uvs,
_batchRGB: core.utils.hex2rgb(color),
_tintRGB: color,
_texture: gI.style.texture,
alpha: gI.style.alpha,
worldAlpha: 1
};
this.batches[i] = batch;
}
}
_renderBatched(renderer) {
if (!this.batches.length) {
return;
}
renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]);
this.calculateVertices();
this.calculateTints();
for (let i = 0, l = this.batches.length; i < l; i++) {
const batch = this.batches[i];
batch.worldAlpha = this.worldAlpha * batch.alpha;
renderer.plugins[this.pluginName].render(batch);
}
}
_renderDirect(renderer) {
const directShader = this._resolveDirectShader(renderer);
let shader = directShader;
const geometry = this._geometry;
const worldAlpha = this.worldAlpha;
const uniforms = shader.uniforms;
const drawCalls = geometry.drawCalls;
uniforms.translationMatrix = this.transform.worldTransform;
core.Color.shared.setValue(this._tintColor).premultiply(worldAlpha).toArray(uniforms.tint);
uniforms.resolution = renderer.renderTexture.current ? renderer.renderTexture.current.resolution : renderer.resolution;
const projTrans = renderer.projection.transform;
if (projTrans) {
const scale = Math.sqrt(projTrans.a * projTrans.a + projTrans.b * projTrans.b);
uniforms.resolution *= scale;
}
const multisample = renderer.renderTexture.current ? renderer.renderTexture.current.multisample : renderer.multisample;
uniforms.expand = (multisample !== core.MSAA_QUALITY.NONE ? 2 : 1) / uniforms.resolution;
renderer.shader.bind(shader);
renderer.geometry.bind(geometry, shader);
renderer.state.set(this.state);
shader = null;
for (let i = 0, l = drawCalls.length; i < l; i++) {
const drawCall = geometry.drawCalls[i];
const shaderChange = shader !== drawCall.shader;
if (shaderChange) {
shader = drawCall.shader;
if (shader) {
shader.uniforms.translationMatrix = this.transform.worldTransform;
if (shader.uniforms.tint) {
shader.uniforms.tint[0] = uniforms.tint[0];
shader.uniforms.tint[1] = uniforms.tint[1];
shader.uniforms.tint[2] = uniforms.tint[2];
shader.uniforms.tint[3] = uniforms.tint[3];
}
}
}
const { texArray, styleArray, size, start } = drawCall;
const groupTextureCount = texArray.count;
const shaderHere = shader || directShader;
const texs = shaderHere.uniforms.styleTextureId;
const mats = shaderHere.uniforms.styleMatrix;
const lines = shaderHere.uniforms.styleLine;
for (let i2 = 0; i2 < styleArray.count; i2++) {
texs[i2] = styleArray.textureIds[i2];
lines[i2 * 2] = styleArray.lines[i2 * 2];
lines[i2 * 2 + 1] = styleArray.lines[i2 * 2 + 1];
const m = styleArray.matrices[i2];
mats[i2 * 6] = m.a;
mats[i2 * 6 + 1] = m.c;
mats[i2 * 6 + 2] = m.tx;
mats[i2 * 6 + 3] = m.b;
mats[i2 * 6 + 4] = m.d;
mats[i2 * 6 + 5] = m.ty;
}
const sizes = shaderHere.uniforms.samplerSize;
for (let i2 = 0; i2 < groupTextureCount; i2++) {
sizes[i2 * 2] = texArray.elements[i2].width;
sizes[i2 * 2 + 1] = texArray.elements[i2].height;
}
renderer.shader.bind(shaderHere);
if (shaderChange) {
renderer.geometry.bind(geometry);
}
for (let j = 0; j < groupTextureCount; j++) {
renderer.texture.bind(texArray.elements[j], j);
}
renderer.geometry.draw(core.DRAW_MODES.TRIANGLES, size, start);
}
}
_resolveDirectShader(_renderer) {
let shader = this.shader;
const pluginName = this.pluginName;
if (!shader) {
if (!DEFAULT_SHADERS[pluginName]) {
DEFAULT_SHADERS[pluginName] = new SmoothShader.SmoothGraphicsShader(this.shaderSettings);
}
shader = DEFAULT_SHADERS[pluginName];
}
return shader;
}
_calculateBounds() {
this.finishPoly();
const geometry = this._geometry;
if (!geometry.graphicsData.length) {
return;
}
const { minX, minY, maxX, maxY } = geometry.bounds;
this._bounds.addFrame(this.transform, minX, minY, maxX, maxY);
}
containsPoint(point) {
this.worldTransform.applyInverse(point, _SmoothGraphics._TEMP_POINT);
return this._geometry.containsPoint(_SmoothGraphics._TEMP_POINT);
}
calculateTints() {
if (this.batchTint !== this.tint) {
this.batchTint = this._tintColor.toNumber();
for (let i = 0; i < this.batches.length; i++) {
const batch = this.batches[i];
batch._tintRGB = core.Color.shared.setValue(this._tintColor).multiply(batch._batchRGB).toLittleEndianNumber();
}
}
}
calculateVertices() {
const wtID = this.transform._worldID;
if (this._transformID === wtID) {
return;
}
this._transformID = wtID;
const wt = this.transform.worldTransform;
const a = wt.a;
const b = wt.b;
const c = wt.c;
const d = wt.d;
const tx = wt.tx;
const ty = wt.ty;
const data = this._geometry.points;
const vertexData = this.vertexData;
let count = 0;
for (let i = 0; i < data.length; i += 2) {
const x = data[i];
const y = data[i + 1];
vertexData[count++] = a * x + c * y + tx;
vertexData[count++] = d * y + b * x + ty;
}
}
closePath() {
const currentPath = this.currentPath;
if (currentPath) {
currentPath.closeStroke = true;
}
return this;
}
setMatrix(matrix) {
this._matrix = matrix;
return this;
}
beginHole() {
this.finishPoly();
this._holeMode = true;
return this;
}
endHole() {
this.finishPoly();
this._holeMode = false;
return this;
}
destroy(options) {
this._geometry.refCount--;
if (this._geometry.refCount === 0) {
this._geometry.dispose();
}
this._matrix = null;
this.currentPath = null;
this._lineStyle.destroy();
this._lineStyle = null;
this._fillStyle.destroy();
this._fillStyle = null;
this._geometry = null;
this.shader = null;
this.vertexData = null;
this.batches.length = 0;
this.batches = null;
super.destroy(options);
}
};
let SmoothGraphics = _SmoothGraphics;
SmoothGraphics.curves = graphics.curves;
SmoothGraphics._TEMP_POINT = new core.Point();
exports.SmoothGraphics = SmoothGraphics;
//# sourceMappingURL=SmoothGraphics.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,541 @@
import { Point, State, Color, BLEND_MODES, Texture, Polygon, PI_2, Rectangle, RoundedRectangle, Circle, Ellipse, SHAPES, utils, MSAA_QUALITY, DRAW_MODES } from '@pixi/core';
import { curves, LINE_CAP, LINE_JOIN, Graphics, graphicsUtils } from '@pixi/graphics';
import { SmoothGraphicsGeometry } from './SmoothGraphicsGeometry.mjs';
import { Container } from '@pixi/display';
import { FillStyle } from './core/FillStyle.mjs';
import { LineStyle, LINE_SCALE_MODE } from './core/LineStyle.mjs';
import { SmoothGraphicsShader } from './SmoothShader.mjs';
import { settings } from './settings.mjs';
const UnsmoothGraphics = Graphics;
const { BezierUtils, QuadraticUtils, ArcUtils } = graphicsUtils;
const DEFAULT_SHADERS = {};
const _SmoothGraphics = class extends Container {
constructor(geometry = null) {
super();
this._geometry = geometry || new SmoothGraphicsGeometry();
this._geometry.refCount++;
this.shader = null;
this.shaderSettings = {
maxStyles: settings.SHADER_MAX_STYLES,
maxTextures: settings.SHADER_MAX_TEXTURES,
pixelLine: settings.PIXEL_LINE
};
this.state = State.for2d();
this._fillStyle = new FillStyle();
this._lineStyle = new LineStyle();
this._matrix = null;
this._holeMode = false;
this.currentPath = null;
this.batches = [];
this.batchTint = -1;
this.batchDirty = -1;
this.vertexData = null;
this.pluginName = "smooth";
this._transformID = -1;
this._tintColor = new Color(16777215);
this.blendMode = BLEND_MODES.NORMAL;
}
get geometry() {
return this._geometry;
}
clone() {
this.finishPoly();
return new _SmoothGraphics(this._geometry);
}
set blendMode(value) {
this.state.blendMode = value;
}
get blendMode() {
return this.state.blendMode;
}
get tint() {
return this._tintColor.value;
}
set tint(value) {
this._tintColor.setValue(value);
}
get fill() {
return this._fillStyle;
}
get line() {
return this._lineStyle;
}
lineStyle(options = null, color = 0, alpha = 1, alignment = 0.5, scaleMode = settings.LINE_SCALE_MODE) {
if (typeof options === "number") {
if (typeof scaleMode === "boolean") {
scaleMode = scaleMode ? LINE_SCALE_MODE.NONE : LINE_SCALE_MODE.NORMAL;
}
options = { width: options, color, alpha, alignment, scaleMode };
} else {
const native = options.native;
if (native !== void 0) {
options.scaleMode = native ? LINE_SCALE_MODE.NONE : LINE_SCALE_MODE.NORMAL;
}
}
return this.lineTextureStyle(options);
}
lineTextureStyle(options) {
options = Object.assign({
width: 0,
texture: Texture.WHITE,
color: options && options.texture ? 16777215 : 0,
alpha: 1,
matrix: null,
alignment: 0.5,
native: false,
cap: LINE_CAP.BUTT,
join: LINE_JOIN.MITER,
miterLimit: 10,
shader: null,
scaleMode: settings.LINE_SCALE_MODE
}, options);
this.normalizeColor(options);
if (this.currentPath) {
this.startPoly();
}
const visible = options.width > 0 && options.alpha > 0;
if (!visible) {
this._lineStyle.reset();
} else {
if (options.matrix) {
options.matrix = options.matrix.clone();
options.matrix.invert();
}
Object.assign(this._lineStyle, { visible }, options);
}
return this;
}
startPoly() {
if (this.currentPath) {
const points = this.currentPath.points;
const len = this.currentPath.points.length;
if (len > 2) {
this.drawShape(this.currentPath);
this.currentPath = new Polygon();
this.currentPath.closeStroke = false;
this.currentPath.points.push(points[len - 2], points[len - 1]);
}
} else {
this.currentPath = new Polygon();
this.currentPath.closeStroke = false;
}
}
finishPoly() {
if (this.currentPath) {
if (this.currentPath.points.length > 2) {
this.drawShape(this.currentPath);
this.currentPath = null;
} else {
this.currentPath.points.length = 0;
}
}
}
moveTo(x, y) {
this.startPoly();
this.currentPath.points[0] = x;
this.currentPath.points[1] = y;
return this;
}
lineTo(x, y) {
if (!this.currentPath) {
this.moveTo(0, 0);
}
const points = this.currentPath.points;
const fromX = points[points.length - 2];
const fromY = points[points.length - 1];
if (fromX !== x || fromY !== y) {
points.push(x, y);
}
return this;
}
_initCurve(x = 0, y = 0) {
if (this.currentPath) {
if (this.currentPath.points.length === 0) {
this.currentPath.points = [x, y];
}
} else {
this.moveTo(x, y);
}
}
quadraticCurveTo(cpX, cpY, toX, toY) {
this._initCurve();
const points = this.currentPath.points;
if (points.length === 0) {
this.moveTo(0, 0);
}
QuadraticUtils.curveTo(cpX, cpY, toX, toY, points);
return this;
}
bezierCurveTo(cpX, cpY, cpX2, cpY2, toX, toY) {
this._initCurve();
BezierUtils.curveTo(cpX, cpY, cpX2, cpY2, toX, toY, this.currentPath.points);
return this;
}
arcTo(x1, y1, x2, y2, radius) {
this._initCurve(x1, y1);
const points = this.currentPath.points;
const result = ArcUtils.curveTo(x1, y1, x2, y2, radius, points);
if (result) {
const { cx, cy, radius: radius2, startAngle, endAngle, anticlockwise } = result;
this.arc(cx, cy, radius2, startAngle, endAngle, anticlockwise);
}
return this;
}
arc(cx, cy, radius, startAngle, endAngle, anticlockwise = false) {
if (startAngle === endAngle) {
return this;
}
if (!anticlockwise && endAngle <= startAngle) {
endAngle += PI_2;
} else if (anticlockwise && startAngle <= endAngle) {
startAngle += PI_2;
}
const sweep = endAngle - startAngle;
if (sweep === 0) {
return this;
}
const startX = cx + Math.cos(startAngle) * radius;
const startY = cy + Math.sin(startAngle) * radius;
const eps = this._geometry.closePointEps;
let points = this.currentPath ? this.currentPath.points : null;
if (points) {
const xDiff = Math.abs(points[points.length - 2] - startX);
const yDiff = Math.abs(points[points.length - 1] - startY);
if (xDiff < eps && yDiff < eps) ; else {
points.push(startX, startY);
}
} else {
this.moveTo(startX, startY);
points = this.currentPath.points;
}
ArcUtils.arc(startX, startY, cx, cy, radius, startAngle, endAngle, anticlockwise, points);
return this;
}
beginFill(color = 0, alpha = 1, smooth = false) {
return this.beginTextureFill({ texture: Texture.WHITE, color, alpha, smooth });
}
normalizeColor(options) {
const temp = Color.shared.setValue(options.color ?? 0);
options.color = temp.toNumber();
options.alpha ?? (options.alpha = temp.alpha);
}
beginTextureFill(options) {
options = Object.assign({
texture: Texture.WHITE,
color: 16777215,
alpha: 1,
matrix: null,
smooth: false
}, options);
this.normalizeColor(options);
if (this.currentPath) {
this.startPoly();
}
const visible = options.alpha > 0;
if (!visible) {
this._fillStyle.reset();
} else {
if (options.matrix) {
options.matrix = options.matrix.clone();
options.matrix.invert();
}
Object.assign(this._fillStyle, { visible }, options);
}
return this;
}
endFill() {
this.finishPoly();
this._fillStyle.reset();
return this;
}
drawRect(x, y, width, height) {
return this.drawShape(new Rectangle(x, y, width, height));
}
drawRoundedRect(x, y, width, height, radius) {
return this.drawShape(new RoundedRectangle(x, y, width, height, radius));
}
drawCircle(x, y, radius) {
return this.drawShape(new Circle(x, y, radius));
}
drawEllipse(x, y, width, height) {
return this.drawShape(new Ellipse(x, y, width, height));
}
drawPolygon(...path) {
let points;
let closeStroke = true;
const poly = path[0];
if (poly.points) {
closeStroke = poly.closeStroke;
points = poly.points;
} else if (Array.isArray(path[0])) {
points = path[0];
} else {
points = path;
}
const shape = new Polygon(points);
shape.closeStroke = closeStroke;
this.drawShape(shape);
return this;
}
drawShape(shape) {
if (!this._holeMode) {
this._geometry.drawShape(
shape,
this._fillStyle.clone(),
this._lineStyle.clone(),
this._matrix
);
} else {
this._geometry.drawHole(shape, this._matrix);
}
return this;
}
clear() {
this._geometry.clear();
this._lineStyle.reset();
this._fillStyle.reset();
this._boundsID++;
this._matrix = null;
this._holeMode = false;
this.currentPath = null;
return this;
}
isFastRect() {
const data = this._geometry.graphicsData;
return data.length === 1 && data[0].shape.type === SHAPES.RECT && !data[0].matrix && !data[0].holes.length && !(data[0].lineStyle.visible && data[0].lineStyle.width);
}
_renderCanvas(renderer) {
UnsmoothGraphics.prototype._renderCanvas.call(this, renderer);
}
_render(renderer) {
this.finishPoly();
const geometry = this._geometry;
const hasuint32 = renderer.context.supports.uint32Indices;
geometry.checkInstancing(renderer.geometry.hasInstance, hasuint32);
geometry.updateBatches(this.shaderSettings);
if (geometry.batchable) {
if (this.batchDirty !== geometry.batchDirty) {
this._populateBatches();
}
this._renderBatched(renderer);
} else {
renderer.batch.flush();
this._renderDirect(renderer);
}
}
_populateBatches() {
const geometry = this._geometry;
const blendMode = this.blendMode;
const len = geometry.batches.length;
this.batchTint = -1;
this._transformID = -1;
this.batchDirty = geometry.batchDirty;
this.batches.length = len;
this.vertexData = new Float32Array(geometry.points);
for (let i = 0; i < len; i++) {
const gI = geometry.batches[i];
const color = gI.style.color;
const vertexData = new Float32Array(
this.vertexData.buffer,
gI.attribStart * 4 * 2,
gI.attribSize * 2
);
const batch = {
vertexData,
blendMode,
// indices,
// uvs,
_batchRGB: utils.hex2rgb(color),
_tintRGB: color,
_texture: gI.style.texture,
alpha: gI.style.alpha,
worldAlpha: 1
};
this.batches[i] = batch;
}
}
_renderBatched(renderer) {
if (!this.batches.length) {
return;
}
renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]);
this.calculateVertices();
this.calculateTints();
for (let i = 0, l = this.batches.length; i < l; i++) {
const batch = this.batches[i];
batch.worldAlpha = this.worldAlpha * batch.alpha;
renderer.plugins[this.pluginName].render(batch);
}
}
_renderDirect(renderer) {
const directShader = this._resolveDirectShader(renderer);
let shader = directShader;
const geometry = this._geometry;
const worldAlpha = this.worldAlpha;
const uniforms = shader.uniforms;
const drawCalls = geometry.drawCalls;
uniforms.translationMatrix = this.transform.worldTransform;
Color.shared.setValue(this._tintColor).premultiply(worldAlpha).toArray(uniforms.tint);
uniforms.resolution = renderer.renderTexture.current ? renderer.renderTexture.current.resolution : renderer.resolution;
const projTrans = renderer.projection.transform;
if (projTrans) {
const scale = Math.sqrt(projTrans.a * projTrans.a + projTrans.b * projTrans.b);
uniforms.resolution *= scale;
}
const multisample = renderer.renderTexture.current ? renderer.renderTexture.current.multisample : renderer.multisample;
uniforms.expand = (multisample !== MSAA_QUALITY.NONE ? 2 : 1) / uniforms.resolution;
renderer.shader.bind(shader);
renderer.geometry.bind(geometry, shader);
renderer.state.set(this.state);
shader = null;
for (let i = 0, l = drawCalls.length; i < l; i++) {
const drawCall = geometry.drawCalls[i];
const shaderChange = shader !== drawCall.shader;
if (shaderChange) {
shader = drawCall.shader;
if (shader) {
shader.uniforms.translationMatrix = this.transform.worldTransform;
if (shader.uniforms.tint) {
shader.uniforms.tint[0] = uniforms.tint[0];
shader.uniforms.tint[1] = uniforms.tint[1];
shader.uniforms.tint[2] = uniforms.tint[2];
shader.uniforms.tint[3] = uniforms.tint[3];
}
}
}
const { texArray, styleArray, size, start } = drawCall;
const groupTextureCount = texArray.count;
const shaderHere = shader || directShader;
const texs = shaderHere.uniforms.styleTextureId;
const mats = shaderHere.uniforms.styleMatrix;
const lines = shaderHere.uniforms.styleLine;
for (let i2 = 0; i2 < styleArray.count; i2++) {
texs[i2] = styleArray.textureIds[i2];
lines[i2 * 2] = styleArray.lines[i2 * 2];
lines[i2 * 2 + 1] = styleArray.lines[i2 * 2 + 1];
const m = styleArray.matrices[i2];
mats[i2 * 6] = m.a;
mats[i2 * 6 + 1] = m.c;
mats[i2 * 6 + 2] = m.tx;
mats[i2 * 6 + 3] = m.b;
mats[i2 * 6 + 4] = m.d;
mats[i2 * 6 + 5] = m.ty;
}
const sizes = shaderHere.uniforms.samplerSize;
for (let i2 = 0; i2 < groupTextureCount; i2++) {
sizes[i2 * 2] = texArray.elements[i2].width;
sizes[i2 * 2 + 1] = texArray.elements[i2].height;
}
renderer.shader.bind(shaderHere);
if (shaderChange) {
renderer.geometry.bind(geometry);
}
for (let j = 0; j < groupTextureCount; j++) {
renderer.texture.bind(texArray.elements[j], j);
}
renderer.geometry.draw(DRAW_MODES.TRIANGLES, size, start);
}
}
_resolveDirectShader(_renderer) {
let shader = this.shader;
const pluginName = this.pluginName;
if (!shader) {
if (!DEFAULT_SHADERS[pluginName]) {
DEFAULT_SHADERS[pluginName] = new SmoothGraphicsShader(this.shaderSettings);
}
shader = DEFAULT_SHADERS[pluginName];
}
return shader;
}
_calculateBounds() {
this.finishPoly();
const geometry = this._geometry;
if (!geometry.graphicsData.length) {
return;
}
const { minX, minY, maxX, maxY } = geometry.bounds;
this._bounds.addFrame(this.transform, minX, minY, maxX, maxY);
}
containsPoint(point) {
this.worldTransform.applyInverse(point, _SmoothGraphics._TEMP_POINT);
return this._geometry.containsPoint(_SmoothGraphics._TEMP_POINT);
}
calculateTints() {
if (this.batchTint !== this.tint) {
this.batchTint = this._tintColor.toNumber();
for (let i = 0; i < this.batches.length; i++) {
const batch = this.batches[i];
batch._tintRGB = Color.shared.setValue(this._tintColor).multiply(batch._batchRGB).toLittleEndianNumber();
}
}
}
calculateVertices() {
const wtID = this.transform._worldID;
if (this._transformID === wtID) {
return;
}
this._transformID = wtID;
const wt = this.transform.worldTransform;
const a = wt.a;
const b = wt.b;
const c = wt.c;
const d = wt.d;
const tx = wt.tx;
const ty = wt.ty;
const data = this._geometry.points;
const vertexData = this.vertexData;
let count = 0;
for (let i = 0; i < data.length; i += 2) {
const x = data[i];
const y = data[i + 1];
vertexData[count++] = a * x + c * y + tx;
vertexData[count++] = d * y + b * x + ty;
}
}
closePath() {
const currentPath = this.currentPath;
if (currentPath) {
currentPath.closeStroke = true;
}
return this;
}
setMatrix(matrix) {
this._matrix = matrix;
return this;
}
beginHole() {
this.finishPoly();
this._holeMode = true;
return this;
}
endHole() {
this.finishPoly();
this._holeMode = false;
return this;
}
destroy(options) {
this._geometry.refCount--;
if (this._geometry.refCount === 0) {
this._geometry.dispose();
}
this._matrix = null;
this.currentPath = null;
this._lineStyle.destroy();
this._lineStyle = null;
this._fillStyle.destroy();
this._fillStyle = null;
this._geometry = null;
this.shader = null;
this.vertexData = null;
this.batches.length = 0;
this.batches = null;
super.destroy(options);
}
};
let SmoothGraphics = _SmoothGraphics;
SmoothGraphics.curves = curves;
SmoothGraphics._TEMP_POINT = new Point();
export { SmoothGraphics };
//# sourceMappingURL=SmoothGraphics.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,592 @@
'use strict';
var SmoothGraphicsData = require('./core/SmoothGraphicsData.js');
var index = require('./shapes/index.js');
var core = require('@pixi/core');
var display = require('@pixi/display');
var BuildData = require('./core/BuildData.js');
var SegmentPacker = require('./core/SegmentPacker.js');
var BatchPart = require('./core/BatchPart.js');
var BatchDrawCall = require('./core/BatchDrawCall.js');
const BATCH_POOL = [];
const DRAW_CALL_POOL = [];
const tmpPoint = new core.Point();
const tmpBounds = new display.Bounds();
class SmoothGraphicsGeometry extends core.Geometry {
constructor() {
super();
this.indicesUint16 = null;
this.initAttributes(false);
this.buildData = new BuildData.BuildData();
this.graphicsData = [];
this.dirty = 0;
this.batchDirty = -1;
this.cacheDirty = -1;
this.clearDirty = 0;
this.drawCalls = [];
this.batches = [];
this.shapeBuildIndex = 0;
this.shapeBatchIndex = 0;
this._bounds = new display.Bounds();
this.boundsDirty = -1;
this.boundsPadding = 0;
this.batchable = false;
this.indicesUint16 = null;
this.packer = null;
this.packSize = 0;
this.pack32index = null;
}
get points() {
return this.buildData.verts;
}
get closePointEps() {
return this.buildData.closePointEps;
}
initAttributes(_static) {
this._buffer = new core.Buffer(null, _static, false);
this._bufferFloats = new Float32Array();
this._bufferUint = new Uint32Array();
this._indexBuffer = new core.Buffer(null, _static, true);
this.addAttribute("aPrev", this._buffer, 2, false, core.TYPES.FLOAT).addAttribute("aPoint1", this._buffer, 2, false, core.TYPES.FLOAT).addAttribute("aPoint2", this._buffer, 2, false, core.TYPES.FLOAT).addAttribute("aNext", this._buffer, 2, false, core.TYPES.FLOAT).addAttribute("aTravel", this._buffer, 1, false, core.TYPES.FLOAT).addAttribute("aVertexJoint", this._buffer, 1, false, core.TYPES.FLOAT).addAttribute("aStyleId", this._buffer, 1, false, core.TYPES.FLOAT).addAttribute("aColor", this._buffer, 4, true, core.TYPES.UNSIGNED_BYTE).addIndex(this._indexBuffer);
this.strideFloats = 12;
}
checkInstancing(instanced, allow32Indices) {
if (this.packer) {
return;
}
this.packer = new SegmentPacker.SegmentPacker();
this.pack32index = allow32Indices;
}
/**
* Get the current bounds of the graphic geometry.
*
* @member {PIXI.Bounds}
* @readonly
*/
get bounds() {
if (this.boundsDirty !== this.dirty) {
this.boundsDirty = this.dirty;
this.calculateBounds();
}
return this._bounds;
}
/**
* Call if you changed graphicsData manually.
* Empties all batch buffers.
*/
invalidate() {
this.boundsDirty = -1;
this.dirty++;
this.batchDirty++;
this.shapeBuildIndex = 0;
this.shapeBatchIndex = 0;
this.packSize = 0;
this.buildData.clear();
for (let i = 0; i < this.drawCalls.length; i++) {
this.drawCalls[i].clear();
DRAW_CALL_POOL.push(this.drawCalls[i]);
}
this.drawCalls.length = 0;
for (let i = 0; i < this.batches.length; i++) {
const batchPart = this.batches[i];
batchPart.reset();
BATCH_POOL.push(batchPart);
}
this.batches.length = 0;
}
clear() {
if (this.graphicsData.length > 0) {
this.invalidate();
this.clearDirty++;
this.graphicsData.length = 0;
}
return this;
}
drawShape(shape, fillStyle = null, lineStyle = null, matrix = null) {
const data = new SmoothGraphicsData.SmoothGraphicsData(shape, fillStyle, lineStyle, matrix);
this.graphicsData.push(data);
this.dirty++;
return this;
}
drawHole(shape, matrix = null) {
if (!this.graphicsData.length) {
return null;
}
const data = new SmoothGraphicsData.SmoothGraphicsData(shape, null, null, matrix);
const lastShape = this.graphicsData[this.graphicsData.length - 1];
data.lineStyle = lastShape.lineStyle;
lastShape.holes.push(data);
this.dirty++;
return this;
}
destroy() {
super.destroy();
for (let i = 0; i < this.graphicsData.length; ++i) {
this.graphicsData[i].destroy();
}
this.buildData.destroy();
this.buildData = null;
this.indexBuffer.destroy();
this.indexBuffer = null;
this.graphicsData.length = 0;
this.graphicsData = null;
this.drawCalls.length = 0;
this.drawCalls = null;
this.batches.length = 0;
this.batches = null;
this._bounds = null;
}
/**
* Check to see if a point is contained within this geometry.
*
* @param {PIXI.IPointData} point - Point to check if it's contained.
* @return {Boolean} `true` if the point is contained within geometry.
*/
containsPoint(point) {
const graphicsData = this.graphicsData;
for (let i = 0; i < graphicsData.length; ++i) {
const data = graphicsData[i];
if (!data.fillStyle.visible) {
continue;
}
if (data.shape) {
if (data.matrix) {
data.matrix.applyInverse(point, tmpPoint);
} else {
tmpPoint.copyFrom(point);
}
if (data.shape.contains(tmpPoint.x, tmpPoint.y)) {
let hitHole = false;
if (data.holes) {
for (let i2 = 0; i2 < data.holes.length; i2++) {
const hole = data.holes[i2];
if (hole.shape.contains(tmpPoint.x, tmpPoint.y)) {
hitHole = true;
break;
}
}
}
if (!hitHole) {
return true;
}
}
}
}
return false;
}
updatePoints() {
}
updateBufferSize() {
this._buffer.update(new Float32Array());
}
updateBuild() {
const { graphicsData, buildData } = this;
const len = graphicsData.length;
for (let i = this.shapeBuildIndex; i < len; i++) {
const data = graphicsData[i];
data.strokeStart = 0;
data.strokeLen = 0;
data.fillStart = 0;
data.fillLen = 0;
const { fillStyle, lineStyle, holes } = data;
if (!fillStyle.visible && !lineStyle.visible) {
continue;
}
const command = index.FILL_COMMANDS[data.type];
data.clearPath();
command.path(data, buildData);
if (data.matrix) {
this.transformPoints(data.points, data.matrix);
}
data.clearBuild();
if (data.points.length <= 2) {
continue;
}
if (fillStyle.visible || lineStyle.visible) {
this.processHoles(holes);
}
if (fillStyle.visible) {
data.fillAA = data.fillStyle.smooth && data.fillStyle.texture === core.Texture.WHITE && holes.length === 0 && !(data.closeStroke && data.lineStyle.visible && !data.lineStyle.shader && data.lineStyle.alpha >= 0.99 && data.lineStyle.width * Math.min(data.lineStyle.alignment, 1 - data.lineStyle.alignment) >= 0.495);
data.fillStart = buildData.joints.length;
if (holes.length) {
index.FILL_COMMANDS[core.SHAPES.POLY].fill(data, buildData);
} else {
command.fill(data, buildData);
}
data.fillLen = buildData.joints.length - data.fillStart;
}
if (lineStyle.visible) {
data.strokeStart = buildData.joints.length;
command.line(data, buildData);
for (let i2 = 0; i2 < holes.length; i2++) {
const hole = holes[i2];
index.FILL_COMMANDS[hole.type].line(hole, buildData);
}
data.strokeLen = buildData.joints.length - data.strokeStart;
}
}
this.shapeBuildIndex = len;
}
updateBatches(shaderSettings) {
if (!this.graphicsData.length) {
this.batchable = true;
return;
}
this.updateBuild();
if (!this.validateBatching()) {
return;
}
const { buildData, graphicsData } = this;
const len = graphicsData.length;
this.cacheDirty = this.dirty;
let batchPart = null;
let currentStyle = null;
if (this.batches.length > 0) {
batchPart = this.batches[this.batches.length - 1];
currentStyle = batchPart.style;
}
for (let i = this.shapeBatchIndex; i < len; i++) {
const data = graphicsData[i];
const fillStyle = data.fillStyle;
const lineStyle = data.lineStyle;
if (data.matrix) {
this.transformPoints(data.points, data.matrix);
}
if (!fillStyle.visible && !lineStyle.visible) {
continue;
}
for (let j = 0; j < 2; j++) {
const style = j === 0 ? fillStyle : lineStyle;
if (!style.visible)
continue;
const nextTexture = style.texture.baseTexture;
const attribOld = buildData.vertexSize;
const indexOld = buildData.indexSize;
nextTexture.wrapMode = core.WRAP_MODES.REPEAT;
if (j === 0) {
this.packer.updateBufferSize(data.fillStart, data.fillLen, data.triangles.length, buildData);
} else {
this.packer.updateBufferSize(data.strokeStart, data.strokeLen, data.triangles.length, buildData);
}
const attribSize = buildData.vertexSize;
if (attribSize === attribOld)
continue;
if (batchPart && !this._compareStyles(currentStyle, style)) {
batchPart.end(indexOld, attribOld);
batchPart = null;
}
if (!batchPart) {
batchPart = BATCH_POOL.pop() || new BatchPart.BatchPart();
batchPart.begin(style, indexOld, attribOld);
this.batches.push(batchPart);
currentStyle = style;
}
if (j === 0) {
batchPart.jointEnd = data.fillStart + data.fillLen;
} else {
batchPart.jointEnd = data.strokeStart + data.strokeLen;
}
}
}
this.shapeBatchIndex = len;
if (batchPart) {
batchPart.end(buildData.indexSize, buildData.vertexSize);
}
if (this.batches.length === 0) {
this.batchable = true;
return;
}
this.batchable = this.isBatchable();
if (this.batchable) {
this.packBatches();
} else {
this.buildDrawCalls(shaderSettings);
this.updatePack();
}
}
updatePack() {
const { vertexSize, indexSize } = this.buildData;
if (this.packSize === vertexSize) {
return;
}
const { strideFloats, packer, buildData, batches } = this;
const buffer = this._buffer;
const index = this._indexBuffer;
const floatsSize = vertexSize * strideFloats;
if (buffer.data.length !== floatsSize) {
const arrBuf = new ArrayBuffer(floatsSize * 4);
this._bufferFloats = new Float32Array(arrBuf);
this._bufferUint = new Uint32Array(arrBuf);
buffer.data = this._bufferFloats;
}
if (index.data.length !== indexSize) {
if (vertexSize > 65535 && this.pack32index) {
index.data = new Uint32Array(indexSize);
} else {
index.data = new Uint16Array(indexSize);
}
}
packer.beginPack(buildData, this._bufferFloats, this._bufferUint, index.data);
let j = 0;
for (let i = 0; i < this.graphicsData.length; i++) {
const data = this.graphicsData[i];
if (data.fillLen) {
while (batches[j].jointEnd <= data.fillStart) {
j++;
}
packer.packInterleavedGeometry(
data.fillStart,
data.fillLen,
data.triangles,
batches[j].styleId,
batches[j].rgba
);
}
if (data.strokeLen) {
while (batches[j].jointEnd <= data.strokeStart) {
j++;
}
packer.packInterleavedGeometry(
data.strokeStart,
data.strokeLen,
data.triangles,
batches[j].styleId,
batches[j].rgba
);
}
}
buffer.update();
index.update();
this.packSize = vertexSize;
}
/**
* Affinity check
*
* @param {PIXI.FillStyle | PIXI.LineStyle} styleA
* @param {PIXI.FillStyle | PIXI.LineStyle} styleB
*/
_compareStyles(styleA, styleB) {
if (!styleA || !styleB) {
return false;
}
if (styleA.texture.baseTexture !== styleB.texture.baseTexture) {
return false;
}
if (styleA.color + styleA.alpha !== styleB.color + styleB.alpha) {
return false;
}
if (styleA.shader !== styleB.shader) {
return false;
}
if (styleA.width !== styleB.width) {
return false;
}
if (styleA.scaleMode !== styleB.scaleMode) {
return false;
}
if (styleA.alignment !== styleB.alignment) {
return false;
}
const mat1 = styleA.matrix || core.Matrix.IDENTITY;
const mat2 = styleB.matrix || core.Matrix.IDENTITY;
return BatchDrawCall.matrixEquals(mat1, mat2);
}
/**
* Test geometry for batching process.
*
* @protected
*/
validateBatching() {
if (this.dirty === this.cacheDirty || !this.graphicsData.length) {
return false;
}
for (let i = 0, l = this.graphicsData.length; i < l; i++) {
const data = this.graphicsData[i];
const fill = data.fillStyle;
const line = data.lineStyle;
if (fill && !fill.texture.baseTexture.valid)
return false;
if (line && !line.texture.baseTexture.valid)
return false;
}
return true;
}
/**
* Offset the indices so that it works with the batcher.
*
* @protected
*/
packBatches() {
this.batchDirty++;
const batches = this.batches;
for (let i = 0, l = batches.length; i < l; i++) {
const batch = batches[i];
for (let j = 0; j < batch.size; j++) {
const index = batch.start + j;
this.indicesUint16[index] = this.indicesUint16[index] - batch.attribStart;
}
}
}
isBatchable() {
return false;
}
/**
* Converts intermediate batches data to drawCalls.
*
* @protected
*/
buildDrawCalls(shaderSettings) {
for (let i = 0; i < this.drawCalls.length; i++) {
this.drawCalls[i].clear();
DRAW_CALL_POOL.push(this.drawCalls[i]);
}
this.drawCalls.length = 0;
let currentGroup = DRAW_CALL_POOL.pop() || new BatchDrawCall.BatchDrawCall();
currentGroup.begin(shaderSettings, null);
let index = 0;
this.drawCalls.push(currentGroup);
for (let i = 0; i < this.batches.length; i++) {
const batchData = this.batches[i];
const style = batchData.style;
if (batchData.attribSize === 0) {
continue;
}
let styleId = -1;
const mat = style.getTextureMatrix();
if (currentGroup.check(style.shader)) {
styleId = currentGroup.add(
style.texture,
mat,
style.width,
style.alignment || 0,
style.packLineScale()
);
}
if (styleId < 0) {
currentGroup = DRAW_CALL_POOL.pop() || new BatchDrawCall.BatchDrawCall();
this.drawCalls.push(currentGroup);
currentGroup.begin(shaderSettings, style.shader);
currentGroup.start = index;
styleId = currentGroup.add(
style.texture,
mat,
style.width,
style.alignment || 0,
style.packLineScale()
);
}
currentGroup.size += batchData.size;
index += batchData.size;
const { color, alpha } = style;
const bgr = core.Color.shared.setValue(color).toLittleEndianNumber();
batchData.rgba = core.Color.shared.setValue(bgr).toPremultiplied(alpha);
batchData.styleId = styleId;
}
}
processHoles(holes) {
for (let i = 0; i < holes.length; i++) {
const hole = holes[i];
const command = index.FILL_COMMANDS[hole.type];
hole.clearPath();
command.path(hole, this.buildData);
if (hole.matrix) {
this.transformPoints(hole.points, hole.matrix);
}
}
}
/**
* Update the local bounds of the object. Expensive to use performance-wise.
*
* @protected
*/
calculateBounds() {
const bounds = this._bounds;
const sequenceBounds = tmpBounds;
let curMatrix = core.Matrix.IDENTITY;
this._bounds.clear();
sequenceBounds.clear();
for (let i = 0; i < this.graphicsData.length; i++) {
const data = this.graphicsData[i];
const shape = data.shape;
const type = data.type;
const lineStyle = data.lineStyle;
const nextMatrix = data.matrix || core.Matrix.IDENTITY;
let lineWidth = 0;
if (lineStyle && lineStyle.visible) {
lineWidth = lineStyle.width;
if (type !== core.SHAPES.POLY || data.fillStyle.visible) {
lineWidth *= Math.max(0, lineStyle.alignment);
} else {
lineWidth *= Math.max(lineStyle.alignment, 1 - lineStyle.alignment);
}
}
if (curMatrix !== nextMatrix) {
if (!sequenceBounds.isEmpty()) {
bounds.addBoundsMatrix(sequenceBounds, curMatrix);
sequenceBounds.clear();
}
curMatrix = nextMatrix;
}
if (type === core.SHAPES.RECT || type === core.SHAPES.RREC) {
const rect = shape;
sequenceBounds.addFramePad(
rect.x,
rect.y,
rect.x + rect.width,
rect.y + rect.height,
lineWidth,
lineWidth
);
} else if (type === core.SHAPES.CIRC) {
const circle = shape;
sequenceBounds.addFramePad(
circle.x,
circle.y,
circle.x,
circle.y,
circle.radius + lineWidth,
circle.radius + lineWidth
);
} else if (type === core.SHAPES.ELIP) {
const ellipse = shape;
sequenceBounds.addFramePad(
ellipse.x,
ellipse.y,
ellipse.x,
ellipse.y,
ellipse.width + lineWidth,
ellipse.height + lineWidth
);
} else {
const poly = shape;
bounds.addVerticesMatrix(curMatrix, poly.points, 0, poly.points.length, lineWidth, lineWidth);
}
}
if (!sequenceBounds.isEmpty()) {
bounds.addBoundsMatrix(sequenceBounds, curMatrix);
}
bounds.pad(this.boundsPadding, this.boundsPadding);
}
/**
* Transform points using matrix.
*
* @protected
* @param {number[]} points - Points to transform
* @param {PIXI.Matrix} matrix - Transform matrix
*/
transformPoints(points, matrix) {
for (let i = 0; i < points.length / 2; i++) {
const x = points[i * 2];
const y = points[i * 2 + 1];
points[i * 2] = matrix.a * x + matrix.c * y + matrix.tx;
points[i * 2 + 1] = matrix.b * x + matrix.d * y + matrix.ty;
}
}
}
SmoothGraphicsGeometry.BATCHABLE_SIZE = 100;
exports.BATCH_POOL = BATCH_POOL;
exports.DRAW_CALL_POOL = DRAW_CALL_POOL;
exports.SmoothGraphicsGeometry = SmoothGraphicsGeometry;
//# sourceMappingURL=SmoothGraphicsGeometry.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,588 @@
import { SmoothGraphicsData } from './core/SmoothGraphicsData.mjs';
import { FILL_COMMANDS } from './shapes/index.mjs';
import { Point, Geometry, Buffer, TYPES, Texture, SHAPES, WRAP_MODES, Matrix, Color } from '@pixi/core';
import { Bounds } from '@pixi/display';
import { BuildData } from './core/BuildData.mjs';
import { SegmentPacker } from './core/SegmentPacker.mjs';
import { BatchPart } from './core/BatchPart.mjs';
import { matrixEquals, BatchDrawCall } from './core/BatchDrawCall.mjs';
const BATCH_POOL = [];
const DRAW_CALL_POOL = [];
const tmpPoint = new Point();
const tmpBounds = new Bounds();
class SmoothGraphicsGeometry extends Geometry {
constructor() {
super();
this.indicesUint16 = null;
this.initAttributes(false);
this.buildData = new BuildData();
this.graphicsData = [];
this.dirty = 0;
this.batchDirty = -1;
this.cacheDirty = -1;
this.clearDirty = 0;
this.drawCalls = [];
this.batches = [];
this.shapeBuildIndex = 0;
this.shapeBatchIndex = 0;
this._bounds = new Bounds();
this.boundsDirty = -1;
this.boundsPadding = 0;
this.batchable = false;
this.indicesUint16 = null;
this.packer = null;
this.packSize = 0;
this.pack32index = null;
}
get points() {
return this.buildData.verts;
}
get closePointEps() {
return this.buildData.closePointEps;
}
initAttributes(_static) {
this._buffer = new Buffer(null, _static, false);
this._bufferFloats = new Float32Array();
this._bufferUint = new Uint32Array();
this._indexBuffer = new Buffer(null, _static, true);
this.addAttribute("aPrev", this._buffer, 2, false, TYPES.FLOAT).addAttribute("aPoint1", this._buffer, 2, false, TYPES.FLOAT).addAttribute("aPoint2", this._buffer, 2, false, TYPES.FLOAT).addAttribute("aNext", this._buffer, 2, false, TYPES.FLOAT).addAttribute("aTravel", this._buffer, 1, false, TYPES.FLOAT).addAttribute("aVertexJoint", this._buffer, 1, false, TYPES.FLOAT).addAttribute("aStyleId", this._buffer, 1, false, TYPES.FLOAT).addAttribute("aColor", this._buffer, 4, true, TYPES.UNSIGNED_BYTE).addIndex(this._indexBuffer);
this.strideFloats = 12;
}
checkInstancing(instanced, allow32Indices) {
if (this.packer) {
return;
}
this.packer = new SegmentPacker();
this.pack32index = allow32Indices;
}
/**
* Get the current bounds of the graphic geometry.
*
* @member {PIXI.Bounds}
* @readonly
*/
get bounds() {
if (this.boundsDirty !== this.dirty) {
this.boundsDirty = this.dirty;
this.calculateBounds();
}
return this._bounds;
}
/**
* Call if you changed graphicsData manually.
* Empties all batch buffers.
*/
invalidate() {
this.boundsDirty = -1;
this.dirty++;
this.batchDirty++;
this.shapeBuildIndex = 0;
this.shapeBatchIndex = 0;
this.packSize = 0;
this.buildData.clear();
for (let i = 0; i < this.drawCalls.length; i++) {
this.drawCalls[i].clear();
DRAW_CALL_POOL.push(this.drawCalls[i]);
}
this.drawCalls.length = 0;
for (let i = 0; i < this.batches.length; i++) {
const batchPart = this.batches[i];
batchPart.reset();
BATCH_POOL.push(batchPart);
}
this.batches.length = 0;
}
clear() {
if (this.graphicsData.length > 0) {
this.invalidate();
this.clearDirty++;
this.graphicsData.length = 0;
}
return this;
}
drawShape(shape, fillStyle = null, lineStyle = null, matrix = null) {
const data = new SmoothGraphicsData(shape, fillStyle, lineStyle, matrix);
this.graphicsData.push(data);
this.dirty++;
return this;
}
drawHole(shape, matrix = null) {
if (!this.graphicsData.length) {
return null;
}
const data = new SmoothGraphicsData(shape, null, null, matrix);
const lastShape = this.graphicsData[this.graphicsData.length - 1];
data.lineStyle = lastShape.lineStyle;
lastShape.holes.push(data);
this.dirty++;
return this;
}
destroy() {
super.destroy();
for (let i = 0; i < this.graphicsData.length; ++i) {
this.graphicsData[i].destroy();
}
this.buildData.destroy();
this.buildData = null;
this.indexBuffer.destroy();
this.indexBuffer = null;
this.graphicsData.length = 0;
this.graphicsData = null;
this.drawCalls.length = 0;
this.drawCalls = null;
this.batches.length = 0;
this.batches = null;
this._bounds = null;
}
/**
* Check to see if a point is contained within this geometry.
*
* @param {PIXI.IPointData} point - Point to check if it's contained.
* @return {Boolean} `true` if the point is contained within geometry.
*/
containsPoint(point) {
const graphicsData = this.graphicsData;
for (let i = 0; i < graphicsData.length; ++i) {
const data = graphicsData[i];
if (!data.fillStyle.visible) {
continue;
}
if (data.shape) {
if (data.matrix) {
data.matrix.applyInverse(point, tmpPoint);
} else {
tmpPoint.copyFrom(point);
}
if (data.shape.contains(tmpPoint.x, tmpPoint.y)) {
let hitHole = false;
if (data.holes) {
for (let i2 = 0; i2 < data.holes.length; i2++) {
const hole = data.holes[i2];
if (hole.shape.contains(tmpPoint.x, tmpPoint.y)) {
hitHole = true;
break;
}
}
}
if (!hitHole) {
return true;
}
}
}
}
return false;
}
updatePoints() {
}
updateBufferSize() {
this._buffer.update(new Float32Array());
}
updateBuild() {
const { graphicsData, buildData } = this;
const len = graphicsData.length;
for (let i = this.shapeBuildIndex; i < len; i++) {
const data = graphicsData[i];
data.strokeStart = 0;
data.strokeLen = 0;
data.fillStart = 0;
data.fillLen = 0;
const { fillStyle, lineStyle, holes } = data;
if (!fillStyle.visible && !lineStyle.visible) {
continue;
}
const command = FILL_COMMANDS[data.type];
data.clearPath();
command.path(data, buildData);
if (data.matrix) {
this.transformPoints(data.points, data.matrix);
}
data.clearBuild();
if (data.points.length <= 2) {
continue;
}
if (fillStyle.visible || lineStyle.visible) {
this.processHoles(holes);
}
if (fillStyle.visible) {
data.fillAA = data.fillStyle.smooth && data.fillStyle.texture === Texture.WHITE && holes.length === 0 && !(data.closeStroke && data.lineStyle.visible && !data.lineStyle.shader && data.lineStyle.alpha >= 0.99 && data.lineStyle.width * Math.min(data.lineStyle.alignment, 1 - data.lineStyle.alignment) >= 0.495);
data.fillStart = buildData.joints.length;
if (holes.length) {
FILL_COMMANDS[SHAPES.POLY].fill(data, buildData);
} else {
command.fill(data, buildData);
}
data.fillLen = buildData.joints.length - data.fillStart;
}
if (lineStyle.visible) {
data.strokeStart = buildData.joints.length;
command.line(data, buildData);
for (let i2 = 0; i2 < holes.length; i2++) {
const hole = holes[i2];
FILL_COMMANDS[hole.type].line(hole, buildData);
}
data.strokeLen = buildData.joints.length - data.strokeStart;
}
}
this.shapeBuildIndex = len;
}
updateBatches(shaderSettings) {
if (!this.graphicsData.length) {
this.batchable = true;
return;
}
this.updateBuild();
if (!this.validateBatching()) {
return;
}
const { buildData, graphicsData } = this;
const len = graphicsData.length;
this.cacheDirty = this.dirty;
let batchPart = null;
let currentStyle = null;
if (this.batches.length > 0) {
batchPart = this.batches[this.batches.length - 1];
currentStyle = batchPart.style;
}
for (let i = this.shapeBatchIndex; i < len; i++) {
const data = graphicsData[i];
const fillStyle = data.fillStyle;
const lineStyle = data.lineStyle;
if (data.matrix) {
this.transformPoints(data.points, data.matrix);
}
if (!fillStyle.visible && !lineStyle.visible) {
continue;
}
for (let j = 0; j < 2; j++) {
const style = j === 0 ? fillStyle : lineStyle;
if (!style.visible)
continue;
const nextTexture = style.texture.baseTexture;
const attribOld = buildData.vertexSize;
const indexOld = buildData.indexSize;
nextTexture.wrapMode = WRAP_MODES.REPEAT;
if (j === 0) {
this.packer.updateBufferSize(data.fillStart, data.fillLen, data.triangles.length, buildData);
} else {
this.packer.updateBufferSize(data.strokeStart, data.strokeLen, data.triangles.length, buildData);
}
const attribSize = buildData.vertexSize;
if (attribSize === attribOld)
continue;
if (batchPart && !this._compareStyles(currentStyle, style)) {
batchPart.end(indexOld, attribOld);
batchPart = null;
}
if (!batchPart) {
batchPart = BATCH_POOL.pop() || new BatchPart();
batchPart.begin(style, indexOld, attribOld);
this.batches.push(batchPart);
currentStyle = style;
}
if (j === 0) {
batchPart.jointEnd = data.fillStart + data.fillLen;
} else {
batchPart.jointEnd = data.strokeStart + data.strokeLen;
}
}
}
this.shapeBatchIndex = len;
if (batchPart) {
batchPart.end(buildData.indexSize, buildData.vertexSize);
}
if (this.batches.length === 0) {
this.batchable = true;
return;
}
this.batchable = this.isBatchable();
if (this.batchable) {
this.packBatches();
} else {
this.buildDrawCalls(shaderSettings);
this.updatePack();
}
}
updatePack() {
const { vertexSize, indexSize } = this.buildData;
if (this.packSize === vertexSize) {
return;
}
const { strideFloats, packer, buildData, batches } = this;
const buffer = this._buffer;
const index = this._indexBuffer;
const floatsSize = vertexSize * strideFloats;
if (buffer.data.length !== floatsSize) {
const arrBuf = new ArrayBuffer(floatsSize * 4);
this._bufferFloats = new Float32Array(arrBuf);
this._bufferUint = new Uint32Array(arrBuf);
buffer.data = this._bufferFloats;
}
if (index.data.length !== indexSize) {
if (vertexSize > 65535 && this.pack32index) {
index.data = new Uint32Array(indexSize);
} else {
index.data = new Uint16Array(indexSize);
}
}
packer.beginPack(buildData, this._bufferFloats, this._bufferUint, index.data);
let j = 0;
for (let i = 0; i < this.graphicsData.length; i++) {
const data = this.graphicsData[i];
if (data.fillLen) {
while (batches[j].jointEnd <= data.fillStart) {
j++;
}
packer.packInterleavedGeometry(
data.fillStart,
data.fillLen,
data.triangles,
batches[j].styleId,
batches[j].rgba
);
}
if (data.strokeLen) {
while (batches[j].jointEnd <= data.strokeStart) {
j++;
}
packer.packInterleavedGeometry(
data.strokeStart,
data.strokeLen,
data.triangles,
batches[j].styleId,
batches[j].rgba
);
}
}
buffer.update();
index.update();
this.packSize = vertexSize;
}
/**
* Affinity check
*
* @param {PIXI.FillStyle | PIXI.LineStyle} styleA
* @param {PIXI.FillStyle | PIXI.LineStyle} styleB
*/
_compareStyles(styleA, styleB) {
if (!styleA || !styleB) {
return false;
}
if (styleA.texture.baseTexture !== styleB.texture.baseTexture) {
return false;
}
if (styleA.color + styleA.alpha !== styleB.color + styleB.alpha) {
return false;
}
if (styleA.shader !== styleB.shader) {
return false;
}
if (styleA.width !== styleB.width) {
return false;
}
if (styleA.scaleMode !== styleB.scaleMode) {
return false;
}
if (styleA.alignment !== styleB.alignment) {
return false;
}
const mat1 = styleA.matrix || Matrix.IDENTITY;
const mat2 = styleB.matrix || Matrix.IDENTITY;
return matrixEquals(mat1, mat2);
}
/**
* Test geometry for batching process.
*
* @protected
*/
validateBatching() {
if (this.dirty === this.cacheDirty || !this.graphicsData.length) {
return false;
}
for (let i = 0, l = this.graphicsData.length; i < l; i++) {
const data = this.graphicsData[i];
const fill = data.fillStyle;
const line = data.lineStyle;
if (fill && !fill.texture.baseTexture.valid)
return false;
if (line && !line.texture.baseTexture.valid)
return false;
}
return true;
}
/**
* Offset the indices so that it works with the batcher.
*
* @protected
*/
packBatches() {
this.batchDirty++;
const batches = this.batches;
for (let i = 0, l = batches.length; i < l; i++) {
const batch = batches[i];
for (let j = 0; j < batch.size; j++) {
const index = batch.start + j;
this.indicesUint16[index] = this.indicesUint16[index] - batch.attribStart;
}
}
}
isBatchable() {
return false;
}
/**
* Converts intermediate batches data to drawCalls.
*
* @protected
*/
buildDrawCalls(shaderSettings) {
for (let i = 0; i < this.drawCalls.length; i++) {
this.drawCalls[i].clear();
DRAW_CALL_POOL.push(this.drawCalls[i]);
}
this.drawCalls.length = 0;
let currentGroup = DRAW_CALL_POOL.pop() || new BatchDrawCall();
currentGroup.begin(shaderSettings, null);
let index = 0;
this.drawCalls.push(currentGroup);
for (let i = 0; i < this.batches.length; i++) {
const batchData = this.batches[i];
const style = batchData.style;
if (batchData.attribSize === 0) {
continue;
}
let styleId = -1;
const mat = style.getTextureMatrix();
if (currentGroup.check(style.shader)) {
styleId = currentGroup.add(
style.texture,
mat,
style.width,
style.alignment || 0,
style.packLineScale()
);
}
if (styleId < 0) {
currentGroup = DRAW_CALL_POOL.pop() || new BatchDrawCall();
this.drawCalls.push(currentGroup);
currentGroup.begin(shaderSettings, style.shader);
currentGroup.start = index;
styleId = currentGroup.add(
style.texture,
mat,
style.width,
style.alignment || 0,
style.packLineScale()
);
}
currentGroup.size += batchData.size;
index += batchData.size;
const { color, alpha } = style;
const bgr = Color.shared.setValue(color).toLittleEndianNumber();
batchData.rgba = Color.shared.setValue(bgr).toPremultiplied(alpha);
batchData.styleId = styleId;
}
}
processHoles(holes) {
for (let i = 0; i < holes.length; i++) {
const hole = holes[i];
const command = FILL_COMMANDS[hole.type];
hole.clearPath();
command.path(hole, this.buildData);
if (hole.matrix) {
this.transformPoints(hole.points, hole.matrix);
}
}
}
/**
* Update the local bounds of the object. Expensive to use performance-wise.
*
* @protected
*/
calculateBounds() {
const bounds = this._bounds;
const sequenceBounds = tmpBounds;
let curMatrix = Matrix.IDENTITY;
this._bounds.clear();
sequenceBounds.clear();
for (let i = 0; i < this.graphicsData.length; i++) {
const data = this.graphicsData[i];
const shape = data.shape;
const type = data.type;
const lineStyle = data.lineStyle;
const nextMatrix = data.matrix || Matrix.IDENTITY;
let lineWidth = 0;
if (lineStyle && lineStyle.visible) {
lineWidth = lineStyle.width;
if (type !== SHAPES.POLY || data.fillStyle.visible) {
lineWidth *= Math.max(0, lineStyle.alignment);
} else {
lineWidth *= Math.max(lineStyle.alignment, 1 - lineStyle.alignment);
}
}
if (curMatrix !== nextMatrix) {
if (!sequenceBounds.isEmpty()) {
bounds.addBoundsMatrix(sequenceBounds, curMatrix);
sequenceBounds.clear();
}
curMatrix = nextMatrix;
}
if (type === SHAPES.RECT || type === SHAPES.RREC) {
const rect = shape;
sequenceBounds.addFramePad(
rect.x,
rect.y,
rect.x + rect.width,
rect.y + rect.height,
lineWidth,
lineWidth
);
} else if (type === SHAPES.CIRC) {
const circle = shape;
sequenceBounds.addFramePad(
circle.x,
circle.y,
circle.x,
circle.y,
circle.radius + lineWidth,
circle.radius + lineWidth
);
} else if (type === SHAPES.ELIP) {
const ellipse = shape;
sequenceBounds.addFramePad(
ellipse.x,
ellipse.y,
ellipse.x,
ellipse.y,
ellipse.width + lineWidth,
ellipse.height + lineWidth
);
} else {
const poly = shape;
bounds.addVerticesMatrix(curMatrix, poly.points, 0, poly.points.length, lineWidth, lineWidth);
}
}
if (!sequenceBounds.isEmpty()) {
bounds.addBoundsMatrix(sequenceBounds, curMatrix);
}
bounds.pad(this.boundsPadding, this.boundsPadding);
}
/**
* Transform points using matrix.
*
* @protected
* @param {number[]} points - Points to transform
* @param {PIXI.Matrix} matrix - Transform matrix
*/
transformPoints(points, matrix) {
for (let i = 0; i < points.length / 2; i++) {
const x = points[i * 2];
const y = points[i * 2 + 1];
points[i * 2] = matrix.a * x + matrix.c * y + matrix.tx;
points[i * 2 + 1] = matrix.b * x + matrix.d * y + matrix.ty;
}
}
}
SmoothGraphicsGeometry.BATCHABLE_SIZE = 100;
export { BATCH_POOL, DRAW_CALL_POOL, SmoothGraphicsGeometry };
//# sourceMappingURL=SmoothGraphicsGeometry.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,499 @@
'use strict';
var core = require('@pixi/core');
const smoothVert = `#version 100
precision highp float;
const float FILL = 1.0;
const float BEVEL = 4.0;
const float MITER = 8.0;
const float ROUND = 12.0;
const float JOINT_CAP_BUTT = 16.0;
const float JOINT_CAP_SQUARE = 18.0;
const float JOINT_CAP_ROUND = 20.0;
const float FILL_EXPAND = 24.0;
const float CAP_BUTT = 1.0;
const float CAP_SQUARE = 2.0;
const float CAP_ROUND = 3.0;
const float CAP_BUTT2 = 4.0;
const float MITER_LIMIT = 10.0;
// === geom ===
attribute vec2 aPrev;
attribute vec2 aPoint1;
attribute vec2 aPoint2;
attribute vec2 aNext;
attribute float aVertexJoint;
attribute float aTravel;
uniform mat3 projectionMatrix;
uniform mat3 translationMatrix;
uniform vec4 tint;
varying vec4 vLine1;
varying vec4 vLine2;
varying vec4 vArc;
varying float vType;
uniform float resolution;
uniform float expand;
// === style ===
attribute float aStyleId;
attribute vec4 aColor;
varying float vTextureId;
varying vec4 vColor;
varying vec2 vTextureCoord;
varying vec2 vTravel;
uniform vec2 styleLine[%MAX_STYLES%];
uniform vec3 styleMatrix[2 * %MAX_STYLES%];
uniform float styleTextureId[%MAX_STYLES%];
uniform vec2 samplerSize[%MAX_TEXTURES%];
vec2 doBisect(vec2 norm, float len, vec2 norm2, float len2,
float dy, float inner) {
vec2 bisect = (norm + norm2) / 2.0;
bisect /= dot(norm, bisect);
vec2 shift = dy * bisect;
if (inner > 0.5) {
if (len < len2) {
if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {
return dy * norm;
}
} else {
if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {
return dy * norm;
}
}
}
return dy * bisect;
}
void main(void){
vec2 pointA = (translationMatrix * vec3(aPoint1, 1.0)).xy;
vec2 pointB = (translationMatrix * vec3(aPoint2, 1.0)).xy;
vec2 xBasis = pointB - pointA;
float len = length(xBasis);
vec2 forward = xBasis / len;
vec2 norm = vec2(forward.y, -forward.x);
float type = floor(aVertexJoint / 16.0);
float vertexNum = aVertexJoint - type * 16.0;
float dx = 0.0, dy = 1.0;
float capType = floor(type / 32.0);
type -= capType * 32.0;
int styleId = int(aStyleId + 0.5);
float lineWidth = styleLine[styleId].x;
vTextureId = floor(styleTextureId[styleId] / 4.0);
float scaleMode = styleTextureId[styleId] - vTextureId * 4.0;
float avgScale = 1.0;
if (scaleMode > 2.5) {
avgScale = length(translationMatrix * vec3(1.0, 0.0, 0.0));
} else if (scaleMode > 1.5) {
avgScale = length(translationMatrix * vec3(0.0, 1.0, 0.0));
} else if (scaleMode > 0.5) {
vec2 avgDiag = (translationMatrix * vec3(1.0, 1.0, 0.0)).xy;
avgScale = sqrt(dot(avgDiag, avgDiag) * 0.5);
}
lineWidth *= 0.5 * avgScale;
float lineAlignment = 2.0 * styleLine[styleId].y - 1.0;
vTextureCoord = vec2(0.0);
vec2 pos;
if (capType == CAP_ROUND) {
vertexNum += 4.0;
type = JOINT_CAP_ROUND;
capType = 0.0;
lineAlignment = -lineAlignment;
}
vLine1 = vec4(0.0, 10.0, 1.0, 0.0);
vLine2 = vec4(0.0, 10.0, 1.0, 0.0);
vArc = vec4(0.0);
if (type == FILL) {
pos = pointA;
vType = 0.0;
vLine2 = vec4(-2.0, -2.0, -2.0, 0.0);
vec2 vTexturePixel;
vTexturePixel.x = dot(vec3(aPoint1, 1.0), styleMatrix[styleId * 2]);
vTexturePixel.y = dot(vec3(aPoint1, 1.0), styleMatrix[styleId * 2 + 1]);
vTextureCoord = vTexturePixel / samplerSize[int(vTextureId)];
} else if (type >= FILL_EXPAND && type < FILL_EXPAND + 7.5) {
// expand vertices
float flags = type - FILL_EXPAND;
float flag3 = floor(flags / 4.0);
float flag2 = floor((flags - flag3 * 4.0) / 2.0);
float flag1 = flags - flag3 * 4.0 - flag2 * 2.0;
vec2 prev = (translationMatrix * vec3(aPrev, 1.0)).xy;
if (vertexNum < 0.5) {
pos = prev;
} else if (vertexNum < 1.5) {
pos = pointA;
} else {
pos = pointB;
}
float len2 = length(aNext);
vec2 bisect = (translationMatrix * vec3(aNext, 0.0)).xy;
if (len2 > 0.01) {
bisect = normalize(bisect) * len2;
}
vec2 n1 = normalize(vec2(pointA.y - prev.y, -(pointA.x - prev.x)));
vec2 n2 = normalize(vec2(pointB.y - pointA.y, -(pointB.x - pointA.x)));
vec2 n3 = normalize(vec2(prev.y - pointB.y, -(prev.x - pointB.x)));
if (n1.x * n2.y - n1.y * n2.x < 0.0) {
n1 = -n1;
n2 = -n2;
n3 = -n3;
}
pos += bisect * expand;
vLine1 = vec4(16.0, 16.0, 16.0, -1.0);
if (flag1 > 0.5) {
vLine1.x = -dot(pos - prev, n1);
}
if (flag2 > 0.5) {
vLine1.y = -dot(pos - pointA, n2);
}
if (flag3 > 0.5) {
vLine1.z = -dot(pos - pointB, n3);
}
vLine1.xyz *= resolution;
vType = 2.0;
} else if (type >= BEVEL) {
float dy = lineWidth + expand;
float shift = lineWidth * lineAlignment;
float inner = 0.0;
if (vertexNum >= 1.5) {
dy = -dy;
inner = 1.0;
}
vec2 base, next, xBasis2, bisect;
float flag = 0.0;
float side2 = 1.0;
if (vertexNum < 0.5 || vertexNum > 2.5 && vertexNum < 3.5) {
next = (translationMatrix * vec3(aPrev, 1.0)).xy;
base = pointA;
flag = type - floor(type / 2.0) * 2.0;
side2 = -1.0;
} else {
next = (translationMatrix * vec3(aNext, 1.0)).xy;
base = pointB;
if (type >= MITER && type < MITER + 3.5) {
flag = step(MITER + 1.5, type);
// check miter limit here?
}
}
xBasis2 = next - base;
float len2 = length(xBasis2);
vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;
float D = norm.x * norm2.y - norm.y * norm2.x;
if (D < 0.0) {
inner = 1.0 - inner;
}
norm2 *= side2;
float collinear = step(0.0, dot(norm, norm2));
vType = 0.0;
float dy2 = -1000.0;
if (abs(D) < 0.01 && collinear < 0.5) {
if (type >= ROUND && type < ROUND + 1.5) {
type = JOINT_CAP_ROUND;
}
//TODO: BUTT here too
}
vLine1 = vec4(0.0, lineWidth, max(abs(norm.x), abs(norm.y)), min(abs(norm.x), abs(norm.y)));
vLine2 = vec4(0.0, lineWidth, max(abs(norm2.x), abs(norm2.y)), min(abs(norm2.x), abs(norm2.y)));
if (vertexNum < 3.5) {
if (abs(D) < 0.01 && collinear < 0.5) {
pos = (shift + dy) * norm;
} else {
if (flag < 0.5 && inner < 0.5) {
pos = (shift + dy) * norm;
} else {
pos = doBisect(norm, len, norm2, len2, shift + dy, inner);
}
}
vLine2.y = -1000.0;
if (capType >= CAP_BUTT && capType < CAP_ROUND) {
float extra = step(CAP_SQUARE, capType) * lineWidth;
vec2 back = -forward;
if (vertexNum < 0.5 || vertexNum > 2.5) {
pos += back * (expand + extra);
dy2 = expand;
} else {
dy2 = dot(pos + base - pointA, back) - extra;
}
}
if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {
float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;
if (vertexNum < 0.5 || vertexNum > 2.5) {
vLine2.y = dot(pos + base - pointB, forward) - extra;
} else {
pos += forward * (expand + extra);
vLine2.y = expand;
if (capType >= CAP_BUTT) {
dy2 -= expand + extra;
}
}
}
} else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {
base += shift * norm;
if (inner > 0.5) {
dy = -dy;
inner = 0.0;
}
vec2 d2 = abs(dy) * forward;
if (vertexNum < 4.5) {
dy = -dy;
pos = dy * norm;
} else if (vertexNum < 5.5) {
pos = dy * norm;
} else if (vertexNum < 6.5) {
pos = dy * norm + d2;
vArc.x = abs(dy);
} else {
dy = -dy;
pos = dy * norm + d2;
vArc.x = abs(dy);
}
vLine2 = vec4(0.0, lineWidth * 2.0 + 10.0, 1.0 , 0.0); // forget about line2 with type=3
vArc.y = dy;
vArc.z = 0.0;
vArc.w = lineWidth;
vType = 3.0;
} else if (abs(D) < 0.01 && collinear < 0.5) {
pos = dy * norm;
} else {
if (inner > 0.5) {
dy = -dy;
inner = 0.0;
}
float side = sign(dy);
vec2 norm3 = normalize(norm + norm2);
if (type >= MITER && type < MITER + 3.5) {
vec2 farVertex = doBisect(norm, len, norm2, len2, shift + dy, 0.0);
if (length(farVertex) > abs(shift + dy) * MITER_LIMIT) {
type = BEVEL;
}
}
if (vertexNum < 4.5) {
pos = doBisect(norm, len, norm2, len2, shift - dy, 1.0);
} else if (vertexNum < 5.5) {
pos = (shift + dy) * norm;
} else if (vertexNum > 7.5) {
pos = (shift + dy) * norm2;
} else {
if (type >= ROUND && type < ROUND + 1.5) {
pos = doBisect(norm, len, norm2, len2, shift + dy, 0.0);
float d2 = abs(shift + dy);
if (length(pos) > abs(shift + dy) * 1.5) {
if (vertexNum < 6.5) {
pos.x = (shift + dy) * norm.x - d2 * norm.y;
pos.y = (shift + dy) * norm.y + d2 * norm.x;
} else {
pos.x = (shift + dy) * norm2.x + d2 * norm2.y;
pos.y = (shift + dy) * norm2.y - d2 * norm2.x;
}
}
} else if (type >= MITER && type < MITER + 3.5) {
pos = doBisect(norm, len, norm2, len2, shift + dy, 0.0); //farVertex
} else if (type >= BEVEL && type < BEVEL + 1.5) {
float d2 = side / resolution;
if (vertexNum < 6.5) {
pos = (shift + dy) * norm + d2 * norm3;
} else {
pos = (shift + dy) * norm2 + d2 * norm3;
}
}
}
if (type >= ROUND && type < ROUND + 1.5) {
vArc.x = side * dot(pos, norm3);
vArc.y = pos.x * norm3.y - pos.y * norm3.x;
vArc.z = dot(norm, norm3) * (lineWidth + side * shift);
vArc.w = lineWidth + side * shift;
vType = 3.0;
} else if (type >= MITER && type < MITER + 3.5) {
vType = 1.0;
} else if (type >= BEVEL && type < BEVEL + 1.5) {
vType = 4.0;
vArc.z = dot(norm, norm3) * (lineWidth + side * shift) - side * dot(pos, norm3);
}
dy = side * (dot(pos, norm) - shift);
dy2 = side * (dot(pos, norm2) - shift);
}
pos += base;
vLine1.xy = vec2(dy, vLine1.y) * resolution;
vLine2.xy = vec2(dy2, vLine2.y) * resolution;
vArc = vArc * resolution;
vTravel = vec2(aTravel * avgScale + dot(pos - pointA, vec2(-norm.y, norm.x)), avgScale);
}
gl_Position = vec4((projectionMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);
vColor = aColor * tint;
}`;
const precision = `#version 100
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
`;
const smoothFrag = `%PRECISION%
varying vec4 vColor;
varying vec4 vLine1;
varying vec4 vLine2;
varying vec4 vArc;
varying float vType;
varying float vTextureId;
varying vec2 vTextureCoord;
varying vec2 vTravel;
uniform sampler2D uSamplers[%MAX_TEXTURES%];
%PIXEL_LINE%
void main(void){
%PIXEL_COVERAGE%
vec4 texColor;
float textureId = floor(vTextureId+0.5);
%FOR_LOOP%
gl_FragColor = vColor * texColor * alpha;
}
`;
const pixelLineFunc = [`
float pixelLine(float x, float A, float B) {
return clamp(x + 0.5, 0.0, 1.0);
}
`, `
float pixelLine(float x, float A, float B) {
float y = abs(x), s = sign(x);
if (y * 2.0 < A - B) {
return 0.5 + s * y / A;
}
y -= (A - B) * 0.5;
y = max(1.0 - y / B, 0.0);
return (1.0 + s * (1.0 - y * y)) * 0.5;
//return clamp(x + 0.5, 0.0, 1.0);
}
`];
const pixelCoverage = `float alpha = 1.0;
if (vType < 0.5) {
float left = pixelLine(-vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float right = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float near = vLine2.x - 0.5;
float far = min(vLine2.x + 0.5, 0.0);
float top = vLine2.y - 0.5;
float bottom = min(vLine2.y + 0.5, 0.0);
alpha = (right - left) * max(bottom - top, 0.0) * max(far - near, 0.0);
} else if (vType < 1.5) {
float a1 = pixelLine(- vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float a2 = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float b1 = pixelLine(- vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float b2 = pixelLine(vLine2.y - vLine2.x, vLine2.z, vLine2.w);
alpha = a2 * b2 - a1 * b1;
} else if (vType < 2.5) {
alpha *= max(min(vLine1.x + 0.5, 1.0), 0.0);
alpha *= max(min(vLine1.y + 0.5, 1.0), 0.0);
alpha *= max(min(vLine1.z + 0.5, 1.0), 0.0);
} else if (vType < 3.5) {
float a1 = pixelLine(- vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float a2 = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float b1 = pixelLine(- vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float b2 = pixelLine(vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float alpha_miter = a2 * b2 - a1 * b1;
float alpha_plane = clamp(vArc.z - vArc.x + 0.5, 0.0, 1.0);
float d = length(vArc.xy);
float circle_hor = max(min(vArc.w, d + 0.5) - max(-vArc.w, d - 0.5), 0.0);
float circle_vert = min(vArc.w * 2.0, 1.0);
float alpha_circle = circle_hor * circle_vert;
alpha = min(alpha_miter, max(alpha_circle, alpha_plane));
} else {
float a1 = pixelLine(- vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float a2 = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float b1 = pixelLine(- vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float b2 = pixelLine(vLine2.y - vLine2.x, vLine2.z, vLine2.w);
alpha = a2 * b2 - a1 * b1;
alpha *= clamp(vArc.z + 0.5, 0.0, 1.0);
}
`;
class SmoothGraphicsShader extends core.Shader {
constructor(settings, vert = smoothVert, frag = smoothFrag, uniforms = {}) {
vert = SmoothGraphicsShader.generateVertexSrc(settings, vert);
frag = SmoothGraphicsShader.generateFragmentSrc(settings, frag);
const { maxStyles, maxTextures } = settings;
const sampleValues = new Int32Array(maxTextures);
for (let i = 0; i < maxTextures; i++) {
sampleValues[i] = i;
}
super(core.Program.from(vert, frag), Object.assign(uniforms, {
styleMatrix: new Float32Array(6 * maxStyles),
styleTextureId: new Float32Array(maxStyles),
styleLine: new Float32Array(2 * maxStyles),
samplerSize: new Float32Array(2 * maxTextures),
uSamplers: sampleValues,
tint: new Float32Array([1, 1, 1, 1]),
resolution: 1,
expand: 1
}));
this.settings = settings;
}
static generateVertexSrc(settings, vertexSrc = smoothVert) {
const { maxStyles, maxTextures } = settings;
vertexSrc = vertexSrc.replace(/%MAX_TEXTURES%/gi, `${maxTextures}`).replace(/%MAX_STYLES%/gi, `${maxStyles}`);
return vertexSrc;
}
static generateFragmentSrc(settings, fragmentSrc = smoothFrag) {
const { maxTextures, pixelLine } = settings;
fragmentSrc = fragmentSrc.replace(/%PRECISION%/gi, precision).replace(/%PIXEL_LINE%/gi, pixelLineFunc[pixelLine]).replace(/%PIXEL_COVERAGE%/gi, pixelCoverage).replace(/%MAX_TEXTURES%/gi, `${maxTextures}`).replace(/%FOR_LOOP%/gi, this.generateSampleSrc(maxTextures));
return fragmentSrc;
}
static generateSampleSrc(maxTextures) {
let src = "";
src += "\n";
src += "\n";
for (let i = 0; i < maxTextures; i++) {
if (i > 0) {
src += "\nelse ";
}
if (i < maxTextures - 1) {
src += `if(textureId < ${i}.5)`;
}
src += "\n{";
src += `
texColor = texture2D(uSamplers[${i}], vTextureCoord);`;
src += "\n}";
}
src += "\n";
src += "\n";
return src;
}
}
exports.SmoothGraphicsShader = SmoothGraphicsShader;
//# sourceMappingURL=SmoothShader.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,497 @@
import { Shader, Program } from '@pixi/core';
const smoothVert = `#version 100
precision highp float;
const float FILL = 1.0;
const float BEVEL = 4.0;
const float MITER = 8.0;
const float ROUND = 12.0;
const float JOINT_CAP_BUTT = 16.0;
const float JOINT_CAP_SQUARE = 18.0;
const float JOINT_CAP_ROUND = 20.0;
const float FILL_EXPAND = 24.0;
const float CAP_BUTT = 1.0;
const float CAP_SQUARE = 2.0;
const float CAP_ROUND = 3.0;
const float CAP_BUTT2 = 4.0;
const float MITER_LIMIT = 10.0;
// === geom ===
attribute vec2 aPrev;
attribute vec2 aPoint1;
attribute vec2 aPoint2;
attribute vec2 aNext;
attribute float aVertexJoint;
attribute float aTravel;
uniform mat3 projectionMatrix;
uniform mat3 translationMatrix;
uniform vec4 tint;
varying vec4 vLine1;
varying vec4 vLine2;
varying vec4 vArc;
varying float vType;
uniform float resolution;
uniform float expand;
// === style ===
attribute float aStyleId;
attribute vec4 aColor;
varying float vTextureId;
varying vec4 vColor;
varying vec2 vTextureCoord;
varying vec2 vTravel;
uniform vec2 styleLine[%MAX_STYLES%];
uniform vec3 styleMatrix[2 * %MAX_STYLES%];
uniform float styleTextureId[%MAX_STYLES%];
uniform vec2 samplerSize[%MAX_TEXTURES%];
vec2 doBisect(vec2 norm, float len, vec2 norm2, float len2,
float dy, float inner) {
vec2 bisect = (norm + norm2) / 2.0;
bisect /= dot(norm, bisect);
vec2 shift = dy * bisect;
if (inner > 0.5) {
if (len < len2) {
if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {
return dy * norm;
}
} else {
if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {
return dy * norm;
}
}
}
return dy * bisect;
}
void main(void){
vec2 pointA = (translationMatrix * vec3(aPoint1, 1.0)).xy;
vec2 pointB = (translationMatrix * vec3(aPoint2, 1.0)).xy;
vec2 xBasis = pointB - pointA;
float len = length(xBasis);
vec2 forward = xBasis / len;
vec2 norm = vec2(forward.y, -forward.x);
float type = floor(aVertexJoint / 16.0);
float vertexNum = aVertexJoint - type * 16.0;
float dx = 0.0, dy = 1.0;
float capType = floor(type / 32.0);
type -= capType * 32.0;
int styleId = int(aStyleId + 0.5);
float lineWidth = styleLine[styleId].x;
vTextureId = floor(styleTextureId[styleId] / 4.0);
float scaleMode = styleTextureId[styleId] - vTextureId * 4.0;
float avgScale = 1.0;
if (scaleMode > 2.5) {
avgScale = length(translationMatrix * vec3(1.0, 0.0, 0.0));
} else if (scaleMode > 1.5) {
avgScale = length(translationMatrix * vec3(0.0, 1.0, 0.0));
} else if (scaleMode > 0.5) {
vec2 avgDiag = (translationMatrix * vec3(1.0, 1.0, 0.0)).xy;
avgScale = sqrt(dot(avgDiag, avgDiag) * 0.5);
}
lineWidth *= 0.5 * avgScale;
float lineAlignment = 2.0 * styleLine[styleId].y - 1.0;
vTextureCoord = vec2(0.0);
vec2 pos;
if (capType == CAP_ROUND) {
vertexNum += 4.0;
type = JOINT_CAP_ROUND;
capType = 0.0;
lineAlignment = -lineAlignment;
}
vLine1 = vec4(0.0, 10.0, 1.0, 0.0);
vLine2 = vec4(0.0, 10.0, 1.0, 0.0);
vArc = vec4(0.0);
if (type == FILL) {
pos = pointA;
vType = 0.0;
vLine2 = vec4(-2.0, -2.0, -2.0, 0.0);
vec2 vTexturePixel;
vTexturePixel.x = dot(vec3(aPoint1, 1.0), styleMatrix[styleId * 2]);
vTexturePixel.y = dot(vec3(aPoint1, 1.0), styleMatrix[styleId * 2 + 1]);
vTextureCoord = vTexturePixel / samplerSize[int(vTextureId)];
} else if (type >= FILL_EXPAND && type < FILL_EXPAND + 7.5) {
// expand vertices
float flags = type - FILL_EXPAND;
float flag3 = floor(flags / 4.0);
float flag2 = floor((flags - flag3 * 4.0) / 2.0);
float flag1 = flags - flag3 * 4.0 - flag2 * 2.0;
vec2 prev = (translationMatrix * vec3(aPrev, 1.0)).xy;
if (vertexNum < 0.5) {
pos = prev;
} else if (vertexNum < 1.5) {
pos = pointA;
} else {
pos = pointB;
}
float len2 = length(aNext);
vec2 bisect = (translationMatrix * vec3(aNext, 0.0)).xy;
if (len2 > 0.01) {
bisect = normalize(bisect) * len2;
}
vec2 n1 = normalize(vec2(pointA.y - prev.y, -(pointA.x - prev.x)));
vec2 n2 = normalize(vec2(pointB.y - pointA.y, -(pointB.x - pointA.x)));
vec2 n3 = normalize(vec2(prev.y - pointB.y, -(prev.x - pointB.x)));
if (n1.x * n2.y - n1.y * n2.x < 0.0) {
n1 = -n1;
n2 = -n2;
n3 = -n3;
}
pos += bisect * expand;
vLine1 = vec4(16.0, 16.0, 16.0, -1.0);
if (flag1 > 0.5) {
vLine1.x = -dot(pos - prev, n1);
}
if (flag2 > 0.5) {
vLine1.y = -dot(pos - pointA, n2);
}
if (flag3 > 0.5) {
vLine1.z = -dot(pos - pointB, n3);
}
vLine1.xyz *= resolution;
vType = 2.0;
} else if (type >= BEVEL) {
float dy = lineWidth + expand;
float shift = lineWidth * lineAlignment;
float inner = 0.0;
if (vertexNum >= 1.5) {
dy = -dy;
inner = 1.0;
}
vec2 base, next, xBasis2, bisect;
float flag = 0.0;
float side2 = 1.0;
if (vertexNum < 0.5 || vertexNum > 2.5 && vertexNum < 3.5) {
next = (translationMatrix * vec3(aPrev, 1.0)).xy;
base = pointA;
flag = type - floor(type / 2.0) * 2.0;
side2 = -1.0;
} else {
next = (translationMatrix * vec3(aNext, 1.0)).xy;
base = pointB;
if (type >= MITER && type < MITER + 3.5) {
flag = step(MITER + 1.5, type);
// check miter limit here?
}
}
xBasis2 = next - base;
float len2 = length(xBasis2);
vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;
float D = norm.x * norm2.y - norm.y * norm2.x;
if (D < 0.0) {
inner = 1.0 - inner;
}
norm2 *= side2;
float collinear = step(0.0, dot(norm, norm2));
vType = 0.0;
float dy2 = -1000.0;
if (abs(D) < 0.01 && collinear < 0.5) {
if (type >= ROUND && type < ROUND + 1.5) {
type = JOINT_CAP_ROUND;
}
//TODO: BUTT here too
}
vLine1 = vec4(0.0, lineWidth, max(abs(norm.x), abs(norm.y)), min(abs(norm.x), abs(norm.y)));
vLine2 = vec4(0.0, lineWidth, max(abs(norm2.x), abs(norm2.y)), min(abs(norm2.x), abs(norm2.y)));
if (vertexNum < 3.5) {
if (abs(D) < 0.01 && collinear < 0.5) {
pos = (shift + dy) * norm;
} else {
if (flag < 0.5 && inner < 0.5) {
pos = (shift + dy) * norm;
} else {
pos = doBisect(norm, len, norm2, len2, shift + dy, inner);
}
}
vLine2.y = -1000.0;
if (capType >= CAP_BUTT && capType < CAP_ROUND) {
float extra = step(CAP_SQUARE, capType) * lineWidth;
vec2 back = -forward;
if (vertexNum < 0.5 || vertexNum > 2.5) {
pos += back * (expand + extra);
dy2 = expand;
} else {
dy2 = dot(pos + base - pointA, back) - extra;
}
}
if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {
float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;
if (vertexNum < 0.5 || vertexNum > 2.5) {
vLine2.y = dot(pos + base - pointB, forward) - extra;
} else {
pos += forward * (expand + extra);
vLine2.y = expand;
if (capType >= CAP_BUTT) {
dy2 -= expand + extra;
}
}
}
} else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {
base += shift * norm;
if (inner > 0.5) {
dy = -dy;
inner = 0.0;
}
vec2 d2 = abs(dy) * forward;
if (vertexNum < 4.5) {
dy = -dy;
pos = dy * norm;
} else if (vertexNum < 5.5) {
pos = dy * norm;
} else if (vertexNum < 6.5) {
pos = dy * norm + d2;
vArc.x = abs(dy);
} else {
dy = -dy;
pos = dy * norm + d2;
vArc.x = abs(dy);
}
vLine2 = vec4(0.0, lineWidth * 2.0 + 10.0, 1.0 , 0.0); // forget about line2 with type=3
vArc.y = dy;
vArc.z = 0.0;
vArc.w = lineWidth;
vType = 3.0;
} else if (abs(D) < 0.01 && collinear < 0.5) {
pos = dy * norm;
} else {
if (inner > 0.5) {
dy = -dy;
inner = 0.0;
}
float side = sign(dy);
vec2 norm3 = normalize(norm + norm2);
if (type >= MITER && type < MITER + 3.5) {
vec2 farVertex = doBisect(norm, len, norm2, len2, shift + dy, 0.0);
if (length(farVertex) > abs(shift + dy) * MITER_LIMIT) {
type = BEVEL;
}
}
if (vertexNum < 4.5) {
pos = doBisect(norm, len, norm2, len2, shift - dy, 1.0);
} else if (vertexNum < 5.5) {
pos = (shift + dy) * norm;
} else if (vertexNum > 7.5) {
pos = (shift + dy) * norm2;
} else {
if (type >= ROUND && type < ROUND + 1.5) {
pos = doBisect(norm, len, norm2, len2, shift + dy, 0.0);
float d2 = abs(shift + dy);
if (length(pos) > abs(shift + dy) * 1.5) {
if (vertexNum < 6.5) {
pos.x = (shift + dy) * norm.x - d2 * norm.y;
pos.y = (shift + dy) * norm.y + d2 * norm.x;
} else {
pos.x = (shift + dy) * norm2.x + d2 * norm2.y;
pos.y = (shift + dy) * norm2.y - d2 * norm2.x;
}
}
} else if (type >= MITER && type < MITER + 3.5) {
pos = doBisect(norm, len, norm2, len2, shift + dy, 0.0); //farVertex
} else if (type >= BEVEL && type < BEVEL + 1.5) {
float d2 = side / resolution;
if (vertexNum < 6.5) {
pos = (shift + dy) * norm + d2 * norm3;
} else {
pos = (shift + dy) * norm2 + d2 * norm3;
}
}
}
if (type >= ROUND && type < ROUND + 1.5) {
vArc.x = side * dot(pos, norm3);
vArc.y = pos.x * norm3.y - pos.y * norm3.x;
vArc.z = dot(norm, norm3) * (lineWidth + side * shift);
vArc.w = lineWidth + side * shift;
vType = 3.0;
} else if (type >= MITER && type < MITER + 3.5) {
vType = 1.0;
} else if (type >= BEVEL && type < BEVEL + 1.5) {
vType = 4.0;
vArc.z = dot(norm, norm3) * (lineWidth + side * shift) - side * dot(pos, norm3);
}
dy = side * (dot(pos, norm) - shift);
dy2 = side * (dot(pos, norm2) - shift);
}
pos += base;
vLine1.xy = vec2(dy, vLine1.y) * resolution;
vLine2.xy = vec2(dy2, vLine2.y) * resolution;
vArc = vArc * resolution;
vTravel = vec2(aTravel * avgScale + dot(pos - pointA, vec2(-norm.y, norm.x)), avgScale);
}
gl_Position = vec4((projectionMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);
vColor = aColor * tint;
}`;
const precision = `#version 100
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
`;
const smoothFrag = `%PRECISION%
varying vec4 vColor;
varying vec4 vLine1;
varying vec4 vLine2;
varying vec4 vArc;
varying float vType;
varying float vTextureId;
varying vec2 vTextureCoord;
varying vec2 vTravel;
uniform sampler2D uSamplers[%MAX_TEXTURES%];
%PIXEL_LINE%
void main(void){
%PIXEL_COVERAGE%
vec4 texColor;
float textureId = floor(vTextureId+0.5);
%FOR_LOOP%
gl_FragColor = vColor * texColor * alpha;
}
`;
const pixelLineFunc = [`
float pixelLine(float x, float A, float B) {
return clamp(x + 0.5, 0.0, 1.0);
}
`, `
float pixelLine(float x, float A, float B) {
float y = abs(x), s = sign(x);
if (y * 2.0 < A - B) {
return 0.5 + s * y / A;
}
y -= (A - B) * 0.5;
y = max(1.0 - y / B, 0.0);
return (1.0 + s * (1.0 - y * y)) * 0.5;
//return clamp(x + 0.5, 0.0, 1.0);
}
`];
const pixelCoverage = `float alpha = 1.0;
if (vType < 0.5) {
float left = pixelLine(-vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float right = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float near = vLine2.x - 0.5;
float far = min(vLine2.x + 0.5, 0.0);
float top = vLine2.y - 0.5;
float bottom = min(vLine2.y + 0.5, 0.0);
alpha = (right - left) * max(bottom - top, 0.0) * max(far - near, 0.0);
} else if (vType < 1.5) {
float a1 = pixelLine(- vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float a2 = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float b1 = pixelLine(- vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float b2 = pixelLine(vLine2.y - vLine2.x, vLine2.z, vLine2.w);
alpha = a2 * b2 - a1 * b1;
} else if (vType < 2.5) {
alpha *= max(min(vLine1.x + 0.5, 1.0), 0.0);
alpha *= max(min(vLine1.y + 0.5, 1.0), 0.0);
alpha *= max(min(vLine1.z + 0.5, 1.0), 0.0);
} else if (vType < 3.5) {
float a1 = pixelLine(- vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float a2 = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float b1 = pixelLine(- vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float b2 = pixelLine(vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float alpha_miter = a2 * b2 - a1 * b1;
float alpha_plane = clamp(vArc.z - vArc.x + 0.5, 0.0, 1.0);
float d = length(vArc.xy);
float circle_hor = max(min(vArc.w, d + 0.5) - max(-vArc.w, d - 0.5), 0.0);
float circle_vert = min(vArc.w * 2.0, 1.0);
float alpha_circle = circle_hor * circle_vert;
alpha = min(alpha_miter, max(alpha_circle, alpha_plane));
} else {
float a1 = pixelLine(- vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float a2 = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float b1 = pixelLine(- vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float b2 = pixelLine(vLine2.y - vLine2.x, vLine2.z, vLine2.w);
alpha = a2 * b2 - a1 * b1;
alpha *= clamp(vArc.z + 0.5, 0.0, 1.0);
}
`;
class SmoothGraphicsShader extends Shader {
constructor(settings, vert = smoothVert, frag = smoothFrag, uniforms = {}) {
vert = SmoothGraphicsShader.generateVertexSrc(settings, vert);
frag = SmoothGraphicsShader.generateFragmentSrc(settings, frag);
const { maxStyles, maxTextures } = settings;
const sampleValues = new Int32Array(maxTextures);
for (let i = 0; i < maxTextures; i++) {
sampleValues[i] = i;
}
super(Program.from(vert, frag), Object.assign(uniforms, {
styleMatrix: new Float32Array(6 * maxStyles),
styleTextureId: new Float32Array(maxStyles),
styleLine: new Float32Array(2 * maxStyles),
samplerSize: new Float32Array(2 * maxTextures),
uSamplers: sampleValues,
tint: new Float32Array([1, 1, 1, 1]),
resolution: 1,
expand: 1
}));
this.settings = settings;
}
static generateVertexSrc(settings, vertexSrc = smoothVert) {
const { maxStyles, maxTextures } = settings;
vertexSrc = vertexSrc.replace(/%MAX_TEXTURES%/gi, `${maxTextures}`).replace(/%MAX_STYLES%/gi, `${maxStyles}`);
return vertexSrc;
}
static generateFragmentSrc(settings, fragmentSrc = smoothFrag) {
const { maxTextures, pixelLine } = settings;
fragmentSrc = fragmentSrc.replace(/%PRECISION%/gi, precision).replace(/%PIXEL_LINE%/gi, pixelLineFunc[pixelLine]).replace(/%PIXEL_COVERAGE%/gi, pixelCoverage).replace(/%MAX_TEXTURES%/gi, `${maxTextures}`).replace(/%FOR_LOOP%/gi, this.generateSampleSrc(maxTextures));
return fragmentSrc;
}
static generateSampleSrc(maxTextures) {
let src = "";
src += "\n";
src += "\n";
for (let i = 0; i < maxTextures; i++) {
if (i > 0) {
src += "\nelse ";
}
if (i < maxTextures - 1) {
src += `if(textureId < ${i}.5)`;
}
src += "\n{";
src += `
texColor = texture2D(uSamplers[${i}], vTextureCoord);`;
src += "\n}";
}
src += "\n";
src += "\n";
return src;
}
}
export { SmoothGraphicsShader };
//# sourceMappingURL=SmoothShader.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,107 @@
'use strict';
var core = require('@pixi/core');
function matrixEquals(th, matrix, eps = 1e-3) {
return this === matrix || Math.abs(th.a - matrix.a) < eps && Math.abs(th.b - matrix.b) < eps && Math.abs(th.c - matrix.c) < eps && Math.abs(th.d - matrix.d) < eps && Math.abs(th.tx - matrix.tx) < eps && Math.abs(th.ty - matrix.ty) < eps;
}
class BatchStyleArray {
constructor() {
this.textureIds = [];
this.matrices = [];
this.lines = [];
this.count = 0;
}
clear() {
for (let i = 0; i < this.count; i++) {
this.textureIds[i] = null;
this.matrices[i] = null;
}
this.count = 0;
}
add(textureId, matrix, lineWidth, lineAlignment, lineScaleMode, settings) {
const { textureIds, matrices, lines, count } = this;
textureId = textureId * 4 + lineScaleMode;
for (let i = 0; i < count; i++) {
if (lines[i * 2] === lineWidth && lines[i * 2 + 1] === lineAlignment && textureIds[i] === textureId && matrixEquals(matrices[i], matrix)) {
return i;
}
}
if (count >= settings.maxStyles) {
return -1;
}
textureIds[count] = textureId;
matrices[count] = matrix;
lines[count * 2] = lineWidth;
lines[count * 2 + 1] = lineAlignment;
this.count++;
return count;
}
}
class BatchDrawCall {
constructor() {
this.texArray = new core.BatchTextureArray();
this.styleArray = new BatchStyleArray();
this.shader = null;
this.blend = core.BLEND_MODES.NORMAL;
this.start = 0;
this.size = 0;
this.TICK = 0;
this.settings = null;
this.data = null;
}
clear() {
this.texArray.clear();
this.styleArray.clear();
this.settings = null;
this.data = null;
this.shader = null;
}
begin(settings, shader) {
this.TICK = ++core.BaseTexture._globalBatch;
this.settings = settings;
this.shader = shader;
this.start = 0;
this.size = 0;
this.data = null;
if (shader && shader.settings) {
this.settings = shader.settings;
}
}
check(shader) {
if (this.size === 0) {
this.shader = shader;
return true;
}
return this.shader === shader;
}
add(texture, matrix, lineWidth, lineAlignment, lineScaleMode) {
const { texArray, TICK, styleArray, settings } = this;
const { baseTexture } = texture;
if (baseTexture._batchEnabled !== TICK && texArray.count === settings.maxTextures) {
return -1;
}
const loc = baseTexture._batchEnabled !== TICK ? texArray.count : baseTexture._batchLocation;
const res = styleArray.add(
loc,
matrix || core.Matrix.IDENTITY,
lineWidth,
lineAlignment,
lineScaleMode,
settings
);
if (res >= 0) {
if (baseTexture._batchEnabled !== TICK) {
baseTexture._batchEnabled = TICK;
baseTexture._batchLocation = texArray.count;
texArray.elements[texArray.count++] = baseTexture;
}
}
return res;
}
}
exports.BatchDrawCall = BatchDrawCall;
exports.BatchStyleArray = BatchStyleArray;
exports.matrixEquals = matrixEquals;
//# sourceMappingURL=BatchDrawCall.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,103 @@
import { BatchTextureArray, BLEND_MODES, BaseTexture, Matrix } from '@pixi/core';
function matrixEquals(th, matrix, eps = 1e-3) {
return this === matrix || Math.abs(th.a - matrix.a) < eps && Math.abs(th.b - matrix.b) < eps && Math.abs(th.c - matrix.c) < eps && Math.abs(th.d - matrix.d) < eps && Math.abs(th.tx - matrix.tx) < eps && Math.abs(th.ty - matrix.ty) < eps;
}
class BatchStyleArray {
constructor() {
this.textureIds = [];
this.matrices = [];
this.lines = [];
this.count = 0;
}
clear() {
for (let i = 0; i < this.count; i++) {
this.textureIds[i] = null;
this.matrices[i] = null;
}
this.count = 0;
}
add(textureId, matrix, lineWidth, lineAlignment, lineScaleMode, settings) {
const { textureIds, matrices, lines, count } = this;
textureId = textureId * 4 + lineScaleMode;
for (let i = 0; i < count; i++) {
if (lines[i * 2] === lineWidth && lines[i * 2 + 1] === lineAlignment && textureIds[i] === textureId && matrixEquals(matrices[i], matrix)) {
return i;
}
}
if (count >= settings.maxStyles) {
return -1;
}
textureIds[count] = textureId;
matrices[count] = matrix;
lines[count * 2] = lineWidth;
lines[count * 2 + 1] = lineAlignment;
this.count++;
return count;
}
}
class BatchDrawCall {
constructor() {
this.texArray = new BatchTextureArray();
this.styleArray = new BatchStyleArray();
this.shader = null;
this.blend = BLEND_MODES.NORMAL;
this.start = 0;
this.size = 0;
this.TICK = 0;
this.settings = null;
this.data = null;
}
clear() {
this.texArray.clear();
this.styleArray.clear();
this.settings = null;
this.data = null;
this.shader = null;
}
begin(settings, shader) {
this.TICK = ++BaseTexture._globalBatch;
this.settings = settings;
this.shader = shader;
this.start = 0;
this.size = 0;
this.data = null;
if (shader && shader.settings) {
this.settings = shader.settings;
}
}
check(shader) {
if (this.size === 0) {
this.shader = shader;
return true;
}
return this.shader === shader;
}
add(texture, matrix, lineWidth, lineAlignment, lineScaleMode) {
const { texArray, TICK, styleArray, settings } = this;
const { baseTexture } = texture;
if (baseTexture._batchEnabled !== TICK && texArray.count === settings.maxTextures) {
return -1;
}
const loc = baseTexture._batchEnabled !== TICK ? texArray.count : baseTexture._batchLocation;
const res = styleArray.add(
loc,
matrix || Matrix.IDENTITY,
lineWidth,
lineAlignment,
lineScaleMode,
settings
);
if (res >= 0) {
if (baseTexture._batchEnabled !== TICK) {
baseTexture._batchEnabled = TICK;
baseTexture._batchLocation = texArray.count;
texArray.elements[texArray.count++] = baseTexture;
}
}
return res;
}
}
export { BatchDrawCall, BatchStyleArray, matrixEquals };
//# sourceMappingURL=BatchDrawCall.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,31 @@
'use strict';
class BatchPart {
constructor() {
this.reset();
}
begin(style, startIndex, attribStart) {
this.reset();
this.style = style;
this.start = startIndex;
this.attribStart = attribStart;
this.jointEnd = 0;
}
end(endIndex, endAttrib) {
this.attribSize = endAttrib - this.attribStart;
this.size = endIndex - this.start;
}
reset() {
this.style = null;
this.size = 0;
this.start = 0;
this.attribStart = 0;
this.attribSize = 0;
this.styleId = -1;
this.rgba = 0;
this.jointEnd = 0;
}
}
exports.BatchPart = BatchPart;
//# sourceMappingURL=BatchPart.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BatchPart.js","sources":["../../src/core/BatchPart.ts"],"sourcesContent":["import { LineStyle } from './LineStyle';\r\nimport { FillStyle } from './FillStyle';\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class BatchPart\r\n{\r\n public style: LineStyle | FillStyle;\r\n public start: number;\r\n public size: number;\r\n public jointEnd: number;\r\n public attribStart: number;\r\n public attribSize: number;\r\n public styleId: number;\r\n public rgba: number;\r\n\r\n constructor()\r\n {\r\n this.reset();\r\n }\r\n\r\n public begin(style: LineStyle | FillStyle, startIndex: number, attribStart: number): void\r\n {\r\n this.reset();\r\n this.style = style;\r\n this.start = startIndex;\r\n this.attribStart = attribStart;\r\n this.jointEnd = 0;\r\n }\r\n\r\n public end(endIndex: number, endAttrib: number): void\r\n {\r\n this.attribSize = endAttrib - this.attribStart;\r\n this.size = endIndex - this.start;\r\n }\r\n\r\n public reset(): void\r\n {\r\n this.style = null;\r\n this.size = 0;\r\n this.start = 0;\r\n this.attribStart = 0;\r\n this.attribSize = 0;\r\n this.styleId = -1;\r\n this.rgba = 0;\r\n this.jointEnd = 0;\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAMO,MAAM,SACb,CAAA;AAAA,EAUI,WACA,GAAA;AACI,IAAA,IAAA,CAAK,KAAM,EAAA,CAAA;AAAA,GACf;AAAA,EAEO,KAAA,CAAM,KAA8B,EAAA,UAAA,EAAoB,WAC/D,EAAA;AACI,IAAA,IAAA,CAAK,KAAM,EAAA,CAAA;AACX,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,IAAA,CAAK,KAAQ,GAAA,UAAA,CAAA;AACb,IAAA,IAAA,CAAK,WAAc,GAAA,WAAA,CAAA;AACnB,IAAA,IAAA,CAAK,QAAW,GAAA,CAAA,CAAA;AAAA,GACpB;AAAA,EAEO,GAAA,CAAI,UAAkB,SAC7B,EAAA;AACI,IAAK,IAAA,CAAA,UAAA,GAAa,YAAY,IAAK,CAAA,WAAA,CAAA;AACnC,IAAK,IAAA,CAAA,IAAA,GAAO,WAAW,IAAK,CAAA,KAAA,CAAA;AAAA,GAChC;AAAA,EAEO,KACP,GAAA;AACI,IAAA,IAAA,CAAK,KAAQ,GAAA,IAAA,CAAA;AACb,IAAA,IAAA,CAAK,IAAO,GAAA,CAAA,CAAA;AACZ,IAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,CAAA;AACb,IAAA,IAAA,CAAK,WAAc,GAAA,CAAA,CAAA;AACnB,IAAA,IAAA,CAAK,UAAa,GAAA,CAAA,CAAA;AAClB,IAAA,IAAA,CAAK,OAAU,GAAA,CAAA,CAAA,CAAA;AACf,IAAA,IAAA,CAAK,IAAO,GAAA,CAAA,CAAA;AACZ,IAAA,IAAA,CAAK,QAAW,GAAA,CAAA,CAAA;AAAA,GACpB;AACJ;;;;"}

View File

@@ -0,0 +1,29 @@
class BatchPart {
constructor() {
this.reset();
}
begin(style, startIndex, attribStart) {
this.reset();
this.style = style;
this.start = startIndex;
this.attribStart = attribStart;
this.jointEnd = 0;
}
end(endIndex, endAttrib) {
this.attribSize = endAttrib - this.attribStart;
this.size = endIndex - this.start;
}
reset() {
this.style = null;
this.size = 0;
this.start = 0;
this.attribStart = 0;
this.attribSize = 0;
this.styleId = -1;
this.rgba = 0;
this.jointEnd = 0;
}
}
export { BatchPart };
//# sourceMappingURL=BatchPart.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BatchPart.mjs","sources":["../../src/core/BatchPart.ts"],"sourcesContent":["import { LineStyle } from './LineStyle';\r\nimport { FillStyle } from './FillStyle';\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class BatchPart\r\n{\r\n public style: LineStyle | FillStyle;\r\n public start: number;\r\n public size: number;\r\n public jointEnd: number;\r\n public attribStart: number;\r\n public attribSize: number;\r\n public styleId: number;\r\n public rgba: number;\r\n\r\n constructor()\r\n {\r\n this.reset();\r\n }\r\n\r\n public begin(style: LineStyle | FillStyle, startIndex: number, attribStart: number): void\r\n {\r\n this.reset();\r\n this.style = style;\r\n this.start = startIndex;\r\n this.attribStart = attribStart;\r\n this.jointEnd = 0;\r\n }\r\n\r\n public end(endIndex: number, endAttrib: number): void\r\n {\r\n this.attribSize = endAttrib - this.attribStart;\r\n this.size = endIndex - this.start;\r\n }\r\n\r\n public reset(): void\r\n {\r\n this.style = null;\r\n this.size = 0;\r\n this.start = 0;\r\n this.attribStart = 0;\r\n this.attribSize = 0;\r\n this.styleId = -1;\r\n this.rgba = 0;\r\n this.jointEnd = 0;\r\n }\r\n}\r\n"],"names":[],"mappings":"AAMO,MAAM,SACb,CAAA;AAAA,EAUI,WACA,GAAA;AACI,IAAA,IAAA,CAAK,KAAM,EAAA,CAAA;AAAA,GACf;AAAA,EAEO,KAAA,CAAM,KAA8B,EAAA,UAAA,EAAoB,WAC/D,EAAA;AACI,IAAA,IAAA,CAAK,KAAM,EAAA,CAAA;AACX,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,IAAA,CAAK,KAAQ,GAAA,UAAA,CAAA;AACb,IAAA,IAAA,CAAK,WAAc,GAAA,WAAA,CAAA;AACnB,IAAA,IAAA,CAAK,QAAW,GAAA,CAAA,CAAA;AAAA,GACpB;AAAA,EAEO,GAAA,CAAI,UAAkB,SAC7B,EAAA;AACI,IAAK,IAAA,CAAA,UAAA,GAAa,YAAY,IAAK,CAAA,WAAA,CAAA;AACnC,IAAK,IAAA,CAAA,IAAA,GAAO,WAAW,IAAK,CAAA,KAAA,CAAA;AAAA,GAChC;AAAA,EAEO,KACP,GAAA;AACI,IAAA,IAAA,CAAK,KAAQ,GAAA,IAAA,CAAA;AACb,IAAA,IAAA,CAAK,IAAO,GAAA,CAAA,CAAA;AACZ,IAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,CAAA;AACb,IAAA,IAAA,CAAK,WAAc,GAAA,CAAA,CAAA;AACnB,IAAA,IAAA,CAAK,UAAa,GAAA,CAAA,CAAA;AAClB,IAAA,IAAA,CAAK,OAAU,GAAA,CAAA,CAAA,CAAA;AACf,IAAA,IAAA,CAAK,IAAO,GAAA,CAAA,CAAA;AACZ,IAAA,IAAA,CAAK,QAAW,GAAA,CAAA,CAAA;AAAA,GACpB;AACJ;;;;"}

View File

@@ -0,0 +1,24 @@
'use strict';
class BuildData {
constructor() {
this.verts = [];
this.joints = [];
this.vertexSize = 0;
this.indexSize = 0;
this.closePointEps = 1e-4;
}
clear() {
this.verts.length = 0;
this.joints.length = 0;
this.vertexSize = 0;
this.indexSize = 0;
}
destroy() {
this.verts.length = 0;
this.joints.length = 0;
}
}
exports.BuildData = BuildData;
//# sourceMappingURL=BuildData.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BuildData.js","sources":["../../src/core/BuildData.ts"],"sourcesContent":["/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class BuildData\r\n{\r\n verts: Array<number> = [];\r\n joints: Array<number> = [];\r\n vertexSize = 0;\r\n indexSize = 0;\r\n closePointEps = 1e-4;\r\n\r\n clear()\r\n {\r\n this.verts.length = 0;\r\n this.joints.length = 0;\r\n this.vertexSize = 0;\r\n this.indexSize = 0;\r\n }\r\n\r\n destroy()\r\n {\r\n this.verts.length = 0;\r\n this.joints.length = 0;\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAGO,MAAM,SACb,CAAA;AAAA,EADO,WAAA,GAAA;AAEH,IAAA,IAAA,CAAA,KAAA,GAAuB,EAAC,CAAA;AACxB,IAAA,IAAA,CAAA,MAAA,GAAwB,EAAC,CAAA;AACzB,IAAa,IAAA,CAAA,UAAA,GAAA,CAAA,CAAA;AACb,IAAY,IAAA,CAAA,SAAA,GAAA,CAAA,CAAA;AACZ,IAAgB,IAAA,CAAA,aAAA,GAAA,IAAA,CAAA;AAAA,GAAA;AAAA,EAEhB,KACA,GAAA;AACI,IAAA,IAAA,CAAK,MAAM,MAAS,GAAA,CAAA,CAAA;AACpB,IAAA,IAAA,CAAK,OAAO,MAAS,GAAA,CAAA,CAAA;AACrB,IAAA,IAAA,CAAK,UAAa,GAAA,CAAA,CAAA;AAClB,IAAA,IAAA,CAAK,SAAY,GAAA,CAAA,CAAA;AAAA,GACrB;AAAA,EAEA,OACA,GAAA;AACI,IAAA,IAAA,CAAK,MAAM,MAAS,GAAA,CAAA,CAAA;AACpB,IAAA,IAAA,CAAK,OAAO,MAAS,GAAA,CAAA,CAAA;AAAA,GACzB;AACJ;;;;"}

View File

@@ -0,0 +1,22 @@
class BuildData {
constructor() {
this.verts = [];
this.joints = [];
this.vertexSize = 0;
this.indexSize = 0;
this.closePointEps = 1e-4;
}
clear() {
this.verts.length = 0;
this.joints.length = 0;
this.vertexSize = 0;
this.indexSize = 0;
}
destroy() {
this.verts.length = 0;
this.joints.length = 0;
}
}
export { BuildData };
//# sourceMappingURL=BuildData.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BuildData.mjs","sources":["../../src/core/BuildData.ts"],"sourcesContent":["/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class BuildData\r\n{\r\n verts: Array<number> = [];\r\n joints: Array<number> = [];\r\n vertexSize = 0;\r\n indexSize = 0;\r\n closePointEps = 1e-4;\r\n\r\n clear()\r\n {\r\n this.verts.length = 0;\r\n this.joints.length = 0;\r\n this.vertexSize = 0;\r\n this.indexSize = 0;\r\n }\r\n\r\n destroy()\r\n {\r\n this.verts.length = 0;\r\n this.joints.length = 0;\r\n }\r\n}\r\n"],"names":[],"mappings":"AAGO,MAAM,SACb,CAAA;AAAA,EADO,WAAA,GAAA;AAEH,IAAA,IAAA,CAAA,KAAA,GAAuB,EAAC,CAAA;AACxB,IAAA,IAAA,CAAA,MAAA,GAAwB,EAAC,CAAA;AACzB,IAAa,IAAA,CAAA,UAAA,GAAA,CAAA,CAAA;AACb,IAAY,IAAA,CAAA,SAAA,GAAA,CAAA,CAAA;AACZ,IAAgB,IAAA,CAAA,aAAA,GAAA,IAAA,CAAA;AAAA,GAAA;AAAA,EAEhB,KACA,GAAA;AACI,IAAA,IAAA,CAAK,MAAM,MAAS,GAAA,CAAA,CAAA;AACpB,IAAA,IAAA,CAAK,OAAO,MAAS,GAAA,CAAA,CAAA;AACrB,IAAA,IAAA,CAAK,UAAa,GAAA,CAAA,CAAA;AAClB,IAAA,IAAA,CAAK,SAAY,GAAA,CAAA,CAAA;AAAA,GACrB;AAAA,EAEA,OACA,GAAA;AACI,IAAA,IAAA,CAAK,MAAM,MAAS,GAAA,CAAA,CAAA;AACpB,IAAA,IAAA,CAAK,OAAO,MAAS,GAAA,CAAA,CAAA;AAAA,GACzB;AACJ;;;;"}

View File

@@ -0,0 +1,63 @@
'use strict';
var core = require('@pixi/core');
class FillStyle {
constructor() {
this.reset();
}
toJSON() {
return this.copyTo({});
}
clone() {
return this.copyTo(new FillStyle());
}
copyTo(obj) {
obj.color = this.color;
obj.alpha = this.alpha;
obj.texture = this.texture;
obj.matrix = this.matrix;
obj.shader = this.shader;
obj.visible = this.visible;
obj.smooth = this.smooth;
obj.matrixTex = null;
return obj;
}
packLineScale() {
return 0;
}
reset() {
this.color = 16777215;
this.alpha = 1;
this.texture = core.Texture.WHITE;
this.matrix = null;
this.shader = null;
this.visible = false;
this.smooth = false;
this.matrixTex = null;
}
destroy() {
this.texture = null;
this.matrix = null;
this.matrixTex = null;
}
getTextureMatrix() {
const tex = this.texture;
if (!this.matrix) {
return null;
}
if (tex.frame.width === tex.baseTexture.width && tex.frame.height === tex.baseTexture.height) {
return this.matrix;
}
if (!this.matrixTex) {
this.matrixTex = this.matrix.clone();
} else {
this.matrixTex.copyFrom(this.matrix);
}
this.matrixTex.translate(Number(tex.frame.x), Number(tex.frame.y));
return this.matrixTex;
}
}
exports.FillStyle = FillStyle;
//# sourceMappingURL=FillStyle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FillStyle.js","sources":["../../src/core/FillStyle.ts"],"sourcesContent":["import { Shader, Texture } from '@pixi/core';\r\nimport type { Matrix } from '@pixi/core';\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class FillStyle\r\n{\r\n constructor()\r\n {\r\n this.reset();\r\n }\r\n\r\n color: number;\r\n alpha: number;\r\n texture: Texture;\r\n matrix: Matrix;\r\n matrixTex: Matrix;\r\n shader: Shader;\r\n visible: boolean;\r\n smooth: boolean;\r\n\r\n toJSON()\r\n {\r\n return this.copyTo({});\r\n }\r\n\r\n clone(): FillStyle\r\n {\r\n return this.copyTo(new FillStyle());\r\n }\r\n\r\n copyTo(obj: any): any\r\n {\r\n obj.color = this.color;\r\n obj.alpha = this.alpha;\r\n obj.texture = this.texture;\r\n obj.matrix = this.matrix;\r\n obj.shader = this.shader;\r\n obj.visible = this.visible;\r\n obj.smooth = this.smooth;\r\n obj.matrixTex = null;\r\n\r\n return obj;\r\n }\r\n\r\n packLineScale()\r\n {\r\n return 0;\r\n }\r\n\r\n reset()\r\n {\r\n this.color = 0xFFFFFF;\r\n\r\n this.alpha = 1;\r\n\r\n this.texture = Texture.WHITE;\r\n\r\n this.matrix = null;\r\n\r\n this.shader = null;\r\n\r\n this.visible = false;\r\n\r\n this.smooth = false;\r\n\r\n this.matrixTex = null;\r\n }\r\n\r\n destroy()\r\n {\r\n this.texture = null;\r\n this.matrix = null;\r\n this.matrixTex = null;\r\n }\r\n\r\n getTextureMatrix()\r\n {\r\n const tex = this.texture;\r\n\r\n if (!this.matrix)\r\n {\r\n return null;\r\n }\r\n\r\n if (tex.frame.width === tex.baseTexture.width\r\n && tex.frame.height === tex.baseTexture.height)\r\n {\r\n return this.matrix;\r\n }\r\n\r\n if (!this.matrixTex)\r\n {\r\n this.matrixTex = this.matrix.clone();\r\n }\r\n else\r\n {\r\n this.matrixTex.copyFrom(this.matrix);\r\n }\r\n this.matrixTex.translate(Number(tex.frame.x), Number(tex.frame.y));\r\n\r\n return this.matrixTex;\r\n }\r\n}\r\n"],"names":["Texture"],"mappings":";;;;AAMO,MAAM,SACb,CAAA;AAAA,EACI,WACA,GAAA;AACI,IAAA,IAAA,CAAK,KAAM,EAAA,CAAA;AAAA,GACf;AAAA,EAWA,MACA,GAAA;AACI,IAAO,OAAA,IAAA,CAAK,MAAO,CAAA,EAAE,CAAA,CAAA;AAAA,GACzB;AAAA,EAEA,KACA,GAAA;AACI,IAAA,OAAO,IAAK,CAAA,MAAA,CAAO,IAAI,SAAA,EAAW,CAAA,CAAA;AAAA,GACtC;AAAA,EAEA,OAAO,GACP,EAAA;AACI,IAAA,GAAA,CAAI,QAAQ,IAAK,CAAA,KAAA,CAAA;AACjB,IAAA,GAAA,CAAI,QAAQ,IAAK,CAAA,KAAA,CAAA;AACjB,IAAA,GAAA,CAAI,UAAU,IAAK,CAAA,OAAA,CAAA;AACnB,IAAA,GAAA,CAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAClB,IAAA,GAAA,CAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAClB,IAAA,GAAA,CAAI,UAAU,IAAK,CAAA,OAAA,CAAA;AACnB,IAAA,GAAA,CAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAClB,IAAA,GAAA,CAAI,SAAY,GAAA,IAAA,CAAA;AAEhB,IAAO,OAAA,GAAA,CAAA;AAAA,GACX;AAAA,EAEA,aACA,GAAA;AACI,IAAO,OAAA,CAAA,CAAA;AAAA,GACX;AAAA,EAEA,KACA,GAAA;AACI,IAAA,IAAA,CAAK,KAAQ,GAAA,QAAA,CAAA;AAEb,IAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,CAAA;AAEb,IAAA,IAAA,CAAK,UAAUA,YAAQ,CAAA,KAAA,CAAA;AAEvB,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AAEd,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AAEd,IAAA,IAAA,CAAK,OAAU,GAAA,KAAA,CAAA;AAEf,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA,CAAA;AAEd,IAAA,IAAA,CAAK,SAAY,GAAA,IAAA,CAAA;AAAA,GACrB;AAAA,EAEA,OACA,GAAA;AACI,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAA;AACf,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AACd,IAAA,IAAA,CAAK,SAAY,GAAA,IAAA,CAAA;AAAA,GACrB;AAAA,EAEA,gBACA,GAAA;AACI,IAAA,MAAM,MAAM,IAAK,CAAA,OAAA,CAAA;AAEjB,IAAI,IAAA,CAAC,KAAK,MACV,EAAA;AACI,MAAO,OAAA,IAAA,CAAA;AAAA,KACX;AAEA,IAAI,IAAA,GAAA,CAAI,KAAM,CAAA,KAAA,KAAU,GAAI,CAAA,WAAA,CAAY,KACjC,IAAA,GAAA,CAAI,KAAM,CAAA,MAAA,KAAW,GAAI,CAAA,WAAA,CAAY,MAC5C,EAAA;AACI,MAAA,OAAO,IAAK,CAAA,MAAA,CAAA;AAAA,KAChB;AAEA,IAAI,IAAA,CAAC,KAAK,SACV,EAAA;AACI,MAAK,IAAA,CAAA,SAAA,GAAY,IAAK,CAAA,MAAA,CAAO,KAAM,EAAA,CAAA;AAAA,KAGvC,MAAA;AACI,MAAK,IAAA,CAAA,SAAA,CAAU,QAAS,CAAA,IAAA,CAAK,MAAM,CAAA,CAAA;AAAA,KACvC;AACA,IAAK,IAAA,CAAA,SAAA,CAAU,SAAU,CAAA,MAAA,CAAO,GAAI,CAAA,KAAA,CAAM,CAAC,CAAA,EAAG,MAAO,CAAA,GAAA,CAAI,KAAM,CAAA,CAAC,CAAC,CAAA,CAAA;AAEjE,IAAA,OAAO,IAAK,CAAA,SAAA,CAAA;AAAA,GAChB;AACJ;;;;"}

View File

@@ -0,0 +1,61 @@
import { Texture } from '@pixi/core';
class FillStyle {
constructor() {
this.reset();
}
toJSON() {
return this.copyTo({});
}
clone() {
return this.copyTo(new FillStyle());
}
copyTo(obj) {
obj.color = this.color;
obj.alpha = this.alpha;
obj.texture = this.texture;
obj.matrix = this.matrix;
obj.shader = this.shader;
obj.visible = this.visible;
obj.smooth = this.smooth;
obj.matrixTex = null;
return obj;
}
packLineScale() {
return 0;
}
reset() {
this.color = 16777215;
this.alpha = 1;
this.texture = Texture.WHITE;
this.matrix = null;
this.shader = null;
this.visible = false;
this.smooth = false;
this.matrixTex = null;
}
destroy() {
this.texture = null;
this.matrix = null;
this.matrixTex = null;
}
getTextureMatrix() {
const tex = this.texture;
if (!this.matrix) {
return null;
}
if (tex.frame.width === tex.baseTexture.width && tex.frame.height === tex.baseTexture.height) {
return this.matrix;
}
if (!this.matrixTex) {
this.matrixTex = this.matrix.clone();
} else {
this.matrixTex.copyFrom(this.matrix);
}
this.matrixTex.translate(Number(tex.frame.x), Number(tex.frame.y));
return this.matrixTex;
}
}
export { FillStyle };
//# sourceMappingURL=FillStyle.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"FillStyle.mjs","sources":["../../src/core/FillStyle.ts"],"sourcesContent":["import { Shader, Texture } from '@pixi/core';\r\nimport type { Matrix } from '@pixi/core';\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class FillStyle\r\n{\r\n constructor()\r\n {\r\n this.reset();\r\n }\r\n\r\n color: number;\r\n alpha: number;\r\n texture: Texture;\r\n matrix: Matrix;\r\n matrixTex: Matrix;\r\n shader: Shader;\r\n visible: boolean;\r\n smooth: boolean;\r\n\r\n toJSON()\r\n {\r\n return this.copyTo({});\r\n }\r\n\r\n clone(): FillStyle\r\n {\r\n return this.copyTo(new FillStyle());\r\n }\r\n\r\n copyTo(obj: any): any\r\n {\r\n obj.color = this.color;\r\n obj.alpha = this.alpha;\r\n obj.texture = this.texture;\r\n obj.matrix = this.matrix;\r\n obj.shader = this.shader;\r\n obj.visible = this.visible;\r\n obj.smooth = this.smooth;\r\n obj.matrixTex = null;\r\n\r\n return obj;\r\n }\r\n\r\n packLineScale()\r\n {\r\n return 0;\r\n }\r\n\r\n reset()\r\n {\r\n this.color = 0xFFFFFF;\r\n\r\n this.alpha = 1;\r\n\r\n this.texture = Texture.WHITE;\r\n\r\n this.matrix = null;\r\n\r\n this.shader = null;\r\n\r\n this.visible = false;\r\n\r\n this.smooth = false;\r\n\r\n this.matrixTex = null;\r\n }\r\n\r\n destroy()\r\n {\r\n this.texture = null;\r\n this.matrix = null;\r\n this.matrixTex = null;\r\n }\r\n\r\n getTextureMatrix()\r\n {\r\n const tex = this.texture;\r\n\r\n if (!this.matrix)\r\n {\r\n return null;\r\n }\r\n\r\n if (tex.frame.width === tex.baseTexture.width\r\n && tex.frame.height === tex.baseTexture.height)\r\n {\r\n return this.matrix;\r\n }\r\n\r\n if (!this.matrixTex)\r\n {\r\n this.matrixTex = this.matrix.clone();\r\n }\r\n else\r\n {\r\n this.matrixTex.copyFrom(this.matrix);\r\n }\r\n this.matrixTex.translate(Number(tex.frame.x), Number(tex.frame.y));\r\n\r\n return this.matrixTex;\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAMO,MAAM,SACb,CAAA;AAAA,EACI,WACA,GAAA;AACI,IAAA,IAAA,CAAK,KAAM,EAAA,CAAA;AAAA,GACf;AAAA,EAWA,MACA,GAAA;AACI,IAAO,OAAA,IAAA,CAAK,MAAO,CAAA,EAAE,CAAA,CAAA;AAAA,GACzB;AAAA,EAEA,KACA,GAAA;AACI,IAAA,OAAO,IAAK,CAAA,MAAA,CAAO,IAAI,SAAA,EAAW,CAAA,CAAA;AAAA,GACtC;AAAA,EAEA,OAAO,GACP,EAAA;AACI,IAAA,GAAA,CAAI,QAAQ,IAAK,CAAA,KAAA,CAAA;AACjB,IAAA,GAAA,CAAI,QAAQ,IAAK,CAAA,KAAA,CAAA;AACjB,IAAA,GAAA,CAAI,UAAU,IAAK,CAAA,OAAA,CAAA;AACnB,IAAA,GAAA,CAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAClB,IAAA,GAAA,CAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAClB,IAAA,GAAA,CAAI,UAAU,IAAK,CAAA,OAAA,CAAA;AACnB,IAAA,GAAA,CAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAClB,IAAA,GAAA,CAAI,SAAY,GAAA,IAAA,CAAA;AAEhB,IAAO,OAAA,GAAA,CAAA;AAAA,GACX;AAAA,EAEA,aACA,GAAA;AACI,IAAO,OAAA,CAAA,CAAA;AAAA,GACX;AAAA,EAEA,KACA,GAAA;AACI,IAAA,IAAA,CAAK,KAAQ,GAAA,QAAA,CAAA;AAEb,IAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,CAAA;AAEb,IAAA,IAAA,CAAK,UAAU,OAAQ,CAAA,KAAA,CAAA;AAEvB,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AAEd,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AAEd,IAAA,IAAA,CAAK,OAAU,GAAA,KAAA,CAAA;AAEf,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA,CAAA;AAEd,IAAA,IAAA,CAAK,SAAY,GAAA,IAAA,CAAA;AAAA,GACrB;AAAA,EAEA,OACA,GAAA;AACI,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAA;AACf,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AACd,IAAA,IAAA,CAAK,SAAY,GAAA,IAAA,CAAA;AAAA,GACrB;AAAA,EAEA,gBACA,GAAA;AACI,IAAA,MAAM,MAAM,IAAK,CAAA,OAAA,CAAA;AAEjB,IAAI,IAAA,CAAC,KAAK,MACV,EAAA;AACI,MAAO,OAAA,IAAA,CAAA;AAAA,KACX;AAEA,IAAI,IAAA,GAAA,CAAI,KAAM,CAAA,KAAA,KAAU,GAAI,CAAA,WAAA,CAAY,KACjC,IAAA,GAAA,CAAI,KAAM,CAAA,MAAA,KAAW,GAAI,CAAA,WAAA,CAAY,MAC5C,EAAA;AACI,MAAA,OAAO,IAAK,CAAA,MAAA,CAAA;AAAA,KAChB;AAEA,IAAI,IAAA,CAAC,KAAK,SACV,EAAA;AACI,MAAK,IAAA,CAAA,SAAA,GAAY,IAAK,CAAA,MAAA,CAAO,KAAM,EAAA,CAAA;AAAA,KAGvC,MAAA;AACI,MAAK,IAAA,CAAA,SAAA,CAAU,QAAS,CAAA,IAAA,CAAK,MAAM,CAAA,CAAA;AAAA,KACvC;AACA,IAAK,IAAA,CAAA,SAAA,CAAU,SAAU,CAAA,MAAA,CAAO,GAAI,CAAA,KAAA,CAAM,CAAC,CAAA,EAAG,MAAO,CAAA,GAAA,CAAI,KAAM,CAAA,CAAC,CAAC,CAAA,CAAA;AAEjE,IAAA,OAAO,IAAK,CAAA,SAAA,CAAA;AAAA,GAChB;AACJ;;;;"}

View File

@@ -0,0 +1,63 @@
'use strict';
var graphics = require('@pixi/graphics');
var FillStyle = require('./FillStyle.js');
var LINE_SCALE_MODE = /* @__PURE__ */ ((LINE_SCALE_MODE2) => {
LINE_SCALE_MODE2["NONE"] = "none";
LINE_SCALE_MODE2["NORMAL"] = "normal";
LINE_SCALE_MODE2["HORIZONTAL"] = "horizontal";
LINE_SCALE_MODE2["VERTICAL"] = "vertical";
return LINE_SCALE_MODE2;
})(LINE_SCALE_MODE || {});
class LineStyle extends FillStyle.FillStyle {
clone() {
return this.copyTo(new LineStyle());
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
copyTo(obj) {
obj.color = this.color;
obj.alpha = this.alpha;
obj.texture = this.texture;
obj.matrix = this.matrix;
obj.shader = this.shader;
obj.visible = this.visible;
obj.width = this.width;
obj.alignment = this.alignment;
obj.cap = this.cap;
obj.join = this.join;
obj.miterLimit = this.miterLimit;
obj.scaleMode = this.scaleMode;
return obj;
}
/**
* returns width multiplied by scaleMode
*/
packLineScale() {
switch (this.scaleMode) {
case "normal" /* NORMAL */:
return 1;
case "horizontal" /* HORIZONTAL */:
return 2;
case "vertical" /* VERTICAL */:
return 3;
default:
return 0;
}
}
reset() {
super.reset();
this.smooth = true;
this.color = 0;
this.width = 0;
this.alignment = 0.5;
this.cap = graphics.LINE_CAP.BUTT;
this.join = graphics.LINE_JOIN.MITER;
this.miterLimit = 10;
this.scaleMode = "normal" /* NORMAL */;
}
}
exports.LINE_SCALE_MODE = LINE_SCALE_MODE;
exports.LineStyle = LineStyle;
//# sourceMappingURL=LineStyle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LineStyle.js","sources":["../../src/core/LineStyle.ts"],"sourcesContent":["import { LINE_CAP, LINE_JOIN } from '@pixi/graphics';\r\nimport { FillStyle } from './FillStyle';\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport enum LINE_SCALE_MODE\r\n {\r\n NONE = 'none',\r\n NORMAL = 'normal',\r\n HORIZONTAL = 'horizontal',\r\n VERTICAL = 'vertical',\r\n}\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class LineStyle extends FillStyle\r\n{\r\n width: number;\r\n alignment: number;\r\n\r\n cap: LINE_CAP;\r\n join: LINE_JOIN;\r\n miterLimit: number;\r\n scaleMode: LINE_SCALE_MODE;\r\n\r\n clone(): LineStyle\r\n {\r\n return this.copyTo(new LineStyle());\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\r\n copyTo(obj: any): LineStyle\r\n {\r\n obj.color = this.color;\r\n obj.alpha = this.alpha;\r\n obj.texture = this.texture;\r\n obj.matrix = this.matrix;\r\n obj.shader = this.shader;\r\n obj.visible = this.visible;\r\n obj.width = this.width;\r\n obj.alignment = this.alignment;\r\n obj.cap = this.cap;\r\n obj.join = this.join;\r\n obj.miterLimit = this.miterLimit;\r\n obj.scaleMode = this.scaleMode;\r\n\r\n return obj;\r\n }\r\n\r\n /**\r\n * returns width multiplied by scaleMode\r\n */\r\n packLineScale(): number\r\n {\r\n switch (this.scaleMode)\r\n {\r\n case LINE_SCALE_MODE.NORMAL: return 1;\r\n case LINE_SCALE_MODE.HORIZONTAL: return 2;\r\n case LINE_SCALE_MODE.VERTICAL: return 3;\r\n default: return 0;\r\n }\r\n }\r\n\r\n reset(): void\r\n {\r\n super.reset();\r\n\r\n this.smooth = true;\r\n\r\n this.color = 0x0;\r\n\r\n this.width = 0;\r\n\r\n this.alignment = 0.5;\r\n\r\n this.cap = LINE_CAP.BUTT;\r\n this.join = LINE_JOIN.MITER;\r\n this.miterLimit = 10;\r\n this.scaleMode = LINE_SCALE_MODE.NORMAL;\r\n }\r\n}\r\n"],"names":["LINE_SCALE_MODE","FillStyle","LINE_CAP","LINE_JOIN"],"mappings":";;;;;AAMY,IAAA,eAAA,qBAAAA,gBAAL,KAAA;AAEH,EAAAA,iBAAA,MAAO,CAAA,GAAA,MAAA,CAAA;AACP,EAAAA,iBAAA,QAAS,CAAA,GAAA,QAAA,CAAA;AACT,EAAAA,iBAAA,YAAa,CAAA,GAAA,YAAA,CAAA;AACb,EAAAA,iBAAA,UAAW,CAAA,GAAA,UAAA,CAAA;AALH,EAAAA,OAAAA,gBAAAA,CAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA,EAAA;AAWL,MAAM,kBAAkBC,mBAC/B,CAAA;AAAA,EASI,KACA,GAAA;AACI,IAAA,OAAO,IAAK,CAAA,MAAA,CAAO,IAAI,SAAA,EAAW,CAAA,CAAA;AAAA,GACtC;AAAA;AAAA,EAGA,OAAO,GACP,EAAA;AACI,IAAA,GAAA,CAAI,QAAQ,IAAK,CAAA,KAAA,CAAA;AACjB,IAAA,GAAA,CAAI,QAAQ,IAAK,CAAA,KAAA,CAAA;AACjB,IAAA,GAAA,CAAI,UAAU,IAAK,CAAA,OAAA,CAAA;AACnB,IAAA,GAAA,CAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAClB,IAAA,GAAA,CAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAClB,IAAA,GAAA,CAAI,UAAU,IAAK,CAAA,OAAA,CAAA;AACnB,IAAA,GAAA,CAAI,QAAQ,IAAK,CAAA,KAAA,CAAA;AACjB,IAAA,GAAA,CAAI,YAAY,IAAK,CAAA,SAAA,CAAA;AACrB,IAAA,GAAA,CAAI,MAAM,IAAK,CAAA,GAAA,CAAA;AACf,IAAA,GAAA,CAAI,OAAO,IAAK,CAAA,IAAA,CAAA;AAChB,IAAA,GAAA,CAAI,aAAa,IAAK,CAAA,UAAA,CAAA;AACtB,IAAA,GAAA,CAAI,YAAY,IAAK,CAAA,SAAA,CAAA;AAErB,IAAO,OAAA,GAAA,CAAA;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAKA,aACA,GAAA;AACI,IAAA,QAAQ,KAAK,SACb;AAAA,MACI,KAAK,QAAA;AAAwB,QAAO,OAAA,CAAA,CAAA;AAAA,MACpC,KAAK,YAAA;AAA4B,QAAO,OAAA,CAAA,CAAA;AAAA,MACxC,KAAK,UAAA;AAA0B,QAAO,OAAA,CAAA,CAAA;AAAA,MACtC;AAAS,QAAO,OAAA,CAAA,CAAA;AAAA,KACpB;AAAA,GACJ;AAAA,EAEA,KACA,GAAA;AACI,IAAA,KAAA,CAAM,KAAM,EAAA,CAAA;AAEZ,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AAEd,IAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,CAAA;AAEb,IAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,CAAA;AAEb,IAAA,IAAA,CAAK,SAAY,GAAA,GAAA,CAAA;AAEjB,IAAA,IAAA,CAAK,MAAMC,iBAAS,CAAA,IAAA,CAAA;AACpB,IAAA,IAAA,CAAK,OAAOC,kBAAU,CAAA,KAAA,CAAA;AACtB,IAAA,IAAA,CAAK,UAAa,GAAA,EAAA,CAAA;AAClB,IAAA,IAAA,CAAK,SAAY,GAAA,QAAA,cAAA;AAAA,GACrB;AACJ;;;;;"}

View File

@@ -0,0 +1,60 @@
import { LINE_CAP, LINE_JOIN } from '@pixi/graphics';
import { FillStyle } from './FillStyle.mjs';
var LINE_SCALE_MODE = /* @__PURE__ */ ((LINE_SCALE_MODE2) => {
LINE_SCALE_MODE2["NONE"] = "none";
LINE_SCALE_MODE2["NORMAL"] = "normal";
LINE_SCALE_MODE2["HORIZONTAL"] = "horizontal";
LINE_SCALE_MODE2["VERTICAL"] = "vertical";
return LINE_SCALE_MODE2;
})(LINE_SCALE_MODE || {});
class LineStyle extends FillStyle {
clone() {
return this.copyTo(new LineStyle());
}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
copyTo(obj) {
obj.color = this.color;
obj.alpha = this.alpha;
obj.texture = this.texture;
obj.matrix = this.matrix;
obj.shader = this.shader;
obj.visible = this.visible;
obj.width = this.width;
obj.alignment = this.alignment;
obj.cap = this.cap;
obj.join = this.join;
obj.miterLimit = this.miterLimit;
obj.scaleMode = this.scaleMode;
return obj;
}
/**
* returns width multiplied by scaleMode
*/
packLineScale() {
switch (this.scaleMode) {
case "normal" /* NORMAL */:
return 1;
case "horizontal" /* HORIZONTAL */:
return 2;
case "vertical" /* VERTICAL */:
return 3;
default:
return 0;
}
}
reset() {
super.reset();
this.smooth = true;
this.color = 0;
this.width = 0;
this.alignment = 0.5;
this.cap = LINE_CAP.BUTT;
this.join = LINE_JOIN.MITER;
this.miterLimit = 10;
this.scaleMode = "normal" /* NORMAL */;
}
}
export { LINE_SCALE_MODE, LineStyle };
//# sourceMappingURL=LineStyle.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LineStyle.mjs","sources":["../../src/core/LineStyle.ts"],"sourcesContent":["import { LINE_CAP, LINE_JOIN } from '@pixi/graphics';\r\nimport { FillStyle } from './FillStyle';\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport enum LINE_SCALE_MODE\r\n {\r\n NONE = 'none',\r\n NORMAL = 'normal',\r\n HORIZONTAL = 'horizontal',\r\n VERTICAL = 'vertical',\r\n}\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class LineStyle extends FillStyle\r\n{\r\n width: number;\r\n alignment: number;\r\n\r\n cap: LINE_CAP;\r\n join: LINE_JOIN;\r\n miterLimit: number;\r\n scaleMode: LINE_SCALE_MODE;\r\n\r\n clone(): LineStyle\r\n {\r\n return this.copyTo(new LineStyle());\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\r\n copyTo(obj: any): LineStyle\r\n {\r\n obj.color = this.color;\r\n obj.alpha = this.alpha;\r\n obj.texture = this.texture;\r\n obj.matrix = this.matrix;\r\n obj.shader = this.shader;\r\n obj.visible = this.visible;\r\n obj.width = this.width;\r\n obj.alignment = this.alignment;\r\n obj.cap = this.cap;\r\n obj.join = this.join;\r\n obj.miterLimit = this.miterLimit;\r\n obj.scaleMode = this.scaleMode;\r\n\r\n return obj;\r\n }\r\n\r\n /**\r\n * returns width multiplied by scaleMode\r\n */\r\n packLineScale(): number\r\n {\r\n switch (this.scaleMode)\r\n {\r\n case LINE_SCALE_MODE.NORMAL: return 1;\r\n case LINE_SCALE_MODE.HORIZONTAL: return 2;\r\n case LINE_SCALE_MODE.VERTICAL: return 3;\r\n default: return 0;\r\n }\r\n }\r\n\r\n reset(): void\r\n {\r\n super.reset();\r\n\r\n this.smooth = true;\r\n\r\n this.color = 0x0;\r\n\r\n this.width = 0;\r\n\r\n this.alignment = 0.5;\r\n\r\n this.cap = LINE_CAP.BUTT;\r\n this.join = LINE_JOIN.MITER;\r\n this.miterLimit = 10;\r\n this.scaleMode = LINE_SCALE_MODE.NORMAL;\r\n }\r\n}\r\n"],"names":["LINE_SCALE_MODE"],"mappings":";;;AAMY,IAAA,eAAA,qBAAAA,gBAAL,KAAA;AAEH,EAAAA,iBAAA,MAAO,CAAA,GAAA,MAAA,CAAA;AACP,EAAAA,iBAAA,QAAS,CAAA,GAAA,QAAA,CAAA;AACT,EAAAA,iBAAA,YAAa,CAAA,GAAA,YAAA,CAAA;AACb,EAAAA,iBAAA,UAAW,CAAA,GAAA,UAAA,CAAA;AALH,EAAAA,OAAAA,gBAAAA,CAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA,EAAA;AAWL,MAAM,kBAAkB,SAC/B,CAAA;AAAA,EASI,KACA,GAAA;AACI,IAAA,OAAO,IAAK,CAAA,MAAA,CAAO,IAAI,SAAA,EAAW,CAAA,CAAA;AAAA,GACtC;AAAA;AAAA,EAGA,OAAO,GACP,EAAA;AACI,IAAA,GAAA,CAAI,QAAQ,IAAK,CAAA,KAAA,CAAA;AACjB,IAAA,GAAA,CAAI,QAAQ,IAAK,CAAA,KAAA,CAAA;AACjB,IAAA,GAAA,CAAI,UAAU,IAAK,CAAA,OAAA,CAAA;AACnB,IAAA,GAAA,CAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAClB,IAAA,GAAA,CAAI,SAAS,IAAK,CAAA,MAAA,CAAA;AAClB,IAAA,GAAA,CAAI,UAAU,IAAK,CAAA,OAAA,CAAA;AACnB,IAAA,GAAA,CAAI,QAAQ,IAAK,CAAA,KAAA,CAAA;AACjB,IAAA,GAAA,CAAI,YAAY,IAAK,CAAA,SAAA,CAAA;AACrB,IAAA,GAAA,CAAI,MAAM,IAAK,CAAA,GAAA,CAAA;AACf,IAAA,GAAA,CAAI,OAAO,IAAK,CAAA,IAAA,CAAA;AAChB,IAAA,GAAA,CAAI,aAAa,IAAK,CAAA,UAAA,CAAA;AACtB,IAAA,GAAA,CAAI,YAAY,IAAK,CAAA,SAAA,CAAA;AAErB,IAAO,OAAA,GAAA,CAAA;AAAA,GACX;AAAA;AAAA;AAAA;AAAA,EAKA,aACA,GAAA;AACI,IAAA,QAAQ,KAAK,SACb;AAAA,MACI,KAAK,QAAA;AAAwB,QAAO,OAAA,CAAA,CAAA;AAAA,MACpC,KAAK,YAAA;AAA4B,QAAO,OAAA,CAAA,CAAA;AAAA,MACxC,KAAK,UAAA;AAA0B,QAAO,OAAA,CAAA,CAAA;AAAA,MACtC;AAAS,QAAO,OAAA,CAAA,CAAA;AAAA,KACpB;AAAA,GACJ;AAAA,EAEA,KACA,GAAA;AACI,IAAA,KAAA,CAAM,KAAM,EAAA,CAAA;AAEZ,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AAEd,IAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,CAAA;AAEb,IAAA,IAAA,CAAK,KAAQ,GAAA,CAAA,CAAA;AAEb,IAAA,IAAA,CAAK,SAAY,GAAA,GAAA,CAAA;AAEjB,IAAA,IAAA,CAAK,MAAM,QAAS,CAAA,IAAA,CAAA;AACpB,IAAA,IAAA,CAAK,OAAO,SAAU,CAAA,KAAA,CAAA;AACtB,IAAA,IAAA,CAAK,UAAa,GAAA,EAAA,CAAA;AAClB,IAAA,IAAA,CAAK,SAAY,GAAA,QAAA,cAAA;AAAA,GACrB;AACJ;;;;"}

View File

@@ -0,0 +1,217 @@
'use strict';
var _const = require('./const.js');
const _SegmentPacker = class {
constructor() {
this.strideFloats = 12;
this.bufferPos = 0;
this.indexPos = 0;
}
updateBufferSize(jointStart, jointLen, triangles, target) {
const { joints } = target;
let foundTriangle = false;
let vertexSize = 0;
let indexSize = 0;
for (let i = jointStart; i < jointStart + jointLen; i++) {
const prevCap = joints[i] & ~31;
const joint = joints[i] & 31;
if (joint === _const.JOINT_TYPE.FILL) {
foundTriangle = true;
vertexSize++;
continue;
}
if (joint >= _const.JOINT_TYPE.FILL_EXPAND) {
vertexSize += 3;
indexSize += 3;
continue;
}
const vs = _SegmentPacker.vertsByJoint[joint] + _SegmentPacker.vertsByJoint[prevCap];
if (vs >= 4) {
vertexSize += vs;
indexSize += 6 + 3 * Math.max(vs - 6, 0);
}
}
if (foundTriangle) {
indexSize += triangles;
}
target.vertexSize += vertexSize;
target.indexSize += indexSize;
}
beginPack(buildData, bufFloat, bufUint, indices, bufferPos = 0, indexPos = 0) {
this.buildData = buildData;
this.bufFloat = bufFloat;
this.bufUint = bufUint;
this.indices = indices;
this.bufferPos = bufferPos;
this.indexPos = indexPos;
}
endPack() {
this.buildData = null;
this.bufFloat = null;
this.bufUint = null;
this.indices = null;
}
packInterleavedGeometry(jointStart, jointLen, triangles, lineStyle, color) {
const { bufFloat, bufUint, indices, buildData, strideFloats } = this;
const { joints, verts: verts2 } = buildData;
let bufPos = this.bufferPos;
let indPos = this.indexPos;
let index = this.bufferPos / this.strideFloats;
let x1;
let y1;
let x2;
let y2;
let prevX;
let prevY;
let nextX;
let nextY;
let hasTriangle = false;
let travel = 0;
for (let j = jointStart; j < jointStart + jointLen; j++) {
const fullJoint = joints[j];
const prevCap = joints[j] & ~31;
const joint = joints[j] & 31;
if (joint === _const.JOINT_TYPE.FILL) {
hasTriangle = true;
x1 = verts2[j * 2];
y1 = verts2[j * 2 + 1];
bufFloat[bufPos] = x1;
bufFloat[bufPos + 1] = y1;
bufFloat[bufPos + 2] = x1;
bufFloat[bufPos + 3] = y1;
bufFloat[bufPos + 4] = x1;
bufFloat[bufPos + 5] = y1;
bufFloat[bufPos + 6] = x1;
bufFloat[bufPos + 7] = y1;
bufFloat[bufPos + 8] = travel;
bufFloat[bufPos + 9] = 16 * joint;
bufFloat[bufPos + 10] = lineStyle;
bufUint[bufPos + 11] = color;
bufPos += strideFloats;
continue;
}
if (joint >= _const.JOINT_TYPE.FILL_EXPAND) {
prevX = verts2[j * 2];
prevY = verts2[j * 2 + 1];
x1 = verts2[j * 2 + 2];
y1 = verts2[j * 2 + 3];
x2 = verts2[j * 2 + 4];
y2 = verts2[j * 2 + 5];
const bis = j + 3;
for (let i = 0; i < 3; i++) {
bufFloat[bufPos] = prevX;
bufFloat[bufPos + 1] = prevY;
bufFloat[bufPos + 2] = x1;
bufFloat[bufPos + 3] = y1;
bufFloat[bufPos + 4] = x2;
bufFloat[bufPos + 5] = y2;
bufFloat[bufPos + 6] = verts2[(bis + i) * 2];
bufFloat[bufPos + 7] = verts2[(bis + i) * 2 + 1];
bufFloat[bufPos + 8] = travel;
bufFloat[bufPos + 9] = 16 * fullJoint + i;
bufFloat[bufPos + 10] = lineStyle;
bufUint[bufPos + 11] = color;
bufPos += strideFloats;
}
indices[indPos] = index;
indices[indPos + 1] = index + 1;
indices[indPos + 2] = index + 2;
indPos += 3;
index += 3;
continue;
}
const vs = _SegmentPacker.vertsByJoint[joint] + _SegmentPacker.vertsByJoint[prevCap];
if (vs === 0) {
continue;
}
x1 = verts2[j * 2];
y1 = verts2[j * 2 + 1];
x2 = verts2[j * 2 + 2];
y2 = verts2[j * 2 + 3];
prevX = verts2[j * 2 - 2];
prevY = verts2[j * 2 - 1];
const dist = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
if (_SegmentPacker.vertsByJoint[joint] === 0) {
travel -= dist;
}
if ((joint & ~2) !== _const.JOINT_TYPE.JOINT_CAP_BUTT) {
nextX = verts2[j * 2 + 4];
nextY = verts2[j * 2 + 5];
} else {
nextX = x1;
nextY = y1;
}
for (let i = 0; i < vs; i++) {
bufFloat[bufPos] = prevX;
bufFloat[bufPos + 1] = prevY;
bufFloat[bufPos + 2] = x1;
bufFloat[bufPos + 3] = y1;
bufFloat[bufPos + 4] = x2;
bufFloat[bufPos + 5] = y2;
bufFloat[bufPos + 6] = nextX;
bufFloat[bufPos + 7] = nextY;
bufFloat[bufPos + 8] = travel;
bufFloat[bufPos + 9] = 16 * fullJoint + i;
bufFloat[bufPos + 10] = lineStyle;
bufUint[bufPos + 11] = color;
bufPos += strideFloats;
}
travel += dist;
indices[indPos] = index;
indices[indPos + 1] = index + 1;
indices[indPos + 2] = index + 2;
indices[indPos + 3] = index;
indices[indPos + 4] = index + 2;
indices[indPos + 5] = index + 3;
indPos += 6;
for (let j2 = 5; j2 + 1 < vs; j2++) {
indices[indPos] = index + 4;
indices[indPos + 1] = index + j2;
indices[indPos + 2] = index + j2 + 1;
indPos += 3;
}
index += vs;
}
if (hasTriangle) {
for (let i = 0; i < triangles.length; i++) {
indices[indPos + i] = triangles[i] + index;
}
indPos += triangles.length;
}
this.bufferPos = bufPos;
this.indexPos = indPos;
}
};
let SegmentPacker = _SegmentPacker;
SegmentPacker.vertsByJoint = [];
const verts = SegmentPacker.vertsByJoint;
for (let i = 0; i < 256; i++) {
verts.push(0);
}
verts[_const.JOINT_TYPE.FILL] = 1;
for (let i = 0; i < 8; i++) {
verts[_const.JOINT_TYPE.FILL_EXPAND + i] = 3;
}
verts[_const.JOINT_TYPE.JOINT_BEVEL] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_BEVEL + 1] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_BEVEL + 2] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_BEVEL + 3] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_ROUND] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_ROUND + 1] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_ROUND + 2] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_ROUND + 3] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_MITER] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_MITER + 1] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_MITER + 2] = 4;
verts[_const.JOINT_TYPE.JOINT_MITER + 3] = 4;
verts[_const.JOINT_TYPE.JOINT_CAP_BUTT] = 4;
verts[_const.JOINT_TYPE.JOINT_CAP_BUTT + 1] = 4;
verts[_const.JOINT_TYPE.JOINT_CAP_SQUARE] = 4;
verts[_const.JOINT_TYPE.JOINT_CAP_SQUARE + 1] = 4;
verts[_const.JOINT_TYPE.JOINT_CAP_ROUND] = 4 + 5;
verts[_const.JOINT_TYPE.JOINT_CAP_ROUND + 1] = 4 + 5;
verts[_const.JOINT_TYPE.CAP_ROUND] = 4;
exports.SegmentPacker = SegmentPacker;
//# sourceMappingURL=SegmentPacker.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,215 @@
import { JOINT_TYPE } from './const.mjs';
const _SegmentPacker = class {
constructor() {
this.strideFloats = 12;
this.bufferPos = 0;
this.indexPos = 0;
}
updateBufferSize(jointStart, jointLen, triangles, target) {
const { joints } = target;
let foundTriangle = false;
let vertexSize = 0;
let indexSize = 0;
for (let i = jointStart; i < jointStart + jointLen; i++) {
const prevCap = joints[i] & ~31;
const joint = joints[i] & 31;
if (joint === JOINT_TYPE.FILL) {
foundTriangle = true;
vertexSize++;
continue;
}
if (joint >= JOINT_TYPE.FILL_EXPAND) {
vertexSize += 3;
indexSize += 3;
continue;
}
const vs = _SegmentPacker.vertsByJoint[joint] + _SegmentPacker.vertsByJoint[prevCap];
if (vs >= 4) {
vertexSize += vs;
indexSize += 6 + 3 * Math.max(vs - 6, 0);
}
}
if (foundTriangle) {
indexSize += triangles;
}
target.vertexSize += vertexSize;
target.indexSize += indexSize;
}
beginPack(buildData, bufFloat, bufUint, indices, bufferPos = 0, indexPos = 0) {
this.buildData = buildData;
this.bufFloat = bufFloat;
this.bufUint = bufUint;
this.indices = indices;
this.bufferPos = bufferPos;
this.indexPos = indexPos;
}
endPack() {
this.buildData = null;
this.bufFloat = null;
this.bufUint = null;
this.indices = null;
}
packInterleavedGeometry(jointStart, jointLen, triangles, lineStyle, color) {
const { bufFloat, bufUint, indices, buildData, strideFloats } = this;
const { joints, verts: verts2 } = buildData;
let bufPos = this.bufferPos;
let indPos = this.indexPos;
let index = this.bufferPos / this.strideFloats;
let x1;
let y1;
let x2;
let y2;
let prevX;
let prevY;
let nextX;
let nextY;
let hasTriangle = false;
let travel = 0;
for (let j = jointStart; j < jointStart + jointLen; j++) {
const fullJoint = joints[j];
const prevCap = joints[j] & ~31;
const joint = joints[j] & 31;
if (joint === JOINT_TYPE.FILL) {
hasTriangle = true;
x1 = verts2[j * 2];
y1 = verts2[j * 2 + 1];
bufFloat[bufPos] = x1;
bufFloat[bufPos + 1] = y1;
bufFloat[bufPos + 2] = x1;
bufFloat[bufPos + 3] = y1;
bufFloat[bufPos + 4] = x1;
bufFloat[bufPos + 5] = y1;
bufFloat[bufPos + 6] = x1;
bufFloat[bufPos + 7] = y1;
bufFloat[bufPos + 8] = travel;
bufFloat[bufPos + 9] = 16 * joint;
bufFloat[bufPos + 10] = lineStyle;
bufUint[bufPos + 11] = color;
bufPos += strideFloats;
continue;
}
if (joint >= JOINT_TYPE.FILL_EXPAND) {
prevX = verts2[j * 2];
prevY = verts2[j * 2 + 1];
x1 = verts2[j * 2 + 2];
y1 = verts2[j * 2 + 3];
x2 = verts2[j * 2 + 4];
y2 = verts2[j * 2 + 5];
const bis = j + 3;
for (let i = 0; i < 3; i++) {
bufFloat[bufPos] = prevX;
bufFloat[bufPos + 1] = prevY;
bufFloat[bufPos + 2] = x1;
bufFloat[bufPos + 3] = y1;
bufFloat[bufPos + 4] = x2;
bufFloat[bufPos + 5] = y2;
bufFloat[bufPos + 6] = verts2[(bis + i) * 2];
bufFloat[bufPos + 7] = verts2[(bis + i) * 2 + 1];
bufFloat[bufPos + 8] = travel;
bufFloat[bufPos + 9] = 16 * fullJoint + i;
bufFloat[bufPos + 10] = lineStyle;
bufUint[bufPos + 11] = color;
bufPos += strideFloats;
}
indices[indPos] = index;
indices[indPos + 1] = index + 1;
indices[indPos + 2] = index + 2;
indPos += 3;
index += 3;
continue;
}
const vs = _SegmentPacker.vertsByJoint[joint] + _SegmentPacker.vertsByJoint[prevCap];
if (vs === 0) {
continue;
}
x1 = verts2[j * 2];
y1 = verts2[j * 2 + 1];
x2 = verts2[j * 2 + 2];
y2 = verts2[j * 2 + 3];
prevX = verts2[j * 2 - 2];
prevY = verts2[j * 2 - 1];
const dist = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
if (_SegmentPacker.vertsByJoint[joint] === 0) {
travel -= dist;
}
if ((joint & ~2) !== JOINT_TYPE.JOINT_CAP_BUTT) {
nextX = verts2[j * 2 + 4];
nextY = verts2[j * 2 + 5];
} else {
nextX = x1;
nextY = y1;
}
for (let i = 0; i < vs; i++) {
bufFloat[bufPos] = prevX;
bufFloat[bufPos + 1] = prevY;
bufFloat[bufPos + 2] = x1;
bufFloat[bufPos + 3] = y1;
bufFloat[bufPos + 4] = x2;
bufFloat[bufPos + 5] = y2;
bufFloat[bufPos + 6] = nextX;
bufFloat[bufPos + 7] = nextY;
bufFloat[bufPos + 8] = travel;
bufFloat[bufPos + 9] = 16 * fullJoint + i;
bufFloat[bufPos + 10] = lineStyle;
bufUint[bufPos + 11] = color;
bufPos += strideFloats;
}
travel += dist;
indices[indPos] = index;
indices[indPos + 1] = index + 1;
indices[indPos + 2] = index + 2;
indices[indPos + 3] = index;
indices[indPos + 4] = index + 2;
indices[indPos + 5] = index + 3;
indPos += 6;
for (let j2 = 5; j2 + 1 < vs; j2++) {
indices[indPos] = index + 4;
indices[indPos + 1] = index + j2;
indices[indPos + 2] = index + j2 + 1;
indPos += 3;
}
index += vs;
}
if (hasTriangle) {
for (let i = 0; i < triangles.length; i++) {
indices[indPos + i] = triangles[i] + index;
}
indPos += triangles.length;
}
this.bufferPos = bufPos;
this.indexPos = indPos;
}
};
let SegmentPacker = _SegmentPacker;
SegmentPacker.vertsByJoint = [];
const verts = SegmentPacker.vertsByJoint;
for (let i = 0; i < 256; i++) {
verts.push(0);
}
verts[JOINT_TYPE.FILL] = 1;
for (let i = 0; i < 8; i++) {
verts[JOINT_TYPE.FILL_EXPAND + i] = 3;
}
verts[JOINT_TYPE.JOINT_BEVEL] = 4 + 5;
verts[JOINT_TYPE.JOINT_BEVEL + 1] = 4 + 5;
verts[JOINT_TYPE.JOINT_BEVEL + 2] = 4 + 5;
verts[JOINT_TYPE.JOINT_BEVEL + 3] = 4 + 5;
verts[JOINT_TYPE.JOINT_ROUND] = 4 + 5;
verts[JOINT_TYPE.JOINT_ROUND + 1] = 4 + 5;
verts[JOINT_TYPE.JOINT_ROUND + 2] = 4 + 5;
verts[JOINT_TYPE.JOINT_ROUND + 3] = 4 + 5;
verts[JOINT_TYPE.JOINT_MITER] = 4 + 5;
verts[JOINT_TYPE.JOINT_MITER + 1] = 4 + 5;
verts[JOINT_TYPE.JOINT_MITER + 2] = 4;
verts[JOINT_TYPE.JOINT_MITER + 3] = 4;
verts[JOINT_TYPE.JOINT_CAP_BUTT] = 4;
verts[JOINT_TYPE.JOINT_CAP_BUTT + 1] = 4;
verts[JOINT_TYPE.JOINT_CAP_SQUARE] = 4;
verts[JOINT_TYPE.JOINT_CAP_SQUARE + 1] = 4;
verts[JOINT_TYPE.JOINT_CAP_ROUND] = 4 + 5;
verts[JOINT_TYPE.JOINT_CAP_ROUND + 1] = 4 + 5;
verts[JOINT_TYPE.CAP_ROUND] = 4;
export { SegmentPacker };
//# sourceMappingURL=SegmentPacker.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,97 @@
'use strict';
var graphics = require('@pixi/graphics');
var _const = require('./const.js');
class SmoothGraphicsData {
constructor(shape, fillStyle = null, lineStyle = null, matrix = null) {
this.shape = shape;
this.lineStyle = lineStyle;
this.fillStyle = fillStyle;
this.matrix = matrix;
this.type = shape.type;
this.points = [];
this.holes = [];
this.triangles = [];
this.closeStroke = false;
this.clearBuild();
}
clearPath() {
this.points.length = 0;
this.closeStroke = true;
}
clearBuild() {
this.triangles.length = 0;
this.fillStart = 0;
this.fillLen = 0;
this.strokeStart = 0;
this.strokeLen = 0;
this.fillAA = false;
}
clone() {
return new SmoothGraphicsData(
this.shape,
this.fillStyle,
this.lineStyle,
this.matrix
);
}
capType() {
let cap;
switch (this.lineStyle.cap) {
case graphics.LINE_CAP.SQUARE:
cap = _const.JOINT_TYPE.CAP_SQUARE;
break;
case graphics.LINE_CAP.ROUND:
cap = _const.JOINT_TYPE.CAP_ROUND;
break;
default:
cap = _const.JOINT_TYPE.CAP_BUTT;
break;
}
return cap;
}
goodJointType() {
let joint;
switch (this.lineStyle.join) {
case graphics.LINE_JOIN.BEVEL:
joint = _const.JOINT_TYPE.JOINT_BEVEL;
break;
case graphics.LINE_JOIN.ROUND:
joint = _const.JOINT_TYPE.JOINT_ROUND;
break;
default:
joint = _const.JOINT_TYPE.JOINT_MITER + 3;
break;
}
return joint;
}
jointType() {
let joint;
switch (this.lineStyle.join) {
case graphics.LINE_JOIN.BEVEL:
joint = _const.JOINT_TYPE.JOINT_BEVEL;
break;
case graphics.LINE_JOIN.ROUND:
joint = _const.JOINT_TYPE.JOINT_ROUND;
break;
default:
joint = _const.JOINT_TYPE.JOINT_MITER;
break;
}
return joint;
}
destroy() {
this.shape = null;
this.holes.length = 0;
this.holes = null;
this.points.length = 0;
this.points = null;
this.lineStyle = null;
this.fillStyle = null;
this.triangles = null;
}
}
exports.SmoothGraphicsData = SmoothGraphicsData;
//# sourceMappingURL=SmoothGraphicsData.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,95 @@
import { LINE_CAP, LINE_JOIN } from '@pixi/graphics';
import { JOINT_TYPE } from './const.mjs';
class SmoothGraphicsData {
constructor(shape, fillStyle = null, lineStyle = null, matrix = null) {
this.shape = shape;
this.lineStyle = lineStyle;
this.fillStyle = fillStyle;
this.matrix = matrix;
this.type = shape.type;
this.points = [];
this.holes = [];
this.triangles = [];
this.closeStroke = false;
this.clearBuild();
}
clearPath() {
this.points.length = 0;
this.closeStroke = true;
}
clearBuild() {
this.triangles.length = 0;
this.fillStart = 0;
this.fillLen = 0;
this.strokeStart = 0;
this.strokeLen = 0;
this.fillAA = false;
}
clone() {
return new SmoothGraphicsData(
this.shape,
this.fillStyle,
this.lineStyle,
this.matrix
);
}
capType() {
let cap;
switch (this.lineStyle.cap) {
case LINE_CAP.SQUARE:
cap = JOINT_TYPE.CAP_SQUARE;
break;
case LINE_CAP.ROUND:
cap = JOINT_TYPE.CAP_ROUND;
break;
default:
cap = JOINT_TYPE.CAP_BUTT;
break;
}
return cap;
}
goodJointType() {
let joint;
switch (this.lineStyle.join) {
case LINE_JOIN.BEVEL:
joint = JOINT_TYPE.JOINT_BEVEL;
break;
case LINE_JOIN.ROUND:
joint = JOINT_TYPE.JOINT_ROUND;
break;
default:
joint = JOINT_TYPE.JOINT_MITER + 3;
break;
}
return joint;
}
jointType() {
let joint;
switch (this.lineStyle.join) {
case LINE_JOIN.BEVEL:
joint = JOINT_TYPE.JOINT_BEVEL;
break;
case LINE_JOIN.ROUND:
joint = JOINT_TYPE.JOINT_ROUND;
break;
default:
joint = JOINT_TYPE.JOINT_MITER;
break;
}
return joint;
}
destroy() {
this.shape = null;
this.holes.length = 0;
this.holes = null;
this.points.length = 0;
this.points = null;
this.lineStyle = null;
this.fillStyle = null;
this.triangles = null;
}
}
export { SmoothGraphicsData };
//# sourceMappingURL=SmoothGraphicsData.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
'use strict';
var JOINT_TYPE = /* @__PURE__ */ ((JOINT_TYPE2) => {
JOINT_TYPE2[JOINT_TYPE2["NONE"] = 0] = "NONE";
JOINT_TYPE2[JOINT_TYPE2["FILL"] = 1] = "FILL";
JOINT_TYPE2[JOINT_TYPE2["JOINT_BEVEL"] = 4] = "JOINT_BEVEL";
JOINT_TYPE2[JOINT_TYPE2["JOINT_MITER"] = 8] = "JOINT_MITER";
JOINT_TYPE2[JOINT_TYPE2["JOINT_ROUND"] = 12] = "JOINT_ROUND";
JOINT_TYPE2[JOINT_TYPE2["JOINT_CAP_BUTT"] = 16] = "JOINT_CAP_BUTT";
JOINT_TYPE2[JOINT_TYPE2["JOINT_CAP_SQUARE"] = 18] = "JOINT_CAP_SQUARE";
JOINT_TYPE2[JOINT_TYPE2["JOINT_CAP_ROUND"] = 20] = "JOINT_CAP_ROUND";
JOINT_TYPE2[JOINT_TYPE2["FILL_EXPAND"] = 24] = "FILL_EXPAND";
JOINT_TYPE2[JOINT_TYPE2["CAP_BUTT"] = 32] = "CAP_BUTT";
JOINT_TYPE2[JOINT_TYPE2["CAP_SQUARE"] = 64] = "CAP_SQUARE";
JOINT_TYPE2[JOINT_TYPE2["CAP_ROUND"] = 96] = "CAP_ROUND";
JOINT_TYPE2[JOINT_TYPE2["CAP_BUTT2"] = 128] = "CAP_BUTT2";
return JOINT_TYPE2;
})(JOINT_TYPE || {});
exports.JOINT_TYPE = JOINT_TYPE;
//# sourceMappingURL=const.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"const.js","sources":["../../src/core/const.ts"],"sourcesContent":["export enum JOINT_TYPE\r\n {\r\n NONE = 0,\r\n FILL = 1,\r\n JOINT_BEVEL = 4,\r\n JOINT_MITER = 8,\r\n JOINT_ROUND = 12,\r\n JOINT_CAP_BUTT = 16,\r\n JOINT_CAP_SQUARE = 18,\r\n JOINT_CAP_ROUND = 20,\r\n FILL_EXPAND = 24,\r\n CAP_BUTT = 1 << 5,\r\n CAP_SQUARE = 2 << 5,\r\n CAP_ROUND = 3 << 5,\r\n CAP_BUTT2 = 4 << 5,\r\n}\r\n"],"names":["JOINT_TYPE"],"mappings":";;AAAY,IAAA,UAAA,qBAAAA,WAAL,KAAA;AAEH,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,UAAO,CAAP,CAAA,GAAA,MAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,UAAO,CAAP,CAAA,GAAA,MAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,iBAAc,CAAd,CAAA,GAAA,aAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,iBAAc,CAAd,CAAA,GAAA,aAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,iBAAc,EAAd,CAAA,GAAA,aAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,oBAAiB,EAAjB,CAAA,GAAA,gBAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,sBAAmB,EAAnB,CAAA,GAAA,kBAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,qBAAkB,EAAlB,CAAA,GAAA,iBAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,iBAAc,EAAd,CAAA,GAAA,aAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,cAAW,EAAX,CAAA,GAAA,UAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,gBAAa,EAAb,CAAA,GAAA,YAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,eAAY,EAAZ,CAAA,GAAA,WAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,eAAY,GAAZ,CAAA,GAAA,WAAA,CAAA;AAdQ,EAAAA,OAAAA,WAAAA,CAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;;;;"}

View File

@@ -0,0 +1,19 @@
var JOINT_TYPE = /* @__PURE__ */ ((JOINT_TYPE2) => {
JOINT_TYPE2[JOINT_TYPE2["NONE"] = 0] = "NONE";
JOINT_TYPE2[JOINT_TYPE2["FILL"] = 1] = "FILL";
JOINT_TYPE2[JOINT_TYPE2["JOINT_BEVEL"] = 4] = "JOINT_BEVEL";
JOINT_TYPE2[JOINT_TYPE2["JOINT_MITER"] = 8] = "JOINT_MITER";
JOINT_TYPE2[JOINT_TYPE2["JOINT_ROUND"] = 12] = "JOINT_ROUND";
JOINT_TYPE2[JOINT_TYPE2["JOINT_CAP_BUTT"] = 16] = "JOINT_CAP_BUTT";
JOINT_TYPE2[JOINT_TYPE2["JOINT_CAP_SQUARE"] = 18] = "JOINT_CAP_SQUARE";
JOINT_TYPE2[JOINT_TYPE2["JOINT_CAP_ROUND"] = 20] = "JOINT_CAP_ROUND";
JOINT_TYPE2[JOINT_TYPE2["FILL_EXPAND"] = 24] = "FILL_EXPAND";
JOINT_TYPE2[JOINT_TYPE2["CAP_BUTT"] = 32] = "CAP_BUTT";
JOINT_TYPE2[JOINT_TYPE2["CAP_SQUARE"] = 64] = "CAP_SQUARE";
JOINT_TYPE2[JOINT_TYPE2["CAP_ROUND"] = 96] = "CAP_ROUND";
JOINT_TYPE2[JOINT_TYPE2["CAP_BUTT2"] = 128] = "CAP_BUTT2";
return JOINT_TYPE2;
})(JOINT_TYPE || {});
export { JOINT_TYPE };
//# sourceMappingURL=const.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"const.mjs","sources":["../../src/core/const.ts"],"sourcesContent":["export enum JOINT_TYPE\r\n {\r\n NONE = 0,\r\n FILL = 1,\r\n JOINT_BEVEL = 4,\r\n JOINT_MITER = 8,\r\n JOINT_ROUND = 12,\r\n JOINT_CAP_BUTT = 16,\r\n JOINT_CAP_SQUARE = 18,\r\n JOINT_CAP_ROUND = 20,\r\n FILL_EXPAND = 24,\r\n CAP_BUTT = 1 << 5,\r\n CAP_SQUARE = 2 << 5,\r\n CAP_ROUND = 3 << 5,\r\n CAP_BUTT2 = 4 << 5,\r\n}\r\n"],"names":["JOINT_TYPE"],"mappings":"AAAY,IAAA,UAAA,qBAAAA,WAAL,KAAA;AAEH,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,UAAO,CAAP,CAAA,GAAA,MAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,UAAO,CAAP,CAAA,GAAA,MAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,iBAAc,CAAd,CAAA,GAAA,aAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,iBAAc,CAAd,CAAA,GAAA,aAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,iBAAc,EAAd,CAAA,GAAA,aAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,oBAAiB,EAAjB,CAAA,GAAA,gBAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,sBAAmB,EAAnB,CAAA,GAAA,kBAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,qBAAkB,EAAlB,CAAA,GAAA,iBAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,iBAAc,EAAd,CAAA,GAAA,aAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,cAAW,EAAX,CAAA,GAAA,UAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,gBAAa,EAAb,CAAA,GAAA,YAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,eAAY,EAAZ,CAAA,GAAA,WAAA,CAAA;AACA,EAAAA,WAAAA,CAAAA,WAAAA,CAAA,eAAY,GAAZ,CAAA,GAAA,WAAA,CAAA;AAdQ,EAAAA,OAAAA,WAAAA,CAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;;;;"}

View File

@@ -0,0 +1,47 @@
'use strict';
var BatchDrawCall = require('./core/BatchDrawCall.js');
var BatchPart = require('./core/BatchPart.js');
var LineStyle = require('./core/LineStyle.js');
var FillStyle = require('./core/FillStyle.js');
var BuildData = require('./core/BuildData.js');
var _const = require('./core/const.js');
var SegmentPacker = require('./core/SegmentPacker.js');
var SmoothGraphicsData = require('./core/SmoothGraphicsData.js');
var index = require('./shapes/index.js');
var SmoothGraphicsGeometry = require('./SmoothGraphicsGeometry.js');
var SmoothGraphics = require('./SmoothGraphics.js');
var SmoothShader = require('./SmoothShader.js');
var DashLineShader = require('./DashLineShader.js');
var settings = require('./settings.js');
var CircleBuilder = require('./shapes/CircleBuilder.js');
var RectangleBuilder = require('./shapes/RectangleBuilder.js');
var RoundedRectangleBuilder = require('./shapes/RoundedRectangleBuilder.js');
var PolyBuilder = require('./shapes/PolyBuilder.js');
exports.BatchDrawCall = BatchDrawCall.BatchDrawCall;
exports.BatchStyleArray = BatchDrawCall.BatchStyleArray;
exports.matrixEquals = BatchDrawCall.matrixEquals;
exports.BatchPart = BatchPart.BatchPart;
exports.LINE_SCALE_MODE = LineStyle.LINE_SCALE_MODE;
exports.LineStyle = LineStyle.LineStyle;
exports.FillStyle = FillStyle.FillStyle;
exports.BuildData = BuildData.BuildData;
exports.JOINT_TYPE = _const.JOINT_TYPE;
exports.SegmentPacker = SegmentPacker.SegmentPacker;
exports.SmoothGraphicsData = SmoothGraphicsData.SmoothGraphicsData;
exports.FILL_COMMANDS = index.FILL_COMMANDS;
exports.BATCH_POOL = SmoothGraphicsGeometry.BATCH_POOL;
exports.DRAW_CALL_POOL = SmoothGraphicsGeometry.DRAW_CALL_POOL;
exports.SmoothGraphicsGeometry = SmoothGraphicsGeometry.SmoothGraphicsGeometry;
exports.SmoothGraphics = SmoothGraphics.SmoothGraphics;
exports.SmoothGraphicsShader = SmoothShader.SmoothGraphicsShader;
exports.DashLineShader = DashLineShader.DashLineShader;
exports.settings = settings.settings;
exports.CircleBuilder = CircleBuilder.CircleBuilder;
exports.RectangleBuilder = RectangleBuilder.RectangleBuilder;
exports.RoundedRectangleBuilder = RoundedRectangleBuilder.RoundedRectangleBuilder;
exports.PolyBuilder = PolyBuilder.PolyBuilder;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,19 @@
export { BatchDrawCall, BatchStyleArray, matrixEquals } from './core/BatchDrawCall.mjs';
export { BatchPart } from './core/BatchPart.mjs';
export { LINE_SCALE_MODE, LineStyle } from './core/LineStyle.mjs';
export { FillStyle } from './core/FillStyle.mjs';
export { BuildData } from './core/BuildData.mjs';
export { JOINT_TYPE } from './core/const.mjs';
export { SegmentPacker } from './core/SegmentPacker.mjs';
export { SmoothGraphicsData } from './core/SmoothGraphicsData.mjs';
export { FILL_COMMANDS } from './shapes/index.mjs';
export { BATCH_POOL, DRAW_CALL_POOL, SmoothGraphicsGeometry } from './SmoothGraphicsGeometry.mjs';
export { SmoothGraphics } from './SmoothGraphics.mjs';
export { SmoothGraphicsShader } from './SmoothShader.mjs';
export { DashLineShader } from './DashLineShader.mjs';
export { settings } from './settings.mjs';
export { CircleBuilder } from './shapes/CircleBuilder.mjs';
export { RectangleBuilder } from './shapes/RectangleBuilder.mjs';
export { RoundedRectangleBuilder } from './shapes/RoundedRectangleBuilder.mjs';
export { PolyBuilder } from './shapes/PolyBuilder.mjs';
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,13 @@
'use strict';
var LineStyle = require('./core/LineStyle.js');
const settings = {
LINE_SCALE_MODE: LineStyle.LINE_SCALE_MODE.NORMAL,
SHADER_MAX_STYLES: 24,
SHADER_MAX_TEXTURES: 4,
PIXEL_LINE: 0
};
exports.settings = settings;
//# sourceMappingURL=settings.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"settings.js","sources":["../src/settings.ts"],"sourcesContent":["import { LINE_SCALE_MODE } from './core/LineStyle';\r\n\r\nexport interface ISettings\r\n{\r\n LINE_SCALE_MODE: string;\r\n SHADER_MAX_STYLES: number;\r\n SHADER_MAX_TEXTURES: number;\r\n PIXEL_LINE: number;\r\n}\r\n\r\nexport const settings: ISettings = {\r\n LINE_SCALE_MODE: LINE_SCALE_MODE.NORMAL,\r\n SHADER_MAX_STYLES: 24,\r\n SHADER_MAX_TEXTURES: 4,\r\n PIXEL_LINE: 0,\r\n};\r\n"],"names":["LINE_SCALE_MODE"],"mappings":";;;;AAUO,MAAM,QAAsB,GAAA;AAAA,EAC/B,iBAAiBA,yBAAgB,CAAA,MAAA;AAAA,EACjC,iBAAmB,EAAA,EAAA;AAAA,EACnB,mBAAqB,EAAA,CAAA;AAAA,EACrB,UAAY,EAAA,CAAA;AAChB;;;;"}

View File

@@ -0,0 +1,11 @@
import { LINE_SCALE_MODE } from './core/LineStyle.mjs';
const settings = {
LINE_SCALE_MODE: LINE_SCALE_MODE.NORMAL,
SHADER_MAX_STYLES: 24,
SHADER_MAX_TEXTURES: 4,
PIXEL_LINE: 0
};
export { settings };
//# sourceMappingURL=settings.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"settings.mjs","sources":["../src/settings.ts"],"sourcesContent":["import { LINE_SCALE_MODE } from './core/LineStyle';\r\n\r\nexport interface ISettings\r\n{\r\n LINE_SCALE_MODE: string;\r\n SHADER_MAX_STYLES: number;\r\n SHADER_MAX_TEXTURES: number;\r\n PIXEL_LINE: number;\r\n}\r\n\r\nexport const settings: ISettings = {\r\n LINE_SCALE_MODE: LINE_SCALE_MODE.NORMAL,\r\n SHADER_MAX_STYLES: 24,\r\n SHADER_MAX_TEXTURES: 4,\r\n PIXEL_LINE: 0,\r\n};\r\n"],"names":[],"mappings":";;AAUO,MAAM,QAAsB,GAAA;AAAA,EAC/B,iBAAiB,eAAgB,CAAA,MAAA;AAAA,EACjC,iBAAmB,EAAA,EAAA;AAAA,EACnB,mBAAqB,EAAA,CAAA;AAAA,EACrB,UAAY,EAAA,CAAA;AAChB;;;;"}

View File

@@ -0,0 +1,225 @@
'use strict';
var core = require('@pixi/core');
var _const = require('../core/const.js');
class CircleBuilder {
path(graphicsData, _target) {
const points = graphicsData.points;
let x;
let y;
let dx;
let dy;
let rx;
let ry;
if (graphicsData.type === core.SHAPES.CIRC) {
const circle = graphicsData.shape;
x = circle.x;
y = circle.y;
rx = ry = circle.radius;
dx = dy = 0;
} else if (graphicsData.type === core.SHAPES.ELIP) {
const ellipse = graphicsData.shape;
x = ellipse.x;
y = ellipse.y;
rx = ellipse.width;
ry = ellipse.height;
dx = dy = 0;
} else {
const roundedRect = graphicsData.shape;
const halfWidth = roundedRect.width / 2;
const halfHeight = roundedRect.height / 2;
x = roundedRect.x + halfWidth;
y = roundedRect.y + halfHeight;
rx = ry = Math.max(0, Math.min(roundedRect.radius, Math.min(halfWidth, halfHeight)));
dx = halfWidth - rx;
dy = halfHeight - ry;
}
if (!(rx >= 0 && ry >= 0 && dx >= 0 && dy >= 0)) {
points.length = 0;
return;
}
const n = Math.ceil(2.3 * Math.sqrt(rx + ry));
const m = n * 8 + (dx ? 4 : 0) + (dy ? 4 : 0);
points.length = m;
if (m === 0) {
return;
}
if (n === 0) {
points.length = 8;
points[0] = points[6] = x + dx;
points[1] = points[3] = y + dy;
points[2] = points[4] = x - dx;
points[5] = points[7] = y - dy;
return;
}
let j1 = 0;
let j2 = n * 4 + (dx ? 2 : 0) + 2;
let j3 = j2;
let j4 = m;
{
const x0 = dx + rx;
const y0 = dy;
const x1 = x + x0;
const x2 = x - x0;
const y1 = y + y0;
points[j1++] = x1;
points[j1++] = y1;
points[--j2] = y1;
points[--j2] = x2;
if (dy) {
const y2 = y - y0;
points[j3++] = x2;
points[j3++] = y2;
points[--j4] = y2;
points[--j4] = x1;
}
}
for (let i = 1; i < n; i++) {
const a = Math.PI / 2 * (i / n);
const x0 = dx + Math.cos(a) * rx;
const y0 = dy + Math.sin(a) * ry;
const x1 = x + x0;
const x2 = x - x0;
const y1 = y + y0;
const y2 = y - y0;
points[j1++] = x1;
points[j1++] = y1;
points[--j2] = y1;
points[--j2] = x2;
points[j3++] = x2;
points[j3++] = y2;
points[--j4] = y2;
points[--j4] = x1;
}
{
const x0 = dx;
const y0 = dy + ry;
const x1 = x + x0;
const x2 = x - x0;
const y1 = y + y0;
const y2 = y - y0;
points[j1++] = x1;
points[j1++] = y1;
points[--j4] = y2;
points[--j4] = x1;
if (dx) {
points[j1++] = x2;
points[j1++] = y1;
points[--j4] = y2;
points[--j4] = x2;
}
}
}
fill(graphicsData, target) {
const { verts, joints } = target;
const { points, triangles } = graphicsData;
if (points.length === 0) {
return;
}
let x;
let y;
if (graphicsData.type !== core.SHAPES.RREC) {
const circle = graphicsData.shape;
x = circle.x;
y = circle.y;
} else {
const roundedRect = graphicsData.shape;
x = roundedRect.x + roundedRect.width / 2;
y = roundedRect.y + roundedRect.height / 2;
}
const matrix = graphicsData.matrix;
const cx = matrix ? matrix.a * x + matrix.c * y + matrix.tx : x;
const cy = matrix ? matrix.b * x + matrix.d * y + matrix.ty : y;
let vertPos = 1;
const center = 0;
if (!graphicsData.fillAA) {
verts.push(cx, cy);
joints.push(_const.JOINT_TYPE.FILL);
verts.push(points[0], points[1]);
joints.push(_const.JOINT_TYPE.FILL);
for (let i = 2; i < points.length; i += 2) {
verts.push(points[i], points[i + 1]);
joints.push(_const.JOINT_TYPE.FILL);
triangles.push(vertPos++, center, vertPos);
}
triangles.push(center + 1, center, vertPos);
return;
}
const len = points.length;
let x1 = points[len - 2];
let y1 = points[len - 1];
let nx1 = y1 - points[len - 3];
let ny1 = points[len - 4] - x1;
const n1 = Math.sqrt(nx1 * nx1 + ny1 * ny1);
nx1 /= n1;
ny1 /= n1;
let bx1;
let by1;
for (let i = 0; i < len; i += 2) {
const x2 = points[i];
const y2 = points[i + 1];
let nx2 = y2 - y1;
let ny2 = x1 - x2;
const n2 = Math.sqrt(nx2 * nx2 + ny2 * ny2);
nx2 /= n2;
ny2 /= n2;
let bx2 = nx1 + nx2;
let by2 = ny1 + ny2;
const b2 = nx2 * bx2 + ny2 * by2;
bx2 /= b2;
by2 /= b2;
if (i > 0) {
verts.push(bx2);
verts.push(by2);
} else {
bx1 = bx2;
by1 = by2;
}
verts.push(cx);
verts.push(cy);
verts.push(x1);
verts.push(y1);
verts.push(x2);
verts.push(y2);
verts.push(0);
verts.push(0);
verts.push(bx2);
verts.push(by2);
joints.push(_const.JOINT_TYPE.FILL_EXPAND + 2);
joints.push(_const.JOINT_TYPE.NONE);
joints.push(_const.JOINT_TYPE.NONE);
joints.push(_const.JOINT_TYPE.NONE);
joints.push(_const.JOINT_TYPE.NONE);
joints.push(_const.JOINT_TYPE.NONE);
x1 = x2;
y1 = y2;
nx1 = nx2;
ny1 = ny2;
}
verts.push(bx1);
verts.push(by1);
}
line(graphicsData, target) {
const { verts, joints } = target;
const { points } = graphicsData;
const joint = points.length === 8 ? graphicsData.goodJointType() : _const.JOINT_TYPE.JOINT_MITER + 3;
const len = points.length;
if (len === 0) {
return;
}
verts.push(points[len - 2], points[len - 1]);
joints.push(_const.JOINT_TYPE.NONE);
for (let i = 0; i < len; i += 2) {
verts.push(points[i], points[i + 1]);
joints.push(joint);
}
verts.push(points[0], points[1]);
joints.push(_const.JOINT_TYPE.NONE);
verts.push(points[2], points[3]);
joints.push(_const.JOINT_TYPE.NONE);
}
}
exports.CircleBuilder = CircleBuilder;
//# sourceMappingURL=CircleBuilder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,223 @@
import { SHAPES } from '@pixi/core';
import { JOINT_TYPE } from '../core/const.mjs';
class CircleBuilder {
path(graphicsData, _target) {
const points = graphicsData.points;
let x;
let y;
let dx;
let dy;
let rx;
let ry;
if (graphicsData.type === SHAPES.CIRC) {
const circle = graphicsData.shape;
x = circle.x;
y = circle.y;
rx = ry = circle.radius;
dx = dy = 0;
} else if (graphicsData.type === SHAPES.ELIP) {
const ellipse = graphicsData.shape;
x = ellipse.x;
y = ellipse.y;
rx = ellipse.width;
ry = ellipse.height;
dx = dy = 0;
} else {
const roundedRect = graphicsData.shape;
const halfWidth = roundedRect.width / 2;
const halfHeight = roundedRect.height / 2;
x = roundedRect.x + halfWidth;
y = roundedRect.y + halfHeight;
rx = ry = Math.max(0, Math.min(roundedRect.radius, Math.min(halfWidth, halfHeight)));
dx = halfWidth - rx;
dy = halfHeight - ry;
}
if (!(rx >= 0 && ry >= 0 && dx >= 0 && dy >= 0)) {
points.length = 0;
return;
}
const n = Math.ceil(2.3 * Math.sqrt(rx + ry));
const m = n * 8 + (dx ? 4 : 0) + (dy ? 4 : 0);
points.length = m;
if (m === 0) {
return;
}
if (n === 0) {
points.length = 8;
points[0] = points[6] = x + dx;
points[1] = points[3] = y + dy;
points[2] = points[4] = x - dx;
points[5] = points[7] = y - dy;
return;
}
let j1 = 0;
let j2 = n * 4 + (dx ? 2 : 0) + 2;
let j3 = j2;
let j4 = m;
{
const x0 = dx + rx;
const y0 = dy;
const x1 = x + x0;
const x2 = x - x0;
const y1 = y + y0;
points[j1++] = x1;
points[j1++] = y1;
points[--j2] = y1;
points[--j2] = x2;
if (dy) {
const y2 = y - y0;
points[j3++] = x2;
points[j3++] = y2;
points[--j4] = y2;
points[--j4] = x1;
}
}
for (let i = 1; i < n; i++) {
const a = Math.PI / 2 * (i / n);
const x0 = dx + Math.cos(a) * rx;
const y0 = dy + Math.sin(a) * ry;
const x1 = x + x0;
const x2 = x - x0;
const y1 = y + y0;
const y2 = y - y0;
points[j1++] = x1;
points[j1++] = y1;
points[--j2] = y1;
points[--j2] = x2;
points[j3++] = x2;
points[j3++] = y2;
points[--j4] = y2;
points[--j4] = x1;
}
{
const x0 = dx;
const y0 = dy + ry;
const x1 = x + x0;
const x2 = x - x0;
const y1 = y + y0;
const y2 = y - y0;
points[j1++] = x1;
points[j1++] = y1;
points[--j4] = y2;
points[--j4] = x1;
if (dx) {
points[j1++] = x2;
points[j1++] = y1;
points[--j4] = y2;
points[--j4] = x2;
}
}
}
fill(graphicsData, target) {
const { verts, joints } = target;
const { points, triangles } = graphicsData;
if (points.length === 0) {
return;
}
let x;
let y;
if (graphicsData.type !== SHAPES.RREC) {
const circle = graphicsData.shape;
x = circle.x;
y = circle.y;
} else {
const roundedRect = graphicsData.shape;
x = roundedRect.x + roundedRect.width / 2;
y = roundedRect.y + roundedRect.height / 2;
}
const matrix = graphicsData.matrix;
const cx = matrix ? matrix.a * x + matrix.c * y + matrix.tx : x;
const cy = matrix ? matrix.b * x + matrix.d * y + matrix.ty : y;
let vertPos = 1;
const center = 0;
if (!graphicsData.fillAA) {
verts.push(cx, cy);
joints.push(JOINT_TYPE.FILL);
verts.push(points[0], points[1]);
joints.push(JOINT_TYPE.FILL);
for (let i = 2; i < points.length; i += 2) {
verts.push(points[i], points[i + 1]);
joints.push(JOINT_TYPE.FILL);
triangles.push(vertPos++, center, vertPos);
}
triangles.push(center + 1, center, vertPos);
return;
}
const len = points.length;
let x1 = points[len - 2];
let y1 = points[len - 1];
let nx1 = y1 - points[len - 3];
let ny1 = points[len - 4] - x1;
const n1 = Math.sqrt(nx1 * nx1 + ny1 * ny1);
nx1 /= n1;
ny1 /= n1;
let bx1;
let by1;
for (let i = 0; i < len; i += 2) {
const x2 = points[i];
const y2 = points[i + 1];
let nx2 = y2 - y1;
let ny2 = x1 - x2;
const n2 = Math.sqrt(nx2 * nx2 + ny2 * ny2);
nx2 /= n2;
ny2 /= n2;
let bx2 = nx1 + nx2;
let by2 = ny1 + ny2;
const b2 = nx2 * bx2 + ny2 * by2;
bx2 /= b2;
by2 /= b2;
if (i > 0) {
verts.push(bx2);
verts.push(by2);
} else {
bx1 = bx2;
by1 = by2;
}
verts.push(cx);
verts.push(cy);
verts.push(x1);
verts.push(y1);
verts.push(x2);
verts.push(y2);
verts.push(0);
verts.push(0);
verts.push(bx2);
verts.push(by2);
joints.push(JOINT_TYPE.FILL_EXPAND + 2);
joints.push(JOINT_TYPE.NONE);
joints.push(JOINT_TYPE.NONE);
joints.push(JOINT_TYPE.NONE);
joints.push(JOINT_TYPE.NONE);
joints.push(JOINT_TYPE.NONE);
x1 = x2;
y1 = y2;
nx1 = nx2;
ny1 = ny2;
}
verts.push(bx1);
verts.push(by1);
}
line(graphicsData, target) {
const { verts, joints } = target;
const { points } = graphicsData;
const joint = points.length === 8 ? graphicsData.goodJointType() : JOINT_TYPE.JOINT_MITER + 3;
const len = points.length;
if (len === 0) {
return;
}
verts.push(points[len - 2], points[len - 1]);
joints.push(JOINT_TYPE.NONE);
for (let i = 0; i < len; i += 2) {
verts.push(points[i], points[i + 1]);
joints.push(joint);
}
verts.push(points[0], points[1]);
joints.push(JOINT_TYPE.NONE);
verts.push(points[2], points[3]);
joints.push(JOINT_TYPE.NONE);
}
}
export { CircleBuilder };
//# sourceMappingURL=CircleBuilder.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,288 @@
'use strict';
var _const = require('../core/const.js');
var core = require('@pixi/core');
const tempArr = [];
function fixOrientation(points, hole = false) {
const m = points.length;
if (m < 6) {
return;
}
let area = 0;
for (let i = 0, x1 = points[m - 2], y1 = points[m - 1]; i < m; i += 2) {
const x2 = points[i];
const y2 = points[i + 1];
area += (x2 - x1) * (y2 + y1);
x1 = x2;
y1 = y2;
}
if (!hole && area > 0 || hole && area <= 0) {
const n = m / 2;
for (let i = n + n % 2; i < m; i += 2) {
const i1 = m - i - 2;
const i2 = m - i - 1;
const i3 = i;
const i4 = i + 1;
[points[i1], points[i3]] = [points[i3], points[i1]];
[points[i2], points[i4]] = [points[i4], points[i2]];
}
}
}
class PolyBuilder {
path(graphicsData, buildData) {
const shape = graphicsData.shape;
const points = graphicsData.points = shape.points.slice();
const eps = buildData.closePointEps;
const eps2 = eps * eps;
if (points.length === 0) {
return;
}
const firstPoint = new core.Point(points[0], points[1]);
const lastPoint = new core.Point(points[points.length - 2], points[points.length - 1]);
const closedShape = graphicsData.closeStroke = shape.closeStroke;
let len = points.length;
let newLen = 2;
for (let i = 2; i < len; i += 2) {
const x1 = points[i - 2];
const y1 = points[i - 1];
const x2 = points[i];
const y2 = points[i + 1];
let flag = true;
if (Math.abs(x1 - x2) < eps && Math.abs(y1 - y2) < eps) {
flag = false;
}
if (flag) {
points[newLen] = points[i];
points[newLen + 1] = points[i + 1];
newLen += 2;
}
}
points.length = len = newLen;
newLen = 2;
for (let i = 2; i + 2 < len; i += 2) {
let x1 = points[i - 2];
let y1 = points[i - 1];
const x2 = points[i];
const y2 = points[i + 1];
let x3 = points[i + 2];
let y3 = points[i + 3];
x1 -= x2;
y1 -= y2;
x3 -= x2;
y3 -= y2;
let flag = true;
if (Math.abs(x3 * y1 - y3 * x1) < eps2) {
if (x1 * x3 + y1 * y3 < -eps2) {
flag = false;
}
}
if (flag) {
points[newLen] = points[i];
points[newLen + 1] = points[i + 1];
newLen += 2;
}
}
points[newLen] = points[len - 2];
points[newLen + 1] = points[len - 1];
newLen += 2;
points.length = len = newLen;
if (len <= 2) {
return;
}
if (closedShape) {
const closedPath = Math.abs(firstPoint.x - lastPoint.x) < eps && Math.abs(firstPoint.y - lastPoint.y) < eps;
if (closedPath) {
points.pop();
points.pop();
}
}
}
line(graphicsData, buildData) {
const { closeStroke, points } = graphicsData;
const len = points.length;
if (len <= 2) {
return;
}
const { verts, joints } = buildData;
const joint = graphicsData.jointType();
const cap = graphicsData.capType();
let prevCap = 0;
let prevX;
let prevY;
if (closeStroke) {
prevX = points[len - 2];
prevY = points[len - 1];
joints.push(_const.JOINT_TYPE.NONE);
} else {
prevX = points[2];
prevY = points[3];
if (cap === _const.JOINT_TYPE.CAP_ROUND) {
verts.push(points[0], points[1]);
joints.push(_const.JOINT_TYPE.NONE);
joints.push(_const.JOINT_TYPE.CAP_ROUND);
prevCap = 0;
} else {
prevCap = cap;
joints.push(_const.JOINT_TYPE.NONE);
}
}
verts.push(prevX, prevY);
for (let i = 0; i < len; i += 2) {
const x1 = points[i];
const y1 = points[i + 1];
let endJoint = joint;
if (i + 2 >= len) {
if (!closeStroke) {
endJoint = _const.JOINT_TYPE.NONE;
}
} else if (i + 4 >= len) {
if (!closeStroke) {
if (cap === _const.JOINT_TYPE.CAP_ROUND) {
endJoint = _const.JOINT_TYPE.JOINT_CAP_ROUND;
}
if (cap === _const.JOINT_TYPE.CAP_BUTT) {
endJoint = _const.JOINT_TYPE.JOINT_CAP_BUTT;
}
if (cap === _const.JOINT_TYPE.CAP_SQUARE) {
endJoint = _const.JOINT_TYPE.JOINT_CAP_SQUARE;
}
}
}
endJoint += prevCap;
prevCap = 0;
verts.push(x1, y1);
joints.push(endJoint);
prevX = x1;
prevY = y1;
}
if (closeStroke) {
verts.push(points[0], points[1]);
joints.push(_const.JOINT_TYPE.NONE);
verts.push(points[2], points[3]);
joints.push(_const.JOINT_TYPE.NONE);
} else {
verts.push(points[len - 4], points[len - 3]);
joints.push(_const.JOINT_TYPE.NONE);
}
}
fill(graphicsData, buildData) {
let points = graphicsData.points;
const holes = graphicsData.holes;
const eps = buildData.closePointEps;
const { verts, joints } = buildData;
if (points.length < 6) {
return;
}
const holeArray = [];
let len = points.length;
fixOrientation(points, false);
for (let i = 0; i < holes.length; i++) {
const hole = holes[i];
fixOrientation(hole.points, true);
holeArray.push(points.length / 2);
points = points.concat(hole.points);
}
const pn = tempArr;
if (pn.length < points.length) {
pn.length = points.length;
}
let start = 0;
for (let i = 0; i <= holeArray.length; i++) {
let finish = len / 2;
if (i > 0) {
if (i < holeArray.length) {
finish = holeArray[i];
} else {
finish = points.length >> 1;
}
}
pn[start * 2] = finish - 1;
pn[(finish - 1) * 2 + 1] = start;
for (let j = start; j + 1 < finish; j++) {
pn[j * 2 + 1] = j + 1;
pn[j * 2 + 2] = j;
}
start = finish;
}
graphicsData.triangles = core.utils.earcut(points, holeArray, 2);
if (!graphicsData.triangles) {
return;
}
if (!graphicsData.fillAA) {
for (let i = 0; i < points.length; i += 2) {
verts.push(points[i], points[i + 1]);
joints.push(_const.JOINT_TYPE.FILL);
}
return;
}
const { triangles } = graphicsData;
len = points.length;
for (let i = 0; i < triangles.length; i += 3) {
let flag = 0;
for (let j = 0; j < 3; j++) {
const ind1 = triangles[i + j];
const ind2 = triangles[i + (j + 1) % 3];
if (pn[ind1 * 2] === ind2 || pn[ind1 * 2 + 1] === ind2) {
flag |= 1 << j;
}
}
joints.push(_const.JOINT_TYPE.FILL_EXPAND + flag);
joints.push(_const.JOINT_TYPE.NONE);
joints.push(_const.JOINT_TYPE.NONE);
joints.push(_const.JOINT_TYPE.NONE);
joints.push(_const.JOINT_TYPE.NONE);
joints.push(_const.JOINT_TYPE.NONE);
}
for (let ind = 0; ind < len / 2; ind++) {
const prev = pn[ind * 2];
const next = pn[ind * 2 + 1];
let nx1 = points[next * 2 + 1] - points[ind * 2 + 1];
let ny1 = -(points[next * 2] - points[ind * 2]);
let nx2 = points[ind * 2 + 1] - points[prev * 2 + 1];
let ny2 = -(points[ind * 2] - points[prev * 2]);
const D1 = Math.sqrt(nx1 * nx1 + ny1 * ny1);
nx1 /= D1;
ny1 /= D1;
const D2 = Math.sqrt(nx2 * nx2 + ny2 * ny2);
nx2 /= D2;
ny2 /= D2;
let bx = nx1 + nx2;
let by = ny1 + ny2;
const D = bx * nx1 + by * ny1;
if (Math.abs(D) < eps) {
bx = nx1;
by = ny1;
} else {
bx /= D;
by /= D;
}
pn[ind * 2] = bx;
pn[ind * 2 + 1] = by;
}
for (let i = 0; i < triangles.length; i += 3) {
const prev = triangles[i];
const ind = triangles[i + 1];
const next = triangles[i + 2];
const nx1 = points[next * 2 + 1] - points[ind * 2 + 1];
const ny1 = -(points[next * 2] - points[ind * 2]);
const nx2 = points[ind * 2 + 1] - points[prev * 2 + 1];
const ny2 = -(points[ind * 2] - points[prev * 2]);
let j1 = 1;
if (nx1 * ny2 - nx2 * ny1 > 0) {
j1 = 2;
}
for (let j = 0; j < 3; j++) {
const ind2 = triangles[i + j * j1 % 3];
verts.push(points[ind2 * 2], points[ind2 * 2 + 1]);
}
for (let j = 0; j < 3; j++) {
const ind2 = triangles[i + j * j1 % 3];
verts.push(pn[ind2 * 2], pn[ind2 * 2 + 1]);
}
}
}
}
exports.PolyBuilder = PolyBuilder;
//# sourceMappingURL=PolyBuilder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,286 @@
import { JOINT_TYPE } from '../core/const.mjs';
import { Point, utils } from '@pixi/core';
const tempArr = [];
function fixOrientation(points, hole = false) {
const m = points.length;
if (m < 6) {
return;
}
let area = 0;
for (let i = 0, x1 = points[m - 2], y1 = points[m - 1]; i < m; i += 2) {
const x2 = points[i];
const y2 = points[i + 1];
area += (x2 - x1) * (y2 + y1);
x1 = x2;
y1 = y2;
}
if (!hole && area > 0 || hole && area <= 0) {
const n = m / 2;
for (let i = n + n % 2; i < m; i += 2) {
const i1 = m - i - 2;
const i2 = m - i - 1;
const i3 = i;
const i4 = i + 1;
[points[i1], points[i3]] = [points[i3], points[i1]];
[points[i2], points[i4]] = [points[i4], points[i2]];
}
}
}
class PolyBuilder {
path(graphicsData, buildData) {
const shape = graphicsData.shape;
const points = graphicsData.points = shape.points.slice();
const eps = buildData.closePointEps;
const eps2 = eps * eps;
if (points.length === 0) {
return;
}
const firstPoint = new Point(points[0], points[1]);
const lastPoint = new Point(points[points.length - 2], points[points.length - 1]);
const closedShape = graphicsData.closeStroke = shape.closeStroke;
let len = points.length;
let newLen = 2;
for (let i = 2; i < len; i += 2) {
const x1 = points[i - 2];
const y1 = points[i - 1];
const x2 = points[i];
const y2 = points[i + 1];
let flag = true;
if (Math.abs(x1 - x2) < eps && Math.abs(y1 - y2) < eps) {
flag = false;
}
if (flag) {
points[newLen] = points[i];
points[newLen + 1] = points[i + 1];
newLen += 2;
}
}
points.length = len = newLen;
newLen = 2;
for (let i = 2; i + 2 < len; i += 2) {
let x1 = points[i - 2];
let y1 = points[i - 1];
const x2 = points[i];
const y2 = points[i + 1];
let x3 = points[i + 2];
let y3 = points[i + 3];
x1 -= x2;
y1 -= y2;
x3 -= x2;
y3 -= y2;
let flag = true;
if (Math.abs(x3 * y1 - y3 * x1) < eps2) {
if (x1 * x3 + y1 * y3 < -eps2) {
flag = false;
}
}
if (flag) {
points[newLen] = points[i];
points[newLen + 1] = points[i + 1];
newLen += 2;
}
}
points[newLen] = points[len - 2];
points[newLen + 1] = points[len - 1];
newLen += 2;
points.length = len = newLen;
if (len <= 2) {
return;
}
if (closedShape) {
const closedPath = Math.abs(firstPoint.x - lastPoint.x) < eps && Math.abs(firstPoint.y - lastPoint.y) < eps;
if (closedPath) {
points.pop();
points.pop();
}
}
}
line(graphicsData, buildData) {
const { closeStroke, points } = graphicsData;
const len = points.length;
if (len <= 2) {
return;
}
const { verts, joints } = buildData;
const joint = graphicsData.jointType();
const cap = graphicsData.capType();
let prevCap = 0;
let prevX;
let prevY;
if (closeStroke) {
prevX = points[len - 2];
prevY = points[len - 1];
joints.push(JOINT_TYPE.NONE);
} else {
prevX = points[2];
prevY = points[3];
if (cap === JOINT_TYPE.CAP_ROUND) {
verts.push(points[0], points[1]);
joints.push(JOINT_TYPE.NONE);
joints.push(JOINT_TYPE.CAP_ROUND);
prevCap = 0;
} else {
prevCap = cap;
joints.push(JOINT_TYPE.NONE);
}
}
verts.push(prevX, prevY);
for (let i = 0; i < len; i += 2) {
const x1 = points[i];
const y1 = points[i + 1];
let endJoint = joint;
if (i + 2 >= len) {
if (!closeStroke) {
endJoint = JOINT_TYPE.NONE;
}
} else if (i + 4 >= len) {
if (!closeStroke) {
if (cap === JOINT_TYPE.CAP_ROUND) {
endJoint = JOINT_TYPE.JOINT_CAP_ROUND;
}
if (cap === JOINT_TYPE.CAP_BUTT) {
endJoint = JOINT_TYPE.JOINT_CAP_BUTT;
}
if (cap === JOINT_TYPE.CAP_SQUARE) {
endJoint = JOINT_TYPE.JOINT_CAP_SQUARE;
}
}
}
endJoint += prevCap;
prevCap = 0;
verts.push(x1, y1);
joints.push(endJoint);
prevX = x1;
prevY = y1;
}
if (closeStroke) {
verts.push(points[0], points[1]);
joints.push(JOINT_TYPE.NONE);
verts.push(points[2], points[3]);
joints.push(JOINT_TYPE.NONE);
} else {
verts.push(points[len - 4], points[len - 3]);
joints.push(JOINT_TYPE.NONE);
}
}
fill(graphicsData, buildData) {
let points = graphicsData.points;
const holes = graphicsData.holes;
const eps = buildData.closePointEps;
const { verts, joints } = buildData;
if (points.length < 6) {
return;
}
const holeArray = [];
let len = points.length;
fixOrientation(points, false);
for (let i = 0; i < holes.length; i++) {
const hole = holes[i];
fixOrientation(hole.points, true);
holeArray.push(points.length / 2);
points = points.concat(hole.points);
}
const pn = tempArr;
if (pn.length < points.length) {
pn.length = points.length;
}
let start = 0;
for (let i = 0; i <= holeArray.length; i++) {
let finish = len / 2;
if (i > 0) {
if (i < holeArray.length) {
finish = holeArray[i];
} else {
finish = points.length >> 1;
}
}
pn[start * 2] = finish - 1;
pn[(finish - 1) * 2 + 1] = start;
for (let j = start; j + 1 < finish; j++) {
pn[j * 2 + 1] = j + 1;
pn[j * 2 + 2] = j;
}
start = finish;
}
graphicsData.triangles = utils.earcut(points, holeArray, 2);
if (!graphicsData.triangles) {
return;
}
if (!graphicsData.fillAA) {
for (let i = 0; i < points.length; i += 2) {
verts.push(points[i], points[i + 1]);
joints.push(JOINT_TYPE.FILL);
}
return;
}
const { triangles } = graphicsData;
len = points.length;
for (let i = 0; i < triangles.length; i += 3) {
let flag = 0;
for (let j = 0; j < 3; j++) {
const ind1 = triangles[i + j];
const ind2 = triangles[i + (j + 1) % 3];
if (pn[ind1 * 2] === ind2 || pn[ind1 * 2 + 1] === ind2) {
flag |= 1 << j;
}
}
joints.push(JOINT_TYPE.FILL_EXPAND + flag);
joints.push(JOINT_TYPE.NONE);
joints.push(JOINT_TYPE.NONE);
joints.push(JOINT_TYPE.NONE);
joints.push(JOINT_TYPE.NONE);
joints.push(JOINT_TYPE.NONE);
}
for (let ind = 0; ind < len / 2; ind++) {
const prev = pn[ind * 2];
const next = pn[ind * 2 + 1];
let nx1 = points[next * 2 + 1] - points[ind * 2 + 1];
let ny1 = -(points[next * 2] - points[ind * 2]);
let nx2 = points[ind * 2 + 1] - points[prev * 2 + 1];
let ny2 = -(points[ind * 2] - points[prev * 2]);
const D1 = Math.sqrt(nx1 * nx1 + ny1 * ny1);
nx1 /= D1;
ny1 /= D1;
const D2 = Math.sqrt(nx2 * nx2 + ny2 * ny2);
nx2 /= D2;
ny2 /= D2;
let bx = nx1 + nx2;
let by = ny1 + ny2;
const D = bx * nx1 + by * ny1;
if (Math.abs(D) < eps) {
bx = nx1;
by = ny1;
} else {
bx /= D;
by /= D;
}
pn[ind * 2] = bx;
pn[ind * 2 + 1] = by;
}
for (let i = 0; i < triangles.length; i += 3) {
const prev = triangles[i];
const ind = triangles[i + 1];
const next = triangles[i + 2];
const nx1 = points[next * 2 + 1] - points[ind * 2 + 1];
const ny1 = -(points[next * 2] - points[ind * 2]);
const nx2 = points[ind * 2 + 1] - points[prev * 2 + 1];
const ny2 = -(points[ind * 2] - points[prev * 2]);
let j1 = 1;
if (nx1 * ny2 - nx2 * ny1 > 0) {
j1 = 2;
}
for (let j = 0; j < 3; j++) {
const ind2 = triangles[i + j * j1 % 3];
verts.push(points[ind2 * 2], points[ind2 * 2 + 1]);
}
for (let j = 0; j < 3; j++) {
const ind2 = triangles[i + j * j1 % 3];
verts.push(pn[ind2 * 2], pn[ind2 * 2 + 1]);
}
}
}
}
export { PolyBuilder };
//# sourceMappingURL=PolyBuilder.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,69 @@
'use strict';
var _const = require('../core/const.js');
var PolyBuilder = require('./PolyBuilder.js');
class RectangleBuilder {
constructor() {
this._polyBuilder = new PolyBuilder.PolyBuilder();
}
path(graphicsData, _target) {
const rectData = graphicsData.shape;
const x = rectData.x;
const y = rectData.y;
const width = rectData.width;
const height = rectData.height;
const points = graphicsData.points;
points.length = 0;
points.push(
x,
y,
x + width,
y,
x + width,
y + height,
x,
y + height
);
}
line(graphicsData, target) {
const { verts, joints } = target;
const { points } = graphicsData;
const joint = graphicsData.goodJointType();
const len = points.length;
verts.push(points[len - 2], points[len - 1]);
joints.push(_const.JOINT_TYPE.NONE);
for (let i = 0; i < len; i += 2) {
verts.push(points[i], points[i + 1]);
joints.push(joint);
}
verts.push(points[0], points[1]);
joints.push(_const.JOINT_TYPE.NONE);
verts.push(points[2], points[3]);
joints.push(_const.JOINT_TYPE.NONE);
}
fill(graphicsData, target) {
const { verts, joints } = target;
const { points, triangles } = graphicsData;
triangles.length = 0;
if (!graphicsData.fillAA) {
verts.push(
points[0],
points[1],
points[2],
points[3],
points[4],
points[5],
points[6],
points[7]
);
joints.push(_const.JOINT_TYPE.FILL, _const.JOINT_TYPE.FILL, _const.JOINT_TYPE.FILL, _const.JOINT_TYPE.FILL);
triangles.push(0, 1, 2, 0, 2, 3);
return;
}
this._polyBuilder.fill(graphicsData, target);
}
}
exports.RectangleBuilder = RectangleBuilder;
//# sourceMappingURL=RectangleBuilder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RectangleBuilder.js","sources":["../../src/shapes/RectangleBuilder.ts"],"sourcesContent":["import type { Rectangle } from '@pixi/core';\r\nimport type { IShapeBuilder } from '../core/IShapeBuilder';\r\nimport { SmoothGraphicsData } from '../core/SmoothGraphicsData';\r\nimport { BuildData } from '../core/BuildData';\r\nimport { JOINT_TYPE } from '../core/const';\r\nimport { PolyBuilder } from './PolyBuilder';\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class RectangleBuilder implements IShapeBuilder\r\n{\r\n _polyBuilder = new PolyBuilder();\r\n\r\n path(graphicsData: SmoothGraphicsData, _target: BuildData)\r\n {\r\n // --- //\r\n // need to convert points to a nice regular data\r\n //\r\n const rectData = graphicsData.shape as Rectangle;\r\n const x = rectData.x;\r\n const y = rectData.y;\r\n const width = rectData.width;\r\n const height = rectData.height;\r\n const points = graphicsData.points;\r\n\r\n points.length = 0;\r\n\r\n points.push(x, y,\r\n x + width, y,\r\n x + width, y + height,\r\n x, y + height);\r\n }\r\n\r\n line(graphicsData: SmoothGraphicsData, target: BuildData): void\r\n {\r\n const { verts, joints } = target;\r\n const { points } = graphicsData;\r\n\r\n const joint = graphicsData.goodJointType();\r\n const len = points.length;\r\n\r\n verts.push(points[len - 2], points[len - 1]);\r\n joints.push(JOINT_TYPE.NONE);\r\n for (let i = 0; i < len; i += 2)\r\n {\r\n verts.push(points[i], points[i + 1]);\r\n joints.push(joint);\r\n }\r\n verts.push(points[0], points[1]);\r\n joints.push(JOINT_TYPE.NONE);\r\n verts.push(points[2], points[3]);\r\n joints.push(JOINT_TYPE.NONE);\r\n }\r\n\r\n fill(graphicsData: SmoothGraphicsData, target: BuildData): void\r\n {\r\n const { verts, joints } = target;\r\n const { points, triangles } = graphicsData;\r\n\r\n triangles.length = 0;\r\n\r\n if (!graphicsData.fillAA)\r\n {\r\n verts.push(points[0], points[1],\r\n points[2], points[3],\r\n points[4], points[5],\r\n points[6], points[7]);\r\n\r\n joints.push(JOINT_TYPE.FILL, JOINT_TYPE.FILL, JOINT_TYPE.FILL, JOINT_TYPE.FILL);\r\n triangles.push(0, 1, 2, 0, 2, 3);\r\n\r\n return;\r\n }\r\n\r\n this._polyBuilder.fill(graphicsData, target);\r\n }\r\n}\r\n"],"names":["PolyBuilder","JOINT_TYPE"],"mappings":";;;;;AAUO,MAAM,gBACb,CAAA;AAAA,EADO,WAAA,GAAA;AAEH,IAAA,IAAA,CAAA,YAAA,GAAe,IAAIA,uBAAY,EAAA,CAAA;AAAA,GAAA;AAAA,EAE/B,IAAA,CAAK,cAAkC,OACvC,EAAA;AAII,IAAA,MAAM,WAAW,YAAa,CAAA,KAAA,CAAA;AAC9B,IAAA,MAAM,IAAI,QAAS,CAAA,CAAA,CAAA;AACnB,IAAA,MAAM,IAAI,QAAS,CAAA,CAAA,CAAA;AACnB,IAAA,MAAM,QAAQ,QAAS,CAAA,KAAA,CAAA;AACvB,IAAA,MAAM,SAAS,QAAS,CAAA,MAAA,CAAA;AACxB,IAAA,MAAM,SAAS,YAAa,CAAA,MAAA,CAAA;AAE5B,IAAA,MAAA,CAAO,MAAS,GAAA,CAAA,CAAA;AAEhB,IAAO,MAAA,CAAA,IAAA;AAAA,MAAK,CAAA;AAAA,MAAG,CAAA;AAAA,MACX,CAAI,GAAA,KAAA;AAAA,MAAO,CAAA;AAAA,MACX,CAAI,GAAA,KAAA;AAAA,MAAO,CAAI,GAAA,MAAA;AAAA,MACf,CAAA;AAAA,MAAG,CAAI,GAAA,MAAA;AAAA,KAAM,CAAA;AAAA,GACrB;AAAA,EAEA,IAAA,CAAK,cAAkC,MACvC,EAAA;AACI,IAAM,MAAA,EAAE,KAAO,EAAA,MAAA,EAAW,GAAA,MAAA,CAAA;AAC1B,IAAM,MAAA,EAAE,QAAW,GAAA,YAAA,CAAA;AAEnB,IAAM,MAAA,KAAA,GAAQ,aAAa,aAAc,EAAA,CAAA;AACzC,IAAA,MAAM,MAAM,MAAO,CAAA,MAAA,CAAA;AAEnB,IAAM,KAAA,CAAA,IAAA,CAAK,OAAO,GAAM,GAAA,CAAC,GAAG,MAAO,CAAA,GAAA,GAAM,CAAC,CAAC,CAAA,CAAA;AAC3C,IAAO,MAAA,CAAA,IAAA,CAAKC,kBAAW,IAAI,CAAA,CAAA;AAC3B,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,GAAA,EAAK,KAAK,CAC9B,EAAA;AACI,MAAA,KAAA,CAAM,KAAK,MAAO,CAAA,CAAC,GAAG,MAAO,CAAA,CAAA,GAAI,CAAC,CAAC,CAAA,CAAA;AACnC,MAAA,MAAA,CAAO,KAAK,KAAK,CAAA,CAAA;AAAA,KACrB;AACA,IAAA,KAAA,CAAM,KAAK,MAAO,CAAA,CAAC,CAAG,EAAA,MAAA,CAAO,CAAC,CAAC,CAAA,CAAA;AAC/B,IAAO,MAAA,CAAA,IAAA,CAAKA,kBAAW,IAAI,CAAA,CAAA;AAC3B,IAAA,KAAA,CAAM,KAAK,MAAO,CAAA,CAAC,CAAG,EAAA,MAAA,CAAO,CAAC,CAAC,CAAA,CAAA;AAC/B,IAAO,MAAA,CAAA,IAAA,CAAKA,kBAAW,IAAI,CAAA,CAAA;AAAA,GAC/B;AAAA,EAEA,IAAA,CAAK,cAAkC,MACvC,EAAA;AACI,IAAM,MAAA,EAAE,KAAO,EAAA,MAAA,EAAW,GAAA,MAAA,CAAA;AAC1B,IAAM,MAAA,EAAE,MAAQ,EAAA,SAAA,EAAc,GAAA,YAAA,CAAA;AAE9B,IAAA,SAAA,CAAU,MAAS,GAAA,CAAA,CAAA;AAEnB,IAAI,IAAA,CAAC,aAAa,MAClB,EAAA;AACI,MAAM,KAAA,CAAA,IAAA;AAAA,QAAK,OAAO,CAAC,CAAA;AAAA,QAAG,OAAO,CAAC,CAAA;AAAA,QAC1B,OAAO,CAAC,CAAA;AAAA,QAAG,OAAO,CAAC,CAAA;AAAA,QACnB,OAAO,CAAC,CAAA;AAAA,QAAG,OAAO,CAAC,CAAA;AAAA,QACnB,OAAO,CAAC,CAAA;AAAA,QAAG,OAAO,CAAC,CAAA;AAAA,OAAC,CAAA;AAExB,MAAO,MAAA,CAAA,IAAA,CAAKA,kBAAW,IAAM,EAAAA,iBAAA,CAAW,MAAMA,iBAAW,CAAA,IAAA,EAAMA,kBAAW,IAAI,CAAA,CAAA;AAC9E,MAAA,SAAA,CAAU,KAAK,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,GAAG,CAAC,CAAA,CAAA;AAE/B,MAAA,OAAA;AAAA,KACJ;AAEA,IAAK,IAAA,CAAA,YAAA,CAAa,IAAK,CAAA,YAAA,EAAc,MAAM,CAAA,CAAA;AAAA,GAC/C;AACJ;;;;"}

View File

@@ -0,0 +1,67 @@
import { JOINT_TYPE } from '../core/const.mjs';
import { PolyBuilder } from './PolyBuilder.mjs';
class RectangleBuilder {
constructor() {
this._polyBuilder = new PolyBuilder();
}
path(graphicsData, _target) {
const rectData = graphicsData.shape;
const x = rectData.x;
const y = rectData.y;
const width = rectData.width;
const height = rectData.height;
const points = graphicsData.points;
points.length = 0;
points.push(
x,
y,
x + width,
y,
x + width,
y + height,
x,
y + height
);
}
line(graphicsData, target) {
const { verts, joints } = target;
const { points } = graphicsData;
const joint = graphicsData.goodJointType();
const len = points.length;
verts.push(points[len - 2], points[len - 1]);
joints.push(JOINT_TYPE.NONE);
for (let i = 0; i < len; i += 2) {
verts.push(points[i], points[i + 1]);
joints.push(joint);
}
verts.push(points[0], points[1]);
joints.push(JOINT_TYPE.NONE);
verts.push(points[2], points[3]);
joints.push(JOINT_TYPE.NONE);
}
fill(graphicsData, target) {
const { verts, joints } = target;
const { points, triangles } = graphicsData;
triangles.length = 0;
if (!graphicsData.fillAA) {
verts.push(
points[0],
points[1],
points[2],
points[3],
points[4],
points[5],
points[6],
points[7]
);
joints.push(JOINT_TYPE.FILL, JOINT_TYPE.FILL, JOINT_TYPE.FILL, JOINT_TYPE.FILL);
triangles.push(0, 1, 2, 0, 2, 3);
return;
}
this._polyBuilder.fill(graphicsData, target);
}
}
export { RectangleBuilder };
//# sourceMappingURL=RectangleBuilder.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RectangleBuilder.mjs","sources":["../../src/shapes/RectangleBuilder.ts"],"sourcesContent":["import type { Rectangle } from '@pixi/core';\r\nimport type { IShapeBuilder } from '../core/IShapeBuilder';\r\nimport { SmoothGraphicsData } from '../core/SmoothGraphicsData';\r\nimport { BuildData } from '../core/BuildData';\r\nimport { JOINT_TYPE } from '../core/const';\r\nimport { PolyBuilder } from './PolyBuilder';\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class RectangleBuilder implements IShapeBuilder\r\n{\r\n _polyBuilder = new PolyBuilder();\r\n\r\n path(graphicsData: SmoothGraphicsData, _target: BuildData)\r\n {\r\n // --- //\r\n // need to convert points to a nice regular data\r\n //\r\n const rectData = graphicsData.shape as Rectangle;\r\n const x = rectData.x;\r\n const y = rectData.y;\r\n const width = rectData.width;\r\n const height = rectData.height;\r\n const points = graphicsData.points;\r\n\r\n points.length = 0;\r\n\r\n points.push(x, y,\r\n x + width, y,\r\n x + width, y + height,\r\n x, y + height);\r\n }\r\n\r\n line(graphicsData: SmoothGraphicsData, target: BuildData): void\r\n {\r\n const { verts, joints } = target;\r\n const { points } = graphicsData;\r\n\r\n const joint = graphicsData.goodJointType();\r\n const len = points.length;\r\n\r\n verts.push(points[len - 2], points[len - 1]);\r\n joints.push(JOINT_TYPE.NONE);\r\n for (let i = 0; i < len; i += 2)\r\n {\r\n verts.push(points[i], points[i + 1]);\r\n joints.push(joint);\r\n }\r\n verts.push(points[0], points[1]);\r\n joints.push(JOINT_TYPE.NONE);\r\n verts.push(points[2], points[3]);\r\n joints.push(JOINT_TYPE.NONE);\r\n }\r\n\r\n fill(graphicsData: SmoothGraphicsData, target: BuildData): void\r\n {\r\n const { verts, joints } = target;\r\n const { points, triangles } = graphicsData;\r\n\r\n triangles.length = 0;\r\n\r\n if (!graphicsData.fillAA)\r\n {\r\n verts.push(points[0], points[1],\r\n points[2], points[3],\r\n points[4], points[5],\r\n points[6], points[7]);\r\n\r\n joints.push(JOINT_TYPE.FILL, JOINT_TYPE.FILL, JOINT_TYPE.FILL, JOINT_TYPE.FILL);\r\n triangles.push(0, 1, 2, 0, 2, 3);\r\n\r\n return;\r\n }\r\n\r\n this._polyBuilder.fill(graphicsData, target);\r\n }\r\n}\r\n"],"names":[],"mappings":";;;AAUO,MAAM,gBACb,CAAA;AAAA,EADO,WAAA,GAAA;AAEH,IAAA,IAAA,CAAA,YAAA,GAAe,IAAI,WAAY,EAAA,CAAA;AAAA,GAAA;AAAA,EAE/B,IAAA,CAAK,cAAkC,OACvC,EAAA;AAII,IAAA,MAAM,WAAW,YAAa,CAAA,KAAA,CAAA;AAC9B,IAAA,MAAM,IAAI,QAAS,CAAA,CAAA,CAAA;AACnB,IAAA,MAAM,IAAI,QAAS,CAAA,CAAA,CAAA;AACnB,IAAA,MAAM,QAAQ,QAAS,CAAA,KAAA,CAAA;AACvB,IAAA,MAAM,SAAS,QAAS,CAAA,MAAA,CAAA;AACxB,IAAA,MAAM,SAAS,YAAa,CAAA,MAAA,CAAA;AAE5B,IAAA,MAAA,CAAO,MAAS,GAAA,CAAA,CAAA;AAEhB,IAAO,MAAA,CAAA,IAAA;AAAA,MAAK,CAAA;AAAA,MAAG,CAAA;AAAA,MACX,CAAI,GAAA,KAAA;AAAA,MAAO,CAAA;AAAA,MACX,CAAI,GAAA,KAAA;AAAA,MAAO,CAAI,GAAA,MAAA;AAAA,MACf,CAAA;AAAA,MAAG,CAAI,GAAA,MAAA;AAAA,KAAM,CAAA;AAAA,GACrB;AAAA,EAEA,IAAA,CAAK,cAAkC,MACvC,EAAA;AACI,IAAM,MAAA,EAAE,KAAO,EAAA,MAAA,EAAW,GAAA,MAAA,CAAA;AAC1B,IAAM,MAAA,EAAE,QAAW,GAAA,YAAA,CAAA;AAEnB,IAAM,MAAA,KAAA,GAAQ,aAAa,aAAc,EAAA,CAAA;AACzC,IAAA,MAAM,MAAM,MAAO,CAAA,MAAA,CAAA;AAEnB,IAAM,KAAA,CAAA,IAAA,CAAK,OAAO,GAAM,GAAA,CAAC,GAAG,MAAO,CAAA,GAAA,GAAM,CAAC,CAAC,CAAA,CAAA;AAC3C,IAAO,MAAA,CAAA,IAAA,CAAK,WAAW,IAAI,CAAA,CAAA;AAC3B,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,GAAA,EAAK,KAAK,CAC9B,EAAA;AACI,MAAA,KAAA,CAAM,KAAK,MAAO,CAAA,CAAC,GAAG,MAAO,CAAA,CAAA,GAAI,CAAC,CAAC,CAAA,CAAA;AACnC,MAAA,MAAA,CAAO,KAAK,KAAK,CAAA,CAAA;AAAA,KACrB;AACA,IAAA,KAAA,CAAM,KAAK,MAAO,CAAA,CAAC,CAAG,EAAA,MAAA,CAAO,CAAC,CAAC,CAAA,CAAA;AAC/B,IAAO,MAAA,CAAA,IAAA,CAAK,WAAW,IAAI,CAAA,CAAA;AAC3B,IAAA,KAAA,CAAM,KAAK,MAAO,CAAA,CAAC,CAAG,EAAA,MAAA,CAAO,CAAC,CAAC,CAAA,CAAA;AAC/B,IAAO,MAAA,CAAA,IAAA,CAAK,WAAW,IAAI,CAAA,CAAA;AAAA,GAC/B;AAAA,EAEA,IAAA,CAAK,cAAkC,MACvC,EAAA;AACI,IAAM,MAAA,EAAE,KAAO,EAAA,MAAA,EAAW,GAAA,MAAA,CAAA;AAC1B,IAAM,MAAA,EAAE,MAAQ,EAAA,SAAA,EAAc,GAAA,YAAA,CAAA;AAE9B,IAAA,SAAA,CAAU,MAAS,GAAA,CAAA,CAAA;AAEnB,IAAI,IAAA,CAAC,aAAa,MAClB,EAAA;AACI,MAAM,KAAA,CAAA,IAAA;AAAA,QAAK,OAAO,CAAC,CAAA;AAAA,QAAG,OAAO,CAAC,CAAA;AAAA,QAC1B,OAAO,CAAC,CAAA;AAAA,QAAG,OAAO,CAAC,CAAA;AAAA,QACnB,OAAO,CAAC,CAAA;AAAA,QAAG,OAAO,CAAC,CAAA;AAAA,QACnB,OAAO,CAAC,CAAA;AAAA,QAAG,OAAO,CAAC,CAAA;AAAA,OAAC,CAAA;AAExB,MAAO,MAAA,CAAA,IAAA,CAAK,WAAW,IAAM,EAAA,UAAA,CAAW,MAAM,UAAW,CAAA,IAAA,EAAM,WAAW,IAAI,CAAA,CAAA;AAC9E,MAAA,SAAA,CAAU,KAAK,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,GAAG,CAAC,CAAA,CAAA;AAE/B,MAAA,OAAA;AAAA,KACJ;AAEA,IAAK,IAAA,CAAA,YAAA,CAAa,IAAK,CAAA,YAAA,EAAc,MAAM,CAAA,CAAA;AAAA,GAC/C;AACJ;;;;"}

View File

@@ -0,0 +1,21 @@
'use strict';
var CircleBuilder = require('./CircleBuilder.js');
class RoundedRectangleBuilder {
constructor() {
this._circleBuilder = new CircleBuilder.CircleBuilder();
}
path(graphicsData, target) {
this._circleBuilder.path(graphicsData, target);
}
line(graphicsData, target) {
this._circleBuilder.line(graphicsData, target);
}
fill(graphicsData, target) {
this._circleBuilder.fill(graphicsData, target);
}
}
exports.RoundedRectangleBuilder = RoundedRectangleBuilder;
//# sourceMappingURL=RoundedRectangleBuilder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RoundedRectangleBuilder.js","sources":["../../src/shapes/RoundedRectangleBuilder.ts"],"sourcesContent":["import type { IShapeBuilder } from '../core/IShapeBuilder';\r\nimport type { SmoothGraphicsData } from '../core/SmoothGraphicsData';\r\nimport type { BuildData } from '../core/BuildData';\r\nimport { CircleBuilder } from './CircleBuilder';\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class RoundedRectangleBuilder implements IShapeBuilder\r\n{\r\n _circleBuilder = new CircleBuilder();\r\n\r\n path(graphicsData: SmoothGraphicsData, target: BuildData)\r\n {\r\n this._circleBuilder.path(graphicsData, target);\r\n }\r\n\r\n line(graphicsData: SmoothGraphicsData, target: BuildData): void\r\n {\r\n this._circleBuilder.line(graphicsData, target);\r\n }\r\n\r\n fill(graphicsData: SmoothGraphicsData, target: BuildData): void\r\n {\r\n this._circleBuilder.fill(graphicsData, target);\r\n }\r\n}\r\n"],"names":["CircleBuilder"],"mappings":";;;;AAQO,MAAM,uBACb,CAAA;AAAA,EADO,WAAA,GAAA;AAEH,IAAA,IAAA,CAAA,cAAA,GAAiB,IAAIA,2BAAc,EAAA,CAAA;AAAA,GAAA;AAAA,EAEnC,IAAA,CAAK,cAAkC,MACvC,EAAA;AACI,IAAK,IAAA,CAAA,cAAA,CAAe,IAAK,CAAA,YAAA,EAAc,MAAM,CAAA,CAAA;AAAA,GACjD;AAAA,EAEA,IAAA,CAAK,cAAkC,MACvC,EAAA;AACI,IAAK,IAAA,CAAA,cAAA,CAAe,IAAK,CAAA,YAAA,EAAc,MAAM,CAAA,CAAA;AAAA,GACjD;AAAA,EAEA,IAAA,CAAK,cAAkC,MACvC,EAAA;AACI,IAAK,IAAA,CAAA,cAAA,CAAe,IAAK,CAAA,YAAA,EAAc,MAAM,CAAA,CAAA;AAAA,GACjD;AACJ;;;;"}

View File

@@ -0,0 +1,19 @@
import { CircleBuilder } from './CircleBuilder.mjs';
class RoundedRectangleBuilder {
constructor() {
this._circleBuilder = new CircleBuilder();
}
path(graphicsData, target) {
this._circleBuilder.path(graphicsData, target);
}
line(graphicsData, target) {
this._circleBuilder.line(graphicsData, target);
}
fill(graphicsData, target) {
this._circleBuilder.fill(graphicsData, target);
}
}
export { RoundedRectangleBuilder };
//# sourceMappingURL=RoundedRectangleBuilder.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RoundedRectangleBuilder.mjs","sources":["../../src/shapes/RoundedRectangleBuilder.ts"],"sourcesContent":["import type { IShapeBuilder } from '../core/IShapeBuilder';\r\nimport type { SmoothGraphicsData } from '../core/SmoothGraphicsData';\r\nimport type { BuildData } from '../core/BuildData';\r\nimport { CircleBuilder } from './CircleBuilder';\r\n\r\n/**\r\n * @memberof PIXI.smooth\r\n */\r\nexport class RoundedRectangleBuilder implements IShapeBuilder\r\n{\r\n _circleBuilder = new CircleBuilder();\r\n\r\n path(graphicsData: SmoothGraphicsData, target: BuildData)\r\n {\r\n this._circleBuilder.path(graphicsData, target);\r\n }\r\n\r\n line(graphicsData: SmoothGraphicsData, target: BuildData): void\r\n {\r\n this._circleBuilder.line(graphicsData, target);\r\n }\r\n\r\n fill(graphicsData: SmoothGraphicsData, target: BuildData): void\r\n {\r\n this._circleBuilder.fill(graphicsData, target);\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAQO,MAAM,uBACb,CAAA;AAAA,EADO,WAAA,GAAA;AAEH,IAAA,IAAA,CAAA,cAAA,GAAiB,IAAI,aAAc,EAAA,CAAA;AAAA,GAAA;AAAA,EAEnC,IAAA,CAAK,cAAkC,MACvC,EAAA;AACI,IAAK,IAAA,CAAA,cAAA,CAAe,IAAK,CAAA,YAAA,EAAc,MAAM,CAAA,CAAA;AAAA,GACjD;AAAA,EAEA,IAAA,CAAK,cAAkC,MACvC,EAAA;AACI,IAAK,IAAA,CAAA,cAAA,CAAe,IAAK,CAAA,YAAA,EAAc,MAAM,CAAA,CAAA;AAAA,GACjD;AAAA,EAEA,IAAA,CAAK,cAAkC,MACvC,EAAA;AACI,IAAK,IAAA,CAAA,cAAA,CAAe,IAAK,CAAA,YAAA,EAAc,MAAM,CAAA,CAAA;AAAA,GACjD;AACJ;;;;"}

View File

@@ -0,0 +1,22 @@
'use strict';
var core = require('@pixi/core');
var CircleBuilder = require('./CircleBuilder.js');
var RectangleBuilder = require('./RectangleBuilder.js');
var RoundedRectangleBuilder = require('./RoundedRectangleBuilder.js');
var PolyBuilder = require('./PolyBuilder.js');
const FILL_COMMANDS = {
[core.SHAPES.POLY]: new PolyBuilder.PolyBuilder(),
[core.SHAPES.CIRC]: new CircleBuilder.CircleBuilder(),
[core.SHAPES.ELIP]: new CircleBuilder.CircleBuilder(),
[core.SHAPES.RECT]: new RectangleBuilder.RectangleBuilder(),
[core.SHAPES.RREC]: new RoundedRectangleBuilder.RoundedRectangleBuilder()
};
exports.CircleBuilder = CircleBuilder.CircleBuilder;
exports.RectangleBuilder = RectangleBuilder.RectangleBuilder;
exports.RoundedRectangleBuilder = RoundedRectangleBuilder.RoundedRectangleBuilder;
exports.PolyBuilder = PolyBuilder.PolyBuilder;
exports.FILL_COMMANDS = FILL_COMMANDS;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../src/shapes/index.ts"],"sourcesContent":["import { SHAPES } from '@pixi/core';\r\nimport { IShapeBuilder } from '../core/IShapeBuilder';\r\nimport { CircleBuilder } from './CircleBuilder';\r\nimport { RectangleBuilder } from './RectangleBuilder';\r\nimport { RoundedRectangleBuilder } from './RoundedRectangleBuilder';\r\nimport { PolyBuilder } from './PolyBuilder';\r\n\r\nexport const FILL_COMMANDS: Record<SHAPES, IShapeBuilder> = {\r\n [SHAPES.POLY]: new PolyBuilder(),\r\n [SHAPES.CIRC]: new CircleBuilder(),\r\n [SHAPES.ELIP]: new CircleBuilder(),\r\n [SHAPES.RECT]: new RectangleBuilder(),\r\n [SHAPES.RREC]: new RoundedRectangleBuilder()\r\n};\r\n\r\nexport { CircleBuilder, RectangleBuilder, RoundedRectangleBuilder, PolyBuilder };\r\n"],"names":["SHAPES","PolyBuilder","CircleBuilder","RectangleBuilder","RoundedRectangleBuilder"],"mappings":";;;;;;;;AAOO,MAAM,aAA+C,GAAA;AAAA,EACxD,CAACA,WAAA,CAAO,IAAI,GAAG,IAAIC,uBAAY,EAAA;AAAA,EAC/B,CAACD,WAAA,CAAO,IAAI,GAAG,IAAIE,2BAAc,EAAA;AAAA,EACjC,CAACF,WAAA,CAAO,IAAI,GAAG,IAAIE,2BAAc,EAAA;AAAA,EACjC,CAACF,WAAA,CAAO,IAAI,GAAG,IAAIG,iCAAiB,EAAA;AAAA,EACpC,CAACH,WAAA,CAAO,IAAI,GAAG,IAAII,+CAAwB,EAAA;AAC/C;;;;;;;;"}

View File

@@ -0,0 +1,16 @@
import { SHAPES } from '@pixi/core';
import { CircleBuilder } from './CircleBuilder.mjs';
import { RectangleBuilder } from './RectangleBuilder.mjs';
import { RoundedRectangleBuilder } from './RoundedRectangleBuilder.mjs';
import { PolyBuilder } from './PolyBuilder.mjs';
const FILL_COMMANDS = {
[SHAPES.POLY]: new PolyBuilder(),
[SHAPES.CIRC]: new CircleBuilder(),
[SHAPES.ELIP]: new CircleBuilder(),
[SHAPES.RECT]: new RectangleBuilder(),
[SHAPES.RREC]: new RoundedRectangleBuilder()
};
export { CircleBuilder, FILL_COMMANDS, PolyBuilder, RectangleBuilder, RoundedRectangleBuilder };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../src/shapes/index.ts"],"sourcesContent":["import { SHAPES } from '@pixi/core';\r\nimport { IShapeBuilder } from '../core/IShapeBuilder';\r\nimport { CircleBuilder } from './CircleBuilder';\r\nimport { RectangleBuilder } from './RectangleBuilder';\r\nimport { RoundedRectangleBuilder } from './RoundedRectangleBuilder';\r\nimport { PolyBuilder } from './PolyBuilder';\r\n\r\nexport const FILL_COMMANDS: Record<SHAPES, IShapeBuilder> = {\r\n [SHAPES.POLY]: new PolyBuilder(),\r\n [SHAPES.CIRC]: new CircleBuilder(),\r\n [SHAPES.ELIP]: new CircleBuilder(),\r\n [SHAPES.RECT]: new RectangleBuilder(),\r\n [SHAPES.RREC]: new RoundedRectangleBuilder()\r\n};\r\n\r\nexport { CircleBuilder, RectangleBuilder, RoundedRectangleBuilder, PolyBuilder };\r\n"],"names":[],"mappings":";;;;;;AAOO,MAAM,aAA+C,GAAA;AAAA,EACxD,CAAC,MAAA,CAAO,IAAI,GAAG,IAAI,WAAY,EAAA;AAAA,EAC/B,CAAC,MAAA,CAAO,IAAI,GAAG,IAAI,aAAc,EAAA;AAAA,EACjC,CAAC,MAAA,CAAO,IAAI,GAAG,IAAI,aAAc,EAAA;AAAA,EACjC,CAAC,MAAA,CAAO,IAAI,GAAG,IAAI,gBAAiB,EAAA;AAAA,EACpC,CAAC,MAAA,CAAO,IAAI,GAAG,IAAI,uBAAwB,EAAA;AAC/C;;;;"}

View File

@@ -0,0 +1,34 @@
{
"name": "@pixi/graphics-smooth",
"version": "1.1.0",
"description": "PixiJS v7 plugin for smooth HHAA rendering of shapes",
"author": "Ivan Popelyshev",
"main": "./lib/index.js",
"module": "./lib/index.mjs",
"types": "./lib/index.d.ts",
"exports": {
".": {
"import": "./lib/index.mjs",
"require": "./lib/index.js",
"types": "./lib/index.d.ts"
}
},
"homepage": "http://www.pixijs.com/",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/pixijs/graphics-smooth.git"
},
"publishConfig": {
"access": "public"
},
"files": [
"dist/",
"lib/"
],
"peerDependencies": {
"@pixi/core": "^7.2.0",
"@pixi/display": "^7.2.0",
"@pixi/graphics": "^7.2.0"
}
}