Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return;
}
// if the line width is an odd number add 0.5 to align to a whole pixel
// commenting this out fixes #711 and #1620
// if (graphicsData.lineWidth%2)
// {
// for (i = 0; i < points.length; i++)
// {
// points[i] += 0.5;
// }
// }
const style = graphicsData.lineStyle;
// get first and last point.. figure out the middle!
const firstPoint = new Point(points[0], points[1]);
const lastPoint = new Point(points[points.length - 2], points[points.length - 1]);
const closedShape = shape.type !== SHAPES.POLY || shape.closeStroke;
const closedPath = Math.abs(firstPoint.x - lastPoint.x) < eps
&& Math.abs(firstPoint.y - lastPoint.y) < eps;
// if the first point is the last point - gonna have issues :)
if (closedShape)
{
// need to clone as we are going to slightly modify the shape..
points = points.slice();
if (closedPath)
{
points.pop();
points.pop();
lastPoint.set(points[points.length - 2], points[points.length - 1]);
{
// this is old texturepacker legacy, some games/libraries are passing "true" for rotated textures
this._rotate = 2;
}
else if (this._rotate % 2 !== 0)
{
throw new Error('attempt to use diamond-shaped UVs. If you are sure, set rotation manually');
}
/**
* Anchor point that is used as default if sprite is created with this texture.
* Changing the `defaultAnchor` at a later point of time will not update Sprite's anchor point.
* @member {PIXI.Point}
* @default {0,0}
*/
this.defaultAnchor = anchor ? new Point(anchor.x, anchor.y) : new Point(0, 0);
/**
* Update ID is observed by sprites and TextureMatrix instances.
* Call updateUvs() to increment it.
*
* @member {number}
* @protected
*/
this._updateID = 0;
/**
* The ids under which this Texture has been added to the texture cache. This is
* automatically set as long as Texture.addToCache is used, but may not be set if a
* Texture is added directly to the TextureCache array.
*
import { Container, Bounds } from '@pixi/display';
import { BLEND_MODES } from '@pixi/constants';
import { Texture } from '@pixi/core';
import { Point, Rectangle, RoundedRectangle, Ellipse, Polygon, Circle, SHAPES, PI_2 } from '@pixi/math';
import { hex2rgb, rgb2hex } from '@pixi/utils';
import bezierCurveTo from './utils/bezierCurveTo';
import { Sprite } from '@pixi/sprite';
import GraphicsData from './GraphicsData';
const tempPoint = new Point();
const tempColor1 = new Float32Array(4);
const tempColor2 = new Float32Array(4);
/**
* The Graphics class contains methods used to draw primitive shapes such as lines, circles and
* rectangles to the display, and to color and fill them.
*
* @class
* @extends PIXI.Container
* @memberof PIXI
*/
export default class Graphics extends Container
{
/**
*
* @param {boolean} [nativeLines=false] - If true the lines will be draw using LINES instead of TRIANGLE_STRIP
constructor()
{
/**
* This point stores the global coords of where the touch/mouse event happened
*
* @member {PIXI.Point}
*/
this.global = new Point();
/**
* The target Sprite that was interacted with
*
* @member {PIXI.Sprite}
*/
this.target = null;
/**
* When passed to an event handler, this will be the original DOM Event that was captured
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
* @see https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent
* @member {MouseEvent|TouchEvent|PointerEvent}
*/
BATCH_POOL,
DRAW_CALL_POOL } from './utils';
import {
BatchGeometry,
BatchDrawCall,
BatchTextureArray,
BaseTexture } from '@pixi/core';
import { DRAW_MODES, WRAP_MODES } from '@pixi/constants';
import { SHAPES, Point, Matrix } from '@pixi/math';
import { GraphicsData } from './GraphicsData';
import { premultiplyTint } from '@pixi/utils';
import { Bounds } from '@pixi/display';
const tmpPoint = new Point();
const tmpBounds = new Bounds();
/**
* The Graphics class contains methods used to draw primitive shapes such as lines, circles and
* rectangles to the display, and to color and fill them.
*
* GraphicsGeometry is designed to not be continually updating the geometry since it's expensive
* to re-tesselate using **earcut**. Consider using {@link PIXI.Mesh} for this use-case, it's much faster.
*
* @class
* @extends PIXI.BatchGeometry
* @memberof PIXI
*/
export class GraphicsGeometry extends BatchGeometry
{
constructor()
constructor(blur = 100, gradientBlur = 600, start = null, end = null){
super(vertex, fragment);
this.uniforms.blur = blur;
this.uniforms.gradientBlur = gradientBlur;
this.uniforms.start = start || new Point(0, window.innerHeight / 2);
this.uniforms.end = end || new Point(600, window.innerHeight / 2);
this.uniforms.delta = new Point(30, 30);
this.uniforms.texSize = new Point(window.innerWidth, window.innerHeight);
this.updateDelta();
}
if (!charData)
{
continue;
}
if (prevCharCode && charData.kerning[prevCharCode])
{
pos.x += charData.kerning[prevCharCode];
}
chars.push({
texture: charData.texture,
line,
charCode,
position: new Point(pos.x + charData.xOffset + (this._letterSpacing / 2), pos.y + charData.yOffset),
});
pos.x += charData.xAdvance + this._letterSpacing;
lastLineWidth = pos.x;
maxLineHeight = Math.max(maxLineHeight, (charData.yOffset + charData.texture.height));
prevCharCode = charCode;
if (lastBreakPos !== -1 && maxWidth > 0 && pos.x > maxWidth)
{
++spacesRemoved;
removeItems(chars, 1 + lastBreakPos - spacesRemoved, 1 + i - lastBreakPos);
i = lastBreakPos;
lastBreakPos = -1;
lineWidths.push(lastBreakWidth);
maxLineWidth = Math.max(maxLineWidth, lastBreakWidth);
line++;
if (!charData)
{
continue;
}
if (prevCharCode && charData.kerning[prevCharCode])
{
pos.x += charData.kerning[prevCharCode];
}
chars.push({
texture: charData.texture,
line,
charCode,
position: new Point(pos.x + charData.xOffset + (this._letterSpacing / 2), pos.y + charData.yOffset),
});
pos.x += charData.xAdvance + this._letterSpacing;
lastLineWidth = pos.x;
maxLineHeight = Math.max(maxLineHeight, (charData.yOffset + charData.texture.height));
prevCharCode = charCode;
if (lastBreakPos !== -1 && maxWidth > 0 && pos.x > maxWidth)
{
++spacesRemoved;
removeItems(chars, 1 + lastBreakPos - spacesRemoved, 1 + i - lastBreakPos);
i = lastBreakPos;
lastBreakPos = -1;
lineWidths.push(lastBreakWidth);
maxLineWidth = Math.max(maxLineWidth, lastBreakWidth);
line++;
constructor()
{
this._tempPoint = new Point();
}
import { TextureMatrix, Texture } from '@pixi/core';
import { Point, Rectangle, Transform } from '@pixi/math';
import { TextureCache } from '@pixi/utils';
import { Sprite } from '@pixi/sprite';
const tempPoint = new Point();
/**
* A tiling sprite is a fast way of rendering a tiling image
*
* @class
* @extends PIXI.Sprite
* @memberof PIXI
*/
export class TilingSprite extends Sprite
{
/**
* @param {PIXI.Texture} texture - the texture of the tiling sprite
* @param {number} [width=100] - the width of the tiling sprite
* @param {number} [height=100] - the height of the tiling sprite
*/
constructor(texture, width = 100, height = 100)