Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code for discrete color #4

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Change to prevent creation of unnecessary color objects. Could be con…
…verted to just use a single color gradient, but that would most likely break most any existing sequence.
  • Loading branch information
jeffu231 committed Jun 24, 2013
commit deab0eea755a21cfe658ed015d3f4b2a57c78970
15 changes: 11 additions & 4 deletions Modules/Effect/Chase/Chase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ public Color StaticColor
set { _data.StaticColor = value; IsDirty = true; }
}

//Created to hold a ColorGradient version of color rather than continually creating them from Color for static colors.
protected ColorGradient StaticColorGradient
{
get { return _data.StaticColorGradient; }
set { _data.StaticColorGradient = value; }
}

[Value]
public ColorGradient ColorGradient
{
Expand Down Expand Up @@ -126,7 +133,7 @@ private void DoRendering()
List<ElementNode> renderNodes = GetNodesToRenderOn();

int targetNodeCount = renderNodes.Count;

Pulse.Pulse pulse;
EffectIntents pulseData;

Expand All @@ -144,15 +151,15 @@ private void DoRendering()
// figure out what color gradient to use for the pulse
switch (ColorHandling) {
case ChaseColorHandling.GradientForEachPulse:
pulse.ColorGradient = new ColorGradient(StaticColor);
pulse.ColorGradient = StaticColorGradient;
break;

case ChaseColorHandling.GradientThroughWholeEffect:
pulse.ColorGradient = ColorGradient;
break;

case ChaseColorHandling.StaticColor:
pulse.ColorGradient = new ColorGradient(StaticColor);
pulse.ColorGradient = StaticColorGradient;
break;

case ChaseColorHandling.ColorAcrossItems:
Expand Down Expand Up @@ -268,7 +275,7 @@ private void GeneratePulse(ElementNode target, TimeSpan startTime, TimeSpan dura
break;

case ChaseColorHandling.StaticColor:
pulse.ColorGradient = new ColorGradient(StaticColor);
pulse.ColorGradient = StaticColorGradient;
break;

case ChaseColorHandling.ColorAcrossItems:
Expand Down
12 changes: 11 additions & 1 deletion Modules/Effect/Chase/ChaseData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@ public class ChaseData : ModuleDataModelBase
[DataMember]
public double DefaultLevel { get; set; }

private Color _staticColor;
[DataMember]
public Color StaticColor { get; set; }
public Color StaticColor
{
get { return _staticColor; }
set
{
_staticColor = value; StaticColorGradient = new ColorGradient(_staticColor);
}
}

public ColorGradient StaticColorGradient { get; set; }

[DataMember]
public ColorGradient ColorGradient { get; set; }
Expand Down