Two compilers that walk a graph the same way walk it through one emitter (#85)
Refactoring round two: the particle and shader compilers share emitGraph.ts (cycle detection, duplicate names, emit order) and keep only their rules. FontLibrary and TextureLibrary sit on FileLibrary (base URL, loading/failed bookkeeping, listeners); SoundLibrary keeps its own contract. The three Create*Command share ImportFileCommand, the three renames share RenameCommand - class names stay. bandBounds() in framing.ts and portNameField() in portSection.ts replace in-file clones, and three comments that told history now state the rule. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf0be66c9d
commit
d3563897d8
16 files changed
+376
-379
No files matched your search
+11
-8
@@ -68,16 +68,22 @@ export interface Framing {
|
||||
panY: number;
|
||||
}
|
||||
|
||||
function bandBounds(band: Band): { minX: number; maxX: number; minY: number; maxY: number } {
|
||||
return {
|
||||
minX: Math.min(band.x1, band.x2),
|
||||
maxX: Math.max(band.x1, band.x2),
|
||||
minY: Math.min(band.y1, band.y2),
|
||||
maxY: Math.max(band.y1, band.y2),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Ids of every box the band overlaps. Nodes are large rectangles, so – unlike the scene view,
|
||||
* which tests an object's position – touching counts: a band drawn across a node that visibly
|
||||
* caught it would otherwise leave it out.
|
||||
*/
|
||||
export function boxesInBand(boxes: readonly Box[], band: Band): string[] {
|
||||
const minX = Math.min(band.x1, band.x2);
|
||||
const maxX = Math.max(band.x1, band.x2);
|
||||
const minY = Math.min(band.y1, band.y2);
|
||||
const maxY = Math.max(band.y1, band.y2);
|
||||
const { minX, maxX, minY, maxY } = bandBounds(band);
|
||||
return boxes
|
||||
.filter((b) => b.x <= maxX && b.x + b.w >= minX && b.y <= maxY && b.y + b.h >= minY)
|
||||
.map((b) => b.id);
|
||||
@@ -90,10 +96,7 @@ export function boxesInBand(boxes: readonly Box[], band: Band): string[] {
|
||||
* Enclosing it is a deliberate gesture, and it is the one the eye reads as "this box, too".
|
||||
*/
|
||||
export function boxesWithinBand(boxes: readonly Box[], band: Band): string[] {
|
||||
const minX = Math.min(band.x1, band.x2);
|
||||
const maxX = Math.max(band.x1, band.x2);
|
||||
const minY = Math.min(band.y1, band.y2);
|
||||
const maxY = Math.max(band.y1, band.y2);
|
||||
const { minX, maxX, minY, maxY } = bandBounds(band);
|
||||
return boxes
|
||||
.filter((b) => b.x >= minX && b.x + b.w <= maxX && b.y >= minY && b.y + b.h <= maxY)
|
||||
.map((b) => b.id);
|
||||
|
||||
Reference in new issue
Block a user