コード例 #1
0
ファイル: PulseRenderer.cs プロジェクト: jaredb7/vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        public static EffectIntents RenderNode(ElementNode node, Curve levelCurve, ColorGradient colorGradient, TimeSpan duration, bool isDiscrete, bool allowZeroIntensity = false)
        {
            //Collect all the points first.
            double[] allPointsTimeOrdered = _GetAllSignificantDataPoints(levelCurve, colorGradient).ToArray();
            var elementData = new EffectIntents();
            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                    continue;

                //ElementColorType colorType = ColorModule.getColorTypeForElementNode(elementNode);

                if (isDiscrete && IsElementDiscrete(node))
                {
                    IEnumerable<Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false)
                         .Intersect(colorGradient.GetColorsInGradient());
                    foreach (Color color in colors)
                    {
                        AddIntentsToElement(elementNode.Element, allPointsTimeOrdered, levelCurve, colorGradient, duration, elementData, allowZeroIntensity, color);
                    }
                }
                else
                {
                    AddIntentsToElement(elementNode.Element, allPointsTimeOrdered, levelCurve, colorGradient, duration, elementData, allowZeroIntensity);
                }
            }

            return elementData;
        }
コード例 #2
0
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        public static EffectIntents RenderNode(ElementNode node, Curve levelCurve, ColorGradient colorGradient, TimeSpan duration, bool isDiscrete, bool allowZeroIntensity = false)
        {
            //Collect all the points first.
            double[] allPointsTimeOrdered = _GetAllSignificantDataPoints(levelCurve, colorGradient).ToArray();
            var      elementData          = new EffectIntents();

            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                {
                    continue;
                }

                //ElementColorType colorType = ColorModule.getColorTypeForElementNode(elementNode);

                if (isDiscrete && IsElementDiscrete(node))
                {
                    IEnumerable <Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false)
                                                 .Intersect(colorGradient.GetColorsInGradient());
                    foreach (Color color in colors)
                    {
                        AddIntentsToElement(elementNode.Element, allPointsTimeOrdered, levelCurve, colorGradient, duration, elementData, allowZeroIntensity, color);
                    }
                }
                else
                {
                    AddIntentsToElement(elementNode.Element, allPointsTimeOrdered, levelCurve, colorGradient, duration, elementData, allowZeroIntensity);
                }
            }

            return(elementData);
        }
コード例 #3
0
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private void RenderNode(ElementNode node)
        {
            //Collect all the points first.
            double[] allPointsTimeOrdered = _GetAllSignificantDataPoints().ToArray();
            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                {
                    continue;
                }

                ElementColorType colorType = ColorModule.getColorTypeForElementNode(elementNode);

                if (colorType == ElementColorType.FullColor)
                {
                    addIntentsToElement(elementNode.Element, allPointsTimeOrdered);
                }
                else
                {
                    IEnumerable <Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false)
                                                 .Intersect(ColorGradient.GetColorsInGradient());
                    foreach (Color color in colors)
                    {
                        addIntentsToElement(elementNode.Element, allPointsTimeOrdered, color);
                    }
                }
            }
        }
コード例 #4
0
ファイル: VUMeter.cs プロジェクト: jaredb7/vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        protected override void RenderNode(ElementNode node)
        {
            if (!AudioUtilities.AudioLoaded)
                return;

            foreach (ElementNode elementNode in node.GetLeafEnumerator()) {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                    continue;
                bool discreteColors = ColorModule.isElementNodeDiscreteColored(elementNode);

                for(int i = 0;i<(int)((TimeSpan.TotalMilliseconds/Spacing)-1);i++)
                {

                    double gradientPosition1 = (AudioUtilities.VolumeAtTime(i * Spacing) + Data.Range)/Data.Range ;
                    double gradientPosition2 = (AudioUtilities.VolumeAtTime((i+1) * Spacing) + Data.Range)/Data.Range;
                    if (gradientPosition1 <= 0)
                        gradientPosition1 = 0;
                    if (gradientPosition1 >= 1)
                        gradientPosition1 = 1;

                    //Some odd corner cases
                    if (gradientPosition2 <= 0)
                        gradientPosition2 = 0;
                    if (gradientPosition2 >= 1)
                        gradientPosition2 = 1;
                    TimeSpan startTime = TimeSpan.FromMilliseconds(i * Spacing);
                    ElementData.Add(GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition1, gradientPosition2, TimeSpan.FromMilliseconds(Spacing), startTime, discreteColors));

                }

            }
        }
