forked from pixijs/pixijs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pixel line to graphics! (native line from v7) (pixijs#11004)
* add pixel perfect line to line style * fix topology * add test * remove only * update test images * make topology required * fix imports * add pixel perfect line to line style * fix topology * add test * remove only * update test images * make topology required * fix imports * add warning --------- Co-authored-by: Zyie <[email protected]>
- Loading branch information
1 parent
d8b8e18
commit 6a88679
Showing
19 changed files
with
137 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { closePointEps } from '../const'; | ||
|
||
/** | ||
* Builds a line to draw using the polygon method. | ||
* @param points | ||
* @param closed | ||
* @param vertices | ||
* @param indices | ||
*/ | ||
export function buildPixelLine( | ||
points: number[], | ||
closed: boolean, | ||
vertices: number[], | ||
indices: number[], | ||
): void | ||
{ | ||
const eps = closePointEps; | ||
|
||
if (points.length === 0) | ||
{ | ||
return; | ||
} | ||
|
||
// get first and last point.. figure out the middle! | ||
|
||
const fx = points[0]; | ||
const fy = points[1]; | ||
|
||
const lx = points[points.length - 2]; | ||
|
||
const ly = points[points.length - 1]; | ||
|
||
const closePath = closed || (Math.abs(fx - lx) < eps && Math.abs(fy - ly) < eps); | ||
|
||
const verts = vertices; | ||
|
||
const length = points.length / 2; | ||
const indexStart = verts.length / 2; | ||
|
||
for (let i = 0; i < length; i++) | ||
{ | ||
verts.push(points[(i * 2)]); | ||
verts.push(points[(i * 2) + 1]); | ||
} | ||
|
||
for (let i = 0; i < length - 1; i++) | ||
{ | ||
indices.push(indexStart + i, indexStart + i + 1); | ||
} | ||
|
||
if (closePath) | ||
{ | ||
indices.push(indexStart + length - 1, indexStart); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.