Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/shared/dmxUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Window, Window2D_t } from '../shared/window'
import { Window, Window2D_t, window2DToParentCoords } from '../shared/window'
import {
DmxValue,
DMX_MAX_VALUE,
Expand Down Expand Up @@ -291,7 +291,7 @@ export function flatten_fixture(
let flattened: FlattenedFixture[] = fixture_type.subFixtures.map((sub) => {
return {
intensity: sub.intensity ?? fixture_type.intensity,
window: sub.relative_window ?? fixture.window,
window: sub.relative_window ? window2DToParentCoords(sub.relative_window, fixture.window) : fixture.window,
channels: sub.channels.map((ch_index) => {
subfixture_ch_indexes.add(ch_index)
return [base_channel + ch_index, fixture_type.channels[ch_index]]
Expand Down
14 changes: 14 additions & 0 deletions src/shared/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ export type Window2D_t = {
x?: Window
y?: Window
}

export function windowToParentCoords(relative: Window, parent: Window): Window {
return {
pos: parent.pos + (relative.pos - 0.5) * parent.width,
width: relative.width * parent.width
}
}

export function window2DToParentCoords(relative: Window2D_t, parent: Window2D_t): Window2D_t {
return {
x: relative.x && parent.x ? windowToParentCoords(relative.x, parent.x) : undefined,
y: relative.y && parent.y ? windowToParentCoords(relative.y, parent.y) : undefined
}
}