コード例 #5
0
ファイル: SetLevel.cs プロジェクト: thorhs/vixen
 // renders the given node to the internal ElementData dictionary. If the given node is
 // not a element, will recursively descend until we render its elements.
 private void RenderNode(ElementNode node)
 {
     foreach (ElementNode elementNode in node.GetLeafEnumerator())
     {
         LightingValue lightingValue = new LightingValue(Color, (float)IntensityLevel);
         IIntent       intent        = new LightingIntent(lightingValue, lightingValue, TimeSpan);
         _elementData.AddIntentForElement(elementNode.Element.Id, intent, TimeSpan.Zero);
     }
 }
コード例 #6
0
ファイル: Alternating.cs プロジェクト: thorhs/vixen
		//(Numbers represent color/curve pairs, rows are elements columns are intervals)
		//12341234
		//23412341
		//34123412
		//41234123

		//An offset of 2
		//12341234
		//34123412
		//12341234
		//34123412

		//Offset 3
		//12341234
		//41234123
		//23412341
		//12341234

		// renders the given node to the internal ElementData dictionary. If the given node is
		// not a element, will recursively descend until we render its elements.
		private EffectIntents RenderNode(ElementNode node)
		{
			EffectIntents effectIntents = new EffectIntents();
			int intervals = 1;
			var gradientLevelItem = 0;
			var startIndexOffset = 0;
			//make local hold variables to prevent changes in the middle of rendering.
			int group = GroupLevel;
			var skip = IntervalSkipCount;
			int colorCount = Colors.Count();
			//Use a single pulse to do our work, we don't need to keep creating it and then thowing it away making the GC work
			//hard for no reason.
			var pulse = new Pulse.Pulse(); 
			
			if (!EnableStatic)
			{
				intervals = Convert.ToInt32(Math.Ceiling(TimeSpan.TotalMilliseconds/Interval));
			}

			var startTime = TimeSpan.Zero;
			var nodes = node.GetLeafEnumerator();

			var intervalTime = intervals == 1
					? TimeSpan
					: TimeSpan.FromMilliseconds(Interval);

			pulse.TimeSpan = intervalTime;
			
			for (int i = 0; i < intervals; i++)
			{
				var elements = nodes.Select((x, index) => new { x, index })
					.GroupBy(x => x.index / group, y => y.x);

				foreach (IGrouping<int, ElementNode> elementGroup in elements)
				{
					var glp = Colors[gradientLevelItem];
					foreach (var element in elementGroup)
					{
						RenderElement(pulse, glp, startTime, element, effectIntents);
					}
					gradientLevelItem = ++gradientLevelItem % colorCount;

				}

				startIndexOffset = (skip+startIndexOffset) % colorCount;
				gradientLevelItem = startIndexOffset;
				
				startTime += intervalTime;
			}

			return effectIntents;
		}
コード例 #7
0
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private void RenderNode(ElementNode node)
        {
            bool   altColor      = false;
            bool   startingColor = false;
            double intervals     = 1;

            if (Enable)
            {
                //intervals = Math.DivRem((long)TimeSpan.TotalMilliseconds, (long)Interval, out rem);
                intervals = Math.Ceiling(TimeSpan.TotalMilliseconds / (double)Interval);
            }

            TimeSpan startTime = TimeSpan.Zero;

            for (int i = 0; i < intervals; i++)
            {
                altColor = startingColor;
                var intervalTime = intervals == 1
                                                                        ? TimeSpan
                                                                        : TimeSpan.FromMilliseconds(Interval);

                LightingValue?lightingValue = null;

                int totalElements = node.Count();
                int currentNode   = 0;

                var nodes = node.GetLeafEnumerator();

                while (currentNode < totalElements)
                {
                    var elements = nodes.Skip(currentNode).Take(GroupEffect);

                    currentNode += GroupEffect;

                    int cNode = 0;
                    elements.ToList().ForEach(element => {
                        RenderElement(altColor, ref startTime, ref intervalTime, ref lightingValue, element);
                        cNode++;
                    });
                    altColor = !altColor;
                }


                startTime    += intervalTime;
                startingColor = !startingColor;
            }
        }
