-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abcdcce
commit 890a218
Showing
23 changed files
with
1,055 additions
and
1,213 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,39 @@ | ||
import { canvas, ctx } from "./main.js"; | ||
|
||
export function drawAll(ctx, currentParticles) { | ||
const { parentLinks, childrenLinks, infoBoxes } = currentParticles; | ||
|
||
export function drawAll(ctx, loadedObjects) { | ||
ctx.clearRect(0, 0, canvas.width, canvas.height); | ||
// console.time("drawParentLinks"); | ||
for (const link of parentLinks) { | ||
link.draw(ctx, infoBoxes); | ||
} | ||
// console.timeEnd("drawParentLinks"); | ||
// console.time("drawChildrenLinks"); | ||
for (const link of childrenLinks) { | ||
link.draw(ctx, infoBoxes); | ||
} | ||
// console.timeEnd("drawChildrenLinks"); | ||
// console.time("drawBoxes"); | ||
for (const infoBox of infoBoxes) { | ||
if (infoBox !== null) infoBox.draw(ctx); | ||
} | ||
// console.timeEnd("drawBoxes"); | ||
} | ||
|
||
export function drawVisible(currentParticles, visibleParticles) { | ||
const { | ||
infoBoxes: visibleBoxes, | ||
parentLinks: visibleParentLinks, | ||
childrenLinks: visibleChildrenLinks, | ||
} = visibleParticles; | ||
for (const elements of Object.values(loadedObjects)) { | ||
const { collection, oneToMany, oneToOne } = elements; | ||
|
||
for (const links of Object.values(oneToMany)) { | ||
for (const link of links) link.draw(ctx); | ||
} | ||
|
||
const { parentLinks, childrenLinks, infoBoxes } = currentParticles; | ||
for (const link of Object.values(oneToOne)) link.draw(ctx); | ||
|
||
for (const object of collection) object.draw(ctx); | ||
} | ||
} | ||
|
||
export function drawVisible(visibleObjects) { | ||
const boundigClientRect = canvas.getBoundingClientRect(); | ||
ctx.clearRect( | ||
0 - boundigClientRect.x, | ||
0 - boundigClientRect.y, | ||
window.innerWidth, | ||
window.innerHeight | ||
); | ||
for (const linkId of visibleParentLinks) { | ||
if (parentLinks[linkId] !== undefined) | ||
parentLinks[linkId].draw(ctx, infoBoxes); | ||
} | ||
for (const linkId of visibleChildrenLinks) { | ||
if (childrenLinks[linkId] !== undefined) | ||
childrenLinks[linkId].draw(ctx, infoBoxes); | ||
} | ||
for (const boxId of visibleBoxes) { | ||
infoBoxes[boxId].draw(ctx); | ||
|
||
for (const elements of Object.values(visibleObjects)) { | ||
const { collection, oneToMany, oneToOne } = elements; | ||
|
||
for (const links of Object.values(oneToMany)) { | ||
for (const link of links) link.draw(ctx); | ||
} | ||
|
||
for (const link of Object.values(oneToOne)) link.draw(ctx); | ||
|
||
for (const object of collection) object.draw(ctx); | ||
} | ||
} |
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,25 @@ | ||
export function copyObject(objToCopy, updatedObject) { | ||
for (const [key, value] of Object.entries(objToCopy)) { | ||
updatedObject[key] = value; | ||
} | ||
} | ||
|
||
export function emptyCopyObject(objToCopy, updatedObject) { | ||
for (const [objectType, elements] of Object.entries(objToCopy)) { | ||
const { _, oneToMany, oneToOne } = elements; | ||
|
||
updatedObject[objectType] = { | ||
collection: [], | ||
oneToMany: {}, | ||
oneToOne: {}, | ||
}; | ||
|
||
for (const name in oneToMany) { | ||
updatedObject[objectType].oneToMany[name] = []; | ||
} | ||
|
||
for (const name in oneToOne) { | ||
updatedObject[objectType].oneToOne[name] = null; | ||
} | ||
} | ||
} |
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,13 @@ | ||
import { mappings } from "../../data/particles.js"; | ||
|
||
export function getName(pdg) { | ||
const particle = mappings[pdg]; | ||
|
||
if (particle !== undefined) { | ||
console.log("Name: " + particle); | ||
return particle; | ||
} | ||
|
||
console.log("PDG: " + pdg.toString()); | ||
return "PDG: " + pdg.toString(); | ||
} |
Oops, something went wrong.