Skip to content

Commit

Permalink
Move flatCoordsToPoints from util/util.js to pixi/helpers.js
Browse files Browse the repository at this point in the history
We shouldn't be star importing from Pixi in our `util` module,
this is code that should be expected to be run headlessly in unit tests.

re: pixijs/pixijs#10170
  • Loading branch information
bhousel committed Feb 1, 2024
1 parent 71aea30 commit 349091b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
3 changes: 1 addition & 2 deletions modules/pixi/PixiFeaturePolygon.js
Expand Up @@ -3,9 +3,8 @@ import { DashLine } from '@rapideditor/pixi-dashed-line';
import { GlowFilter } from 'pixi-filters';
import { /* geomRotatePoints,*/ vecEqual, vecLength /*, vecSubtract */ } from '@rapid-sdk/math';

import { flatCoordsToPoints } from '../util/util.js';
import { AbstractFeature } from './AbstractFeature.js';
import { lineToPoly } from './helpers.js';
import { flatCoordsToPoints, lineToPoly } from './helpers.js';

const PARTIALFILLWIDTH = 32;

Expand Down
9 changes: 9 additions & 0 deletions modules/pixi/helpers.js
Expand Up @@ -332,6 +332,15 @@ if (isLimited && (span >= spacing * 100)) {
}


export function flatCoordsToPoints(coords) {
const points = new Array(coords.length / 2);
for (let i = 0; i < coords.length; i += 2) {
points[i / 2] = new PIXI.Point(coords[i], coords[i + 1]);
}
return points;
}


export function getDebugBBox(x, y, width, height, color, alpha, name) {
const sprite = new PIXI.Sprite(PIXI.Texture.WHITE);
sprite.eventMode = 'none';
Expand Down
10 changes: 0 additions & 10 deletions modules/util/util.js
@@ -1,4 +1,3 @@
import * as PIXI from 'pixi.js';
import { Extent } from '@rapid-sdk/math';


Expand All @@ -25,15 +24,6 @@ export function utilTotalExtent(vals, graph) {
}


export function flatCoordsToPoints(coords) {
let points = [];
for (let i = 0; i < coords.length; i += 2){
points.push(new PIXI.Point(coords[i], coords[i + 1]));
}
return points;
}


// Adds or removes highlight styling for the specified entities
export function utilHighlightEntities(entityIDs, highlighted, context) {
const editor = context.systems.editor;
Expand Down

0 comments on commit 349091b

Please sign in to comment.