コード例 #8
0
ファイル: VUMeter.cs プロジェクト: priyanr/Vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        protected override void RenderNode(ElementNode node)
        {
            if (!AudioUtilities.AudioLoaded)
            {
                return;
            }

            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                {
                    continue;
                }
                bool discreteColors = ColorModule.isElementNodeDiscreteColored(elementNode);

                for (int i = 0; i < (int)((TimeSpan.TotalMilliseconds / Spacing) - 1); i++)
                {
                    double gradientPosition1 = (AudioUtilities.VolumeAtTime(i * Spacing) + Data.Range) / Data.Range;
                    double gradientPosition2 = (AudioUtilities.VolumeAtTime((i + 1) * Spacing) + Data.Range) / Data.Range;
                    if (gradientPosition1 <= 0)
                    {
                        gradientPosition1 = 0;
                    }
                    if (gradientPosition1 >= 1)
                    {
                        gradientPosition1 = 1;
                    }

                    //Some odd corner cases
                    if (gradientPosition2 <= 0)
                    {
                        gradientPosition2 = 0;
                    }
                    if (gradientPosition2 >= 1)
                    {
                        gradientPosition2 = 1;
                    }
                    TimeSpan startTime = TimeSpan.FromMilliseconds(i * Spacing);
                    ElementData.Add(GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition1, gradientPosition2, TimeSpan.FromMilliseconds(Spacing), startTime, discreteColors));
                }
            }
        }
コード例 #9
0
ファイル: SetLevel.cs プロジェクト: micahswitzer/vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private EffectIntents RenderNode(ElementNode node)
        {
            EffectIntents effectIntents = new EffectIntents();

            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {
                if (HasDiscreteColors && IsElementDiscrete(elementNode))
                {
                    IEnumerable <Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false);
                    if (!colors.Contains(Color))
                    {
                        continue;
                    }
                }

                IIntent intent = CreateIntent(elementNode, Color, IntensityLevel, TimeSpan);
                effectIntents.AddIntentForElement(elementNode.Element.Id, intent, TimeSpan.Zero);
            }

            return(effectIntents);
        }
コード例 #10
0
        protected EffectIntents CreateIntentsForElement(ElementNode element, double intensity, Color color, TimeSpan duration)
        {
            EffectIntents effectIntents = new EffectIntents();

            foreach (ElementNode elementNode in element.GetLeafEnumerator())
            {
                if (HasDiscreteColors && IsElementDiscrete(elementNode))
                {
                    IEnumerable <Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false);
                    if (!colors.Contains(color))
                    {
                        continue;
                    }
                }

                IIntent intent = CreateIntent(elementNode, color, intensity, duration);
                effectIntents.AddIntentForElement(elementNode.Element.Id, intent, TimeSpan.Zero);
            }

            return(effectIntents);
        }
コード例 #11
0
ファイル: Alternating.cs プロジェクト: Jchuchla/vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private void RenderNode(ElementNode node)
        {
            bool altColor = false;
            bool startingColor = false;
            double intervals = 1;

            if (Enable) {
                //intervals = Math.DivRem((long)TimeSpan.TotalMilliseconds, (long)Interval, out rem);
                intervals = Math.Ceiling(TimeSpan.TotalMilliseconds / (double)Interval);
            }

            TimeSpan startTime = TimeSpan.Zero;

            for (int i = 0; i < intervals; i++) {
                altColor = startingColor;
                var intervalTime = intervals == 1
                                    ? TimeSpan
                                    : TimeSpan.FromMilliseconds(Interval);

                LightingValue? lightingValue = null;

                int totalElements = node.Count();
                int currentNode = 0;

                var nodes = node.GetLeafEnumerator();

                while (currentNode < totalElements) {

                    var elements = nodes.Skip(currentNode).Take(GroupEffect);

                    currentNode += GroupEffect;

                    int cNode = 0;
                    elements.ToList().ForEach(element => {
                        RenderElement(altColor, ref startTime, ref intervalTime, ref lightingValue, element);
                        cNode++;
                    });
                    altColor = !altColor;
                }

                startTime += intervalTime;
                startingColor = !startingColor;
            }
        }
