public Color GetNodeColor(LEDNode node, IColorEffect colorEffect) { if (_applyBackground && colorEffect == StartColor) return new Color() {A = (byte)(255*3/4)}; return _colorApplier.GetNodeColor(node, colorEffect); }
protected override IColorEffect ApplyCycle(TimeRange range, LEDNode ledNode) { double pos = Tween.GetValue(range.Current); if (Ordering.GetLEDPosition(ledNode) <= pos) return _endColorEffect; return _startColorEffect; }
public Color SetColor(TimeRange range, double position, LEDNode led) { double pct = range.Portion * (Colors.Count-1); int start = (int)Math.Floor(pct); int end = (int) Math.Ceiling(pct); double diff = pct - start; Color color = ColorUtil.Interpolate(Colors[start], Colors[end], diff); return color; }
public Color SetColor(TimeRange range, double position, LEDNode led) { //get our position in space double posOffset = position*Width; //get our position in time double timeOffset = range.PortionTotal*_ref.Width - range.PortionTotal*Width; double xPosition = (posOffset + timeOffset)/_ref.Width; double yPosition = Ordering.GetAngle(led); return _ref.GetValueAt(xPosition,yPosition); }
protected override IColorEffect ApplyCycle(TimeRange range, LEDNode ledNode) { double pos = Tween.GetValue(range.Current); double rangeStart = pos - _width/2; double rangeEnd = pos + _width/2; double ledPos = Ordering.GetLEDPosition(ledNode); if(ledPos < rangeStart || ledPos > rangeEnd) return _backgroundColor; return _pulseColor; }
public static LightAddress AddLED(LEDNode node) { if (_nodes.ContainsKey(node.Address)) throw new ArgumentException("Node with address '" + node.Address + "' already exists."); if (node.Address.IsUnknown) { node = new LEDNode(new LightAddress(-1,-1, _unaddressed++), node.Position ); } _nodes.Add(node.Address, node); LightsUpdated(true); return node.Address; }
public static IList<LightAddress> AddLEDs(IEnumerable<LEDNode> nodes) { IList<LightAddress> addresses = new List<LightAddress>(); foreach (LEDNode node in nodes) { LEDNode uNode = node; if (node.Address.IsUnknown) { uNode = new LEDNode(new LightAddress(-1,-1, _unaddressed++), node.Position ); } _nodes.Add(uNode.Address, uNode); addresses.Add(uNode.Address); } LightsUpdated(true); return addresses; }
public Color GetNodeColor(LEDNode node, IColorEffect colorEffect) { double position = (_effect.Ordering.GetLEDPosition(node) - OrderingMin) / OrderingSize; return colorEffect.SetColor(Range, position, node); }
public IColorEffect GetEffect(LEDNode node) { return _nodeApplier.GetEffect(node); }
public Color SetColor(TimeRange range, double position, LEDNode led) { return Colors[(int)(range.Portion*Colors.Count)]; }
public double GetLEDPosition(LEDNode ledNode) { var address = ledNode.Address; double pos = Position(_addressToPos[address], 0, _last); return pos; }
public double GetAngle(LEDNode node) { return 0; }
protected override IColorEffect ApplyCycle(TimeRange range, LEDNode ledNode) { return _colorEffect; }
public bool InGroup(LEDNode node) { return _me.InGroup(node); }
public IColorEffect GetEffect(LEDNode node) { if (_effect._group.InGroup(node)) { return _effect.ApplyCycle(Range, node); } return null; }
protected abstract IColorEffect ApplyCycle(TimeRange range, LEDNode ledNode);
public bool InGroup(LEDNode node) { return _addresSet.Contains(node.Address); }
private bool WriteForeground(LEDNode light, Color color) { light.Color = ColorUtil.Interpolate(color, light.Color); if (light.Color.A >= 230) { return true; } return false; }
private void WriteBackground(LEDNode light, Color color) { if (_plugin != null && _plugin.Enabled && _kinectState == PluginMode.NoBack) { byte amount = _plugin.Applies(light.Position.X, light.Position.Y); if (amount != 0) { light.Color = ColorUtil.Interpolate(color, Colors.Black, amount/255.0); return; } } light.Color = color; }
public bool InGroup(LEDNode node) { throw new NotImplementedException("This operation is not valid on a stub group"); }
private static void ParseLights(StreamReader reader) { int duplicates = 0; string line; while(null != (line = ReadSectionLine(reader))) { string[] fixture = line.Split(Separater.ToCharArray()); double x,y,z; LightAddress address; if(fixture.Length != 4 || !LightAddress.TryParse(fixture[0], out address) || !double.TryParse(fixture[1], out x) || !double.TryParse(fixture[2], out y) || !double.TryParse(fixture[3], out z)) continue; if(!_nodes.ContainsKey(address)) _nodes[address] = new LEDNode(address, new Vector3D(x,y,z)); else { duplicates++; Console.WriteLine("Found Duplicates: address: " + address + " orig pos: "+ _nodes[address].Position + " dup pos:" + new Vector3D(x,y,z)); } } LightsUpdated(true); Console.WriteLine("Found " + duplicates + " duplicates."); }