Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.updateGraphics(graphics);
webGL = graphics._webGL[this.CONTEXT_UID];
}
// This could be speeded up for sure!
const shader = this.primitiveShader;
renderer.state.setBlendMode(graphics.blendMode);
for (let i = 0, n = webGL.data.length; i < n; i++)
{
webGLData = webGL.data[i];
shader.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true);
shader.uniforms.tint = hex2rgb(graphics.tint);
shader.uniforms.alpha = graphics.worldAlpha;
renderer.shader.bind(shader);
renderer.geometry.bind(webGLData.geometry);
if (webGLData.nativeLines)
{
renderer.geometry.draw(gl.LINES, webGLData.indices.length / 6);
}
else
{
renderer.geometry.draw(gl.TRIANGLE_STRIP, webGLData.indices.length);
}
}
}
const radius = rrectData.radius;
const recPoints = [];
recPoints.push(x, y + radius);
quadraticBezierCurve(x, y + height - radius, x, y + height, x + radius, y + height, recPoints);
quadraticBezierCurve(x + width - radius, y + height, x + width, y + height, x + width, y + height - radius, recPoints);
quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y, recPoints);
quadraticBezierCurve(x + radius, y, x, y, x, y + radius + 0.0000000001, recPoints);
// this tiny number deals with the issue that occurs when points overlap and earcut fails to triangulate the item.
// TODO - fix this properly, this is not very elegant.. but it works for now.
if (graphicsData.fill)
{
const color = hex2rgb(graphicsData.fillColor);
const alpha = graphicsData.fillAlpha;
const r = color[0] * alpha;
const g = color[1] * alpha;
const b = color[2] * alpha;
const verts = webGLData.points;
const indices = webGLData.indices;
const vecPos = verts.length / 6;
const triangles = earcut(recPoints, null, 2);
for (let i = 0, j = triangles.length; i < j; i += 3)
{
indices.push(triangles[i] + vecPos);
set color(value) {
hex2rgb(value, this.uniforms.outlineColor);
}
}
this._spriteRect = new Sprite(new Texture(Texture.WHITE));
}
const sprite = this._spriteRect;
const fillColor = this.graphicsData[0].fillColor;
if (this.tint === 0xffffff)
{
sprite.tint = fillColor;
}
else if (this.tint !== this._prevRectTint || fillColor !== this._prevRectFillColor)
{
const t1 = tempColor1;
const t2 = tempColor2;
hex2rgb(fillColor, t1);
hex2rgb(this.tint, t2);
t1[0] *= t2[0];
t1[1] *= t2[1];
t1[2] *= t2[2];
sprite.tint = rgb2hex(t1);
this._prevRectTint = this.tint;
this._prevRectFillColor = fillColor;
}
sprite.alpha = this.graphicsData[0].fillAlpha;
sprite.worldAlpha = this.worldAlpha * sprite.alpha;
sprite.blendMode = this.blendMode;
set newColor(value) {
let arr = this.uniforms.newColor;
if (typeof value === 'number') {
hex2rgb(value, arr);
this._newColor = value;
}
else {
arr[0] = value[0];
arr[1] = value[1];
arr[2] = value[2];
this._newColor = rgb2hex(arr);
}
}
get newColor() {
set lightColor(value) {
hex2rgb(value, this.uniforms.lightColor);
}
set color(value) {
hex2rgb(value, this.uniforms.glowColor);
}