コード例 #12
0
ファイル: Pulse.cs プロジェクト: stewmc/vixen
		// renders the given node to the internal ElementData dictionary. If the given node is
		// not a element, will recursively descend until we render its elements.
		private void RenderNode(ElementNode node)
		{
			//Collect all the points first.
			double[] allPointsTimeOrdered = _GetAllSignificantDataPoints().ToArray();
			foreach (ElementNode elementNode in node.GetLeafEnumerator()) {
				// this is probably always going to be a single element for the given node, as
				// we have iterated down to leaf nodes in RenderNode() above. May as well do
				// it this way, though, in case something changes in future.
				if (elementNode == null || elementNode.Element == null)
					continue;

				ElementColorType colorType = ColorModule.getColorTypeForElementNode(elementNode);

				if (colorType == ElementColorType.FullColor) {
					addIntentsToElement(elementNode.Element, allPointsTimeOrdered);
				}
				else {
					IEnumerable<Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false)
						 .Intersect(ColorGradient.GetColorsInGradient());
					foreach (Color color in colors) {
						addIntentsToElement(elementNode.Element, allPointsTimeOrdered, color);	
					}
				}
			}
		}
コード例 #13
0
ファイル: Waveform.cs プロジェクト: priyanr/Vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        protected override void RenderNode(ElementNode node)
        {
            if (!AudioUtilities.AudioLoaded)
            {
                return;
            }

            int currentElement = 0;

            var nodeCount = 0;

            if (Inverted)
            {
                nodeCount = node.GetLeafEnumerator().Count();
            }

            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                {
                    continue;
                }

                bool discreteColors = ColorModule.isElementNodeDiscreteColored(elementNode);

                for (int i = 1; i < (int)(TimeSpan.TotalMilliseconds / Spacing); i++)
                {
                    int startAudioTime;
                    int endAudioTime;
                    if (Inverted)
                    {
                        startAudioTime = i * Spacing - (nodeCount - currentElement) * ((WaveformData)Data).ScrollSpeed + 1;
                        endAudioTime   = (i + 1) * Spacing - (nodeCount - currentElement) * ((WaveformData)Data).ScrollSpeed;
                    }
                    else
                    {
                        startAudioTime = i * Spacing - currentElement * ((WaveformData)Data).ScrollSpeed + 1;
                        endAudioTime   = (i + 1) * Spacing - currentElement * ((WaveformData)Data).ScrollSpeed;
                    }
                    TimeSpan startTime = TimeSpan.FromMilliseconds(i * Spacing);

                    if (startAudioTime > 0 && startAudioTime < TimeSpan.TotalMilliseconds && endAudioTime > 0 && endAudioTime < TimeSpan.TotalMilliseconds)
                    {
                        double gradientPosition1 = (AudioUtilities.VolumeAtTime(startAudioTime) + Data.Range) / Data.Range;
                        double gradientPosition2 = (AudioUtilities.VolumeAtTime(endAudioTime) + Data.Range) / Data.Range;

                        //Some odd corner cases
                        if (gradientPosition1 <= 0)
                        {
                            gradientPosition1 = 0;
                        }
                        if (gradientPosition1 >= 1)
                        {
                            gradientPosition1 = 1;
                        }

                        //Some odd corner cases
                        if (gradientPosition2 <= 0)
                        {
                            gradientPosition2 = 0;
                        }
                        if (gradientPosition2 >= 1)
                        {
                            gradientPosition2 = 1;
                        }

                        ElementData.Add(GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition1, gradientPosition2, TimeSpan.FromMilliseconds(Spacing), startTime, discreteColors));
                    }
                }
                currentElement++;
            }
        }
コード例 #14
0
ファイル: SetLevel.cs プロジェクト: jaredb7/vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private EffectIntents RenderNode(ElementNode node)
        {
            EffectIntents effectIntents = new EffectIntents();
            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {

                if (HasDiscreteColors && IsElementDiscrete(elementNode))
                {
                    IEnumerable<Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false);
                    if (!colors.Contains(Color))
                    {
                        continue;
                    }
                }

                var intent = CreateIntent(elementNode, Color, (float)HSV.FromRGB(Color).V * IntensityLevel, TimeSpan);
                effectIntents.AddIntentForElement(elementNode.Element.Id, intent, TimeSpan.Zero);
            }

            return effectIntents;
        }
