Skip to content

Commit

Permalink
attribute color encoded as hex
Browse files Browse the repository at this point in the history
  • Loading branch information
TeunHuijben committed Dec 9, 2024
1 parent 16c4e55 commit 8b3d9db
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CONFIG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const config = {
data:{
// Default dataset URL (must be publically accessible)
// default_dataset: "https://public.czbiohub.org/royerlab/zoo/Zebrafish/tracks_zebrafish_bundle.zarr/"
default_dataset: "https://public.czbiohub.org/royerlab/zoo/misc/tracks_drosophila_attributes_norm_bundle.zarr/"
// default_dataset: "https://public.czbiohub.org/royerlab/zoo/misc/tracks_drosophila_attributes_norm_bundle.zarr/"
default_dataset: "https://public.czbiohub.org/royerlab/zoo/misc/tracks_hex_bundle.zarr"
},

// Default settings for certain parameters
Expand Down
4 changes: 3 additions & 1 deletion src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ if (detectedDevice.isPhone) {
// );

const drawerWidth = 256;
// const playbackFPS = 16;
const playbackFPS = 16;
const playbackIntervalMs = 1000 / playbackFPS;

Expand Down Expand Up @@ -319,7 +320,8 @@ export default function App() {
const startPositions = track.threeTrack.geometry.getAttribute("instanceStart");
const startTimes = track.threeTrack.geometry.getAttribute("instanceTimeStart");

for (let i = 0; i < startTimes.count; i++) {
console.log("changed for ChromaTrace to only export the first/last timepoint per tracklet");
for (let i = 0; i < 1; i++) {
timepointsInTrack.add(startTimes.getX(i));
trackData.push([
// trackID is 1-indexed in input and output CSVs
Expand Down
2 changes: 1 addition & 1 deletion src/components/leftSidebar/DynamicDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const showDefaultAttributes = config.settings.showDefaultAttributes;
export type Option = {
name: string;
label: number;
type: "default" | "categorical" | "continuous";
type: "default" | "categorical" | "continuous" | "hex";
action: "default" | "calculate" | "provided" | "provided-normalized";
numCategorical: number | undefined;
};
Expand Down
10 changes: 9 additions & 1 deletion src/lib/PointCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export class PointCanvas {
console.error("Invalid action type for colorByEvent:", this.colorByEvent.action);
}
if (attributes) {
if (this.colorByEvent.action != "provided-normalized") {
if (this.colorByEvent.action != "provided-normalized" && this.colorByEvent.type != "hex") {
attributes = this.normalizeAttributeVector(attributes);
}
} else {
Expand All @@ -402,6 +402,14 @@ export class PointCanvas {
for (let i = 0; i < numPoints; i++) {
colorAttribute.setXYZ(i, color.r, color.g, color.b);
}
} else if (this.colorByEvent.type === "hex") {
for (let i = 0; i < numPoints; i++) {
const hexInt = attributes[i]; // must be [0 1]
const hexStr = `#${hexInt.toString(16).padStart(6, "0").toUpperCase()}`;
const color = new Color(hexStr);
color.multiplyScalar(this.pointBrightness);
colorAttribute.setXYZ(i, color.r, color.g, color.b);
}
} else {
const color = new Color();
if (this.colorByEvent.type === "categorical") {
Expand Down

0 comments on commit 8b3d9db

Please sign in to comment.