Skip to content

Commit

Permalink
Show dimmer's effect on beam brightness
Browse files Browse the repository at this point in the history
  • Loading branch information
AzGilrock committed Apr 27, 2024
1 parent 9d366cd commit 96f8dc4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
9 changes: 7 additions & 2 deletions xLights/effects/MovingHeadPanels/MovingHeadDimmerPanel.cpp
Expand Up @@ -25,6 +25,7 @@ namespace
const float hline_gap = 1.0f / num_hlines;
const float vline_gap = 1.0f / num_vlines;
const float marker_length = 0.04f;
const float pt_tol = 0.001f; // can't let points be too close or Value Curve deletes them
}

BEGIN_EVENT_TABLE(MovingHeadDimmerPanel, wxPanel)
Expand Down Expand Up @@ -273,8 +274,12 @@ void MovingHeadDimmerPanel::OnMovingHeadMouseMove(wxMouseEvent& event)
// check if inside surrounding handles
if (active_handle != 0 &&
active_handle != m_handles.size()-1) {
if (m_mousePos.m_x < m_handles[active_handle+1].m_x &&
m_mousePos.m_x > m_handles[active_handle-1].m_x) {
if (m_mousePos.m_x < m_handles[active_handle-1].m_x + pt_tol) {
m_handles[active_handle].m_x = m_handles[active_handle-1].m_x + pt_tol;
}
else if (m_mousePos.m_x > m_handles[active_handle+1].m_x - pt_tol) {
m_handles[active_handle].m_x = m_handles[active_handle+1].m_x - pt_tol;
} else {
m_handles[active_handle].m_x = m_mousePos.m_x;
}
}
Expand Down
13 changes: 12 additions & 1 deletion xLights/models/DMX/DmxMovingHead.cpp
Expand Up @@ -540,7 +540,8 @@ void DmxMovingHead::DrawModel(ModelPreview* preview, xlGraphicsContext* ctx, xlG
size_t NodeCount = Nodes.size();
if ((( nullptr != color_ability ) && !color_ability->IsValidModelSettings(this)) ||
!preset_ability->IsValidModelSettings(this) ||
shutter_channel > NodeCount)
shutter_channel > NodeCount ||
dimmer_channel > NodeCount )
{
DmxModel::DrawInvalid(sprogram, &(GetModelScreenLocation()), false, false);
return;
Expand All @@ -563,6 +564,16 @@ void DmxMovingHead::DrawModel(ModelPreview* preview, xlGraphicsContext* ctx, xlG

xlColor beam_color = color_ability->GetBeamColor(Nodes);

// apply dimmer to beam
if (dimmer_channel > 0 && active) {
xlColor proxy;
Nodes[dimmer_channel - 1]->GetColor(proxy);
HSVValue hsv = proxy.asHSV();
beam_color.red = (beam_color.red * hsv.value);
beam_color.blue = (beam_color.blue * hsv.value);
beam_color.green = (beam_color.green * hsv.value);
}

if (!active) {
beam_color = xlWHITE;
} else {
Expand Down
14 changes: 13 additions & 1 deletion xLights/models/DMX/DmxMovingHeadAdv.cpp
Expand Up @@ -827,7 +827,8 @@ void DmxMovingHeadAdv::DrawModel(ModelPreview* preview, xlGraphicsContext* ctx,
size_t NodeCount = Nodes.size();
if ((( nullptr != color_ability ) && !color_ability->IsValidModelSettings(this)) ||
!preset_ability->IsValidModelSettings(this) ||
shutter_channel > NodeCount)
shutter_channel > NodeCount ||
dimmer_channel > NodeCount)
{
DmxModel::DrawInvalid(sprogram, &(GetModelScreenLocation()), false, false);
return;
Expand Down Expand Up @@ -953,6 +954,17 @@ void DmxMovingHeadAdv::DrawModel(ModelPreview* preview, xlGraphicsContext* ctx,
if (!active) {
beam_color = xlWHITE;
}

// apply dimmer to beam
if (dimmer_channel > 0 && active) {
xlColor proxy;
Nodes[dimmer_channel - 1]->GetColor(proxy);
HSVValue hsv = proxy.asHSV();
beam_color.red = (beam_color.red * hsv.value);
beam_color.blue = (beam_color.blue * hsv.value);
beam_color.green = (beam_color.green * hsv.value);
}

ApplyTransparency(beam_color, trans, trans);

pan_angle_raw += beam_orient;
Expand Down

0 comments on commit 96f8dc4

Please sign in to comment.