コード例 #15
0
ファイル: SetLevel.cs プロジェクト: eberletj/vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private EffectIntents RenderNode(ElementNode node)
        {
            EffectIntents effectIntents = new EffectIntents();
            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {
                var intent = CreateIntent(elementNode, Color, (float) HSV.FromRGB(Color).V * IntensityLevel, TimeSpan);
                effectIntents.AddIntentForElement(elementNode.Element.Id, intent, TimeSpan.Zero);
            }

            return effectIntents;
        }
コード例 #16
0
ファイル: Waveform.cs プロジェクト: jaredb7/vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        protected override void RenderNode(ElementNode node)
        {
            if (!AudioUtilities.AudioLoaded)
                return;

            int currentElement = 0;

            var nodeCount = 0;
            if (Inverted)
            {
                nodeCount = node.GetLeafEnumerator().Count();
            }

            foreach (ElementNode elementNode in node.GetLeafEnumerator()) {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                    continue;

                bool discreteColors = ColorModule.isElementNodeDiscreteColored(elementNode);

                for (int i = 1;i<(int)(TimeSpan.TotalMilliseconds/Spacing);i++)
                {
                    int startAudioTime;
                    int endAudioTime;
                    if (Inverted)
                    {
                        startAudioTime = i * Spacing - (nodeCount-currentElement) * ((WaveformData)Data).ScrollSpeed + 1;
                        endAudioTime = (i + 1) * Spacing - (nodeCount-currentElement) * ((WaveformData)Data).ScrollSpeed;
                    }
                    else
                    {
                        startAudioTime = i * Spacing - currentElement * ((WaveformData)Data).ScrollSpeed + 1;
                        endAudioTime = (i + 1) * Spacing - currentElement * ((WaveformData)Data).ScrollSpeed;
                    }
                    TimeSpan startTime = TimeSpan.FromMilliseconds(i * Spacing);

                    if (startAudioTime > 0 && startAudioTime < TimeSpan.TotalMilliseconds && endAudioTime > 0 && endAudioTime < TimeSpan.TotalMilliseconds)
                    {

                        double gradientPosition1 = (AudioUtilities.VolumeAtTime(startAudioTime) + Data.Range) / Data.Range;
                        double gradientPosition2 = (AudioUtilities.VolumeAtTime(endAudioTime) + Data.Range) / Data.Range;

                        //Some odd corner cases
                        if (gradientPosition1 <= 0)
                            gradientPosition1 = 0;
                        if (gradientPosition1 >= 1)
                            gradientPosition1 = 1;

                        //Some odd corner cases
                        if (gradientPosition2 <= 0)
                            gradientPosition2 = 0;
                        if (gradientPosition2 >= 1)
                            gradientPosition2 = 1;

                        ElementData.Add(GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition1, gradientPosition2, TimeSpan.FromMilliseconds(Spacing), startTime, discreteColors));

                    }
                }
                currentElement++;
            }
        }
コード例 #17
0
ファイル: ColorProperty.cs プロジェクト: nedbert/vixen
 public static bool isElementNodeTreeDiscreteColored(ElementNode element)
 {
     return(element.GetLeafEnumerator().Any(x => isElementNodeDiscreteColored(x)));
 }
コード例 #18
0
 private bool IsPixelStar(ElementNode selectedNode)
 {
     return(!selectedNode.IsLeaf && selectedNode.GetLeafEnumerator().Count() >= 2);
 }
コード例 #19
0
ファイル: VerticalMeter.cs プロジェクト: priyanr/Vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        protected override void RenderNode(ElementNode node)
        {
            int currentElement = 0;

            int elementCount = node.GetLeafEnumerator().Count();

            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                {
                    continue;
                }

                if (!AudioUtilities.AudioLoaded)
                {
                    return;
                }
                bool discreteColors = ColorModule.isElementNodeDiscreteColored(elementNode);
                var  lastTime       = TimeSpan.FromMilliseconds(0);

                double gradientPosition = (double)(currentElement) / elementCount;

                //Audio max is at 0db. The threshold gets shifted from 0 to 1 to -1 to 0 and then scaled.
                double threshold;
                if (!((VerticalMeterData)Data).Inverted)
                {
                    threshold        = (((double)(elementCount - currentElement)) / elementCount - 1) * Data.Range;
                    gradientPosition = 1 - gradientPosition;
                }
                else
                {
                    threshold = (((double)currentElement) / elementCount - 1) * Data.Range;
                }

                var lastValue = AudioUtilities.VolumeAtTime(0) >= threshold;

                TimeSpan start;
                for (int i = 1; i < (int)(TimeSpan.TotalMilliseconds / Spacing); i++)
                {
                    //Current time in ms = i*spacing
                    var currentValue = AudioUtilities.VolumeAtTime(i * Spacing) >= threshold;

                    if (currentValue != lastValue)
                    {
                        start = lastTime;

                        if (lastValue)
                        {
                            var effectIntents = GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition,
                                                                      gradientPosition, TimeSpan.FromMilliseconds(i * Spacing) - lastTime, start, discreteColors);
                            ElementData.Add(effectIntents);
                        }

                        lastTime  = TimeSpan.FromMilliseconds(i * Spacing);
                        lastValue = currentValue;
                    }
                }

                if (lastValue)
                {
                    start = lastTime;
                    var effectIntents = GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition,
                                                              gradientPosition, TimeSpan - lastTime, start, discreteColors);
                    ElementData.Add(effectIntents);
                }

                currentElement++;
            }
        }
コード例 #20
0
ファイル: ElementModeling.cs プロジェクト: robness/Vixen
        public static void ElementsToSvg(ElementNode elementNode)
        {
            if (elementNode == null)
            {
                return;
            }
            var leafNodes = elementNode.GetLeafEnumerator().Distinct();

            if (leafNodes.All(x => x.Properties.Contains(LocationDescriptor._typeId)))
            {
                var locations = leafNodes.Select(LocationModule.GetPositionForElement);
                var rect      = CalculateModelRectangle(locations);
                var scale     = 1f;
                if (rect.Width < 800)
                {
                    scale = 800f / rect.Width;
                }
                SvgDocument doc = new SvgDocument {
                    Width = rect.Width * scale, Height = rect.Height * scale
                };
                doc.ViewBox = new SvgViewBox(-20, -20, doc.Width + 40, doc.Height + 40);

                var group = new SvgGroup();
                doc.Children.Add(group);

                if (leafNodes.All(x => x.Properties.Contains(OrderDescriptor.ModuleId)))
                {
                    leafNodes = OrderNodes(leafNodes, elementNode);
                }

                var lastPoint = new PointF();
                var first     = true;
                var radius    = 6;
                int counter   = 1;
                foreach (var node in leafNodes)
                {
                    var point = ScalePoint(LocationModule.GetPositionForElement(node), scale, rect.Location);

                    var lightNode = CreateLightNode(point, radius);
                    group.Children.Add(lightNode);
                    int order;
                    if (node.Properties.Get(OrderDescriptor.ModuleId) is OrderModule orderModule)
                    {
                        order = orderModule.Order;
                    }
                    else
                    {
                        order = counter;
                    }

                    var label = CreateLabel(order, point, radius);
                    group.Children.Add(label);

                    if (!first)
                    {
                        var line = CreateLine(lastPoint, point, radius);
                        group.Children.Add(line);
                    }
                    first     = false;
                    lastPoint = point;
                    counter++;
                }

                //var stream = new FileStream(@"C:\Test\circle.svg", FileMode.Create);
                var file     = System.IO.Path.GetTempFileName();
                var filePath = System.IO.Path.ChangeExtension(file, "svg");
                //var filePath = $"{file}{System.IO.Path.PathSeparator}{nodes.First()}.svg";
                doc.Write(filePath);
                System.Diagnostics.Process.Start(filePath);
            }
        }
コード例 #21
0
ファイル: VerticalMeter.cs プロジェクト: jaredb7/vixen
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        protected override void RenderNode(ElementNode node)
        {
            int currentElement = 0;

            int elementCount = node.GetLeafEnumerator().Count();

               foreach (ElementNode elementNode in node.GetLeafEnumerator()) {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                    continue;

                if (!AudioUtilities.AudioLoaded)
                    return;
                bool discreteColors = ColorModule.isElementNodeDiscreteColored(elementNode);
                var lastTime = TimeSpan.FromMilliseconds(0);

                double gradientPosition = (double)(currentElement) / elementCount;

                //Audio max is at 0db. The threshold gets shifted from 0 to 1 to -1 to 0 and then scaled.
                double threshold;
                if (!((VerticalMeterData)Data).Inverted)
                {
                    threshold = (((double)(elementCount - currentElement)) / elementCount - 1) * Data.Range;
                    gradientPosition = 1 - gradientPosition;
                }
                else
                {
                    threshold = (((double)currentElement) / elementCount - 1) * Data.Range;

                }

               var lastValue = AudioUtilities.VolumeAtTime(0) >= threshold;

                TimeSpan start;
                for(int i = 1;i<(int)(TimeSpan.TotalMilliseconds/Spacing);i++)
                {
                    //Current time in ms = i*spacing
                    var currentValue = AudioUtilities.VolumeAtTime(i * Spacing) >= threshold;

                    if( currentValue != lastValue) {
                        start = lastTime;

                        if(lastValue)
                        {
                            var effectIntents = GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition,
                                gradientPosition, TimeSpan.FromMilliseconds(i*Spacing) - lastTime, start, discreteColors);
                            ElementData.Add(effectIntents);
                        }

                        lastTime = TimeSpan.FromMilliseconds(i * Spacing);
                        lastValue = currentValue;
                    }
                }

                if (lastValue)
                {
                    start = lastTime;
                    var effectIntents = GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition,
                                gradientPosition, TimeSpan - lastTime, start, discreteColors);
                    ElementData.Add(effectIntents);
                }

                currentElement++;
            }
        }
コード例 #22
0
ファイル: Alternating.cs プロジェクト: jaredb7/vixen
        //(Numbers represent color/curve pairs, rows are elements columns are intervals)
        //12341234
        //23412341
        //34123412
        //41234123
        //An offset of 2
        //12341234
        //34123412
        //12341234
        //34123412
        //Offset 3
        //12341234
        //41234123
        //23412341
        //12341234
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private EffectIntents RenderNode(ElementNode node)
        {
            EffectIntents effectIntents = new EffectIntents();
            int intervals = 1;
            var gradientLevelItem = 0;
            var startIndexOffset = 0;
            //make local hold variables to prevent changes in the middle of rendering.
            int group = GroupLevel;
            var skip = IntervalSkipCount;
            int colorCount = Colors.Count();
            //Use a single pulse to do our work, we don't need to keep creating it and then thowing it away making the GC work
            //hard for no reason.

            if (!EnableStatic)
            {
                intervals = Convert.ToInt32(Math.Ceiling(TimeSpan.TotalMilliseconds/Interval));
            }

            var startTime = TimeSpan.Zero;
            var nodes = node.GetLeafEnumerator();

            var intervalTime = intervals == 1
                    ? TimeSpan
                    : TimeSpan.FromMilliseconds(Interval);

            for (int i = 0; i < intervals; i++)
            {
                var elements = nodes.Select((x, index) => new { x, index })
                    .GroupBy(x => x.index / group, y => y.x);

                foreach (IGrouping<int, ElementNode> elementGroup in elements)
                {
                    var glp = Colors[gradientLevelItem];
                    foreach (var element in elementGroup)
                    {
                        RenderElement(glp, startTime, intervalTime, element, effectIntents);
                    }
                    gradientLevelItem = ++gradientLevelItem % colorCount;

                }

                startIndexOffset = (skip+startIndexOffset) % colorCount;
                gradientLevelItem = startIndexOffset;

                startTime += intervalTime;
            }

            return effectIntents;
        }
コード例 #23
0
ファイル: SetLevel.cs プロジェクト: stewmc/vixen
		// renders the given node to the internal ElementData dictionary. If the given node is
		// not a element, will recursively descend until we render its elements.
		private void RenderNode(ElementNode node)
		{
			foreach (ElementNode elementNode in node.GetLeafEnumerator()) {
				LightingValue lightingValue = new LightingValue(Color, (float) IntensityLevel);
				IIntent intent = new LightingIntent(lightingValue, lightingValue, TimeSpan);
				_elementData.AddIntentForElement(elementNode.Element.Id, intent, TimeSpan.Zero);
			}
		}