public void SetState(PathBarButtonState state) { if (this.state != state) { this.state = state; CommonWindow.Current.Invalidate(); } switch (state) { case PathBarButtonState.Normal: innerGradient = Theme.Colors.PathBarButtonNormal; outline = Theme.Colors.PathBarButtonOutlineNormal; break; case PathBarButtonState.Hover: innerGradient = Theme.Colors.PathBarButtonHover; outline = Theme.Colors.PathBarButtonOutlineHover; break; case PathBarButtonState.Press: innerGradient = Theme.Colors.PathBarButtonPress; outline = Theme.Colors.PathBarButtonOutlinePress; break; } }
protected override void SetColorGradientValue(ColorGradient cg) { if (cg != null) { Value = cg; } }
/// <summary> /// Constructor /// </summary> public MorphData() { Orientation = StringOrientation.Horizontal; PolygonType = PolygonType.Pattern; PolygonFillType = PolygonFillType.Wipe; RepeatCount = 0; RepeatDirection = WipeRepeatDirection.Up; RepeatSkip = 0; Stagger = 0; HeadDuration = 20; // Percent HeadLength = 4; HeadColor = new ColorGradient(System.Drawing.Color.White); TailColor = new ColorGradient(System.Drawing.Color.Red); Acceleration = 0; FillColor = new ColorGradient(System.Drawing.Color.Red); FillPolygon = true; MorphPolygonData = new List <MorphPolygonData>(); DisplayElementWidth = 0; DisplayElementHeight = 0; // Default the brightness to 100% TailBrightness = new Curve(CurveType.Flat100); HeadBrightness = new Curve(CurveType.Flat100); FillBrightness = new Curve(CurveType.Flat100); }
protected override void SetColorGradientValue(ColorGradient cg) { if (cg != null) { Value = new GradientLevelPair(cg, Value.Curve); } }
private void GenerateExtendedStaticPulse(ElementNode target, Curve newCurve, ColorGradient gradient, TimeSpan duration, TimeSpan offset) { var result = PulseRenderer.RenderNode(target, newCurve, gradient, duration, HasDiscreteColors); result.OffsetAllCommandsByTime(offset); _elementData.Add(result); }
protected override void UpdateLeftToRightBar() { while (fillPieces.Count < MaxValue) { CreateFillPiece(); } for (int i = 0; i < fillPieces.Count; i++) { fillPieces[i].gameObject.SetActive(i < MaxValue); if (i < Value) { fillPieces[i].color = ColorGradient.Evaluate(0f); } else if (i < MaxValue && i < Value + PreviewValue) { fillPieces[i].color = PreviewColor; } else if (i < MaxValue) { fillPieces[i].color = UnfilledColor; } } }
// 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); } } } }
public EmitterData() { ParticleType = ParticleSerializationType.Water; UseColorArray = false; FramesPerColor = 3; Color = new ColorGradient(System.Drawing.Color.Blue); Lifetime = new Curve(CurveType.Flat100); ParticleVelocity = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 50.0, 50.0 })); Animate = false; EdgeHandling = EdgeHandlingSerializationType.Bounce; VelocityX = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 10.0, 10.0 })); VelocityY = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 10.0, 10.0 })); // X and Y are used when the emitter is not animated X = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 50.0, 50.0 })); Y = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 90.0, 90.0 })); ManualFlow = true; Flow = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 10.0, 10.0 })); SourceSize = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 0.0, 0.0 })); NozzleMovement = NozzleMovementSerializationType.FixedAngle; NozzleAngle = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 75.0, 75.0 })); OscillateStartAngle = 0; OscillateEndAngle = 90; OscillationSpeed = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 5.0, 5.0 })); FlowControl = FlowControlSerializationType.Continuous; MarkCollectionId = Guid.Empty; OnTime = 2000; // Milliseconds OffTime = 2000; // Milliseconds }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var width = 300; var height = 30; var isDiscrete = false; if (parameter != null) { isDiscrete = System.Convert.ToBoolean(parameter); } //if (editable) //{ // width = 300; // height = 30; //} if (value is ColorGradient) { ColorGradient colorGradient = (ColorGradient)value; return(BitmapImageConverter.BitmapToMediaImage(colorGradient.GenerateColorGradientImage(new Size(width, height), isDiscrete))); } return (BitmapImageConverter.BitmapToMediaImage( new ColorGradient(Color.DimGray).GenerateColorGradientImage(new Size(width, height), false))); }
/// <summary> /// Convienience method to generate intents that knows how to deal with discrete colors. /// </summary> /// <param name="node"></param> /// <param name="gradient"></param> /// <param name="level"></param> /// <param name="startPos"></param> /// <param name="endPos"></param> /// <param name="duration"></param> /// <param name="startTime"></param> /// <param name="isDiscrete"></param> /// <returns></returns> protected EffectIntents GenerateEffectIntents(ElementNode node, ColorGradient gradient, Curve level, double startPos, double endPos, TimeSpan duration, TimeSpan startTime, bool isDiscrete) { EffectIntents result = new EffectIntents(); if (isDiscrete) { IEnumerable <Color> colors = ColorModule.getValidColorsForElementNode(node, false) .Intersect(gradient.GetColorsInGradient()); foreach (Color color in colors) { double proportion = gradient.GetProportionOfColorAt(startPos, color); var startIntensity = (level.GetValue(startPos * 100) / 100) * proportion; proportion = gradient.GetProportionOfColorAt(endPos, color); var endIntensity = (level.GetValue(endPos * 100) / 100) * proportion; if (startIntensity > 0 && endIntensity > 0) { var intent = CreateDiscreteIntent(color, startIntensity, endIntensity, duration); result.AddIntentForElement(node.Element.Id, intent, startTime); } } } else { var startIntensity = level.GetValue(startPos * 100) / 100; var endIntensity = level.GetValue(endPos * 100) / 100; if (startIntensity > 0 && endIntensity > 0) { var intent = CreateIntent(gradient.GetColorAt(startPos), gradient.GetColorAt(endPos), startIntensity, endIntensity, duration); result.AddIntentForElement(node.Element.Id, intent, startTime); } } return(result); }
protected void UpdateColorGradient() { if (Data == null) { return; } switch (Data.MeterColorStyle) { case MeterColorTypes.Discrete: Color[] discreteColors = { Color.Lime, Color.Lime, Color.Yellow, Color.Yellow, Color.Red, Color.Red }; float greenPos = (float)Data.GreenColorPosition / 100; float yellowPos = (float)Data.RedColorPosition / 100; float[] DiscretePositions = { 0, greenPos, greenPos, yellowPos, yellowPos, 1 }; ColorBlend discreteBlend = new ColorBlend(); discreteBlend.Colors = discreteColors; discreteBlend.Positions = DiscretePositions; ColorGradient discreteGradient = new ColorGradient(discreteBlend); _workingGradient = discreteGradient; break; case MeterColorTypes.Linear: Color[] linearColors = { Color.Lime, Color.Yellow, Color.Red }; float[] myPositions = { 0, (float)Data.GreenColorPosition / 100, (float)Data.RedColorPosition / 100 }; ColorBlend linearBlend = new ColorBlend(); linearBlend.Colors = linearColors; linearBlend.Positions = myPositions; ColorGradient linearGradient = new ColorGradient(linearBlend); _workingGradient = linearGradient; break; case MeterColorTypes.Custom: _workingGradient = Data.MeterColorGradient; break; } }
protected override void SetupRender() { if (_scaledImage != null) { _scaledImage.Dispose(); } if (!string.IsNullOrEmpty(FileName)) { var filePath = Path.Combine(PictureDescriptor.ModulePath, FileName); if (File.Exists(filePath)) { using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { var ms = new MemoryStream(); fs.CopyTo(ms); ms.Position = 0; if (_image != null) { _image.Dispose(); } _image = Image.FromStream(ms); } } else { Logging.Error("File is missing or invalid path. {0}", filePath); } } else { var fs = typeof(Picture).Assembly.GetManifestResourceStream("VixenModules.Effect.Picture.PictureTiles." + TilePictures + ".png"); _image = Image.FromStream(fs); } if (_image != null) { _dimension = new FrameDimension(_image.FrameDimensionsList[0]); // Number of frames _frameCount = _image.GetFrameCount(_dimension); _gifSpeed = true; if (_frameCount > 1) { _gifSpeed = false; } UpdateGifSpeedAttribute(); if (Colors == null) //This will only be null for Picture effects that are already on the time line. This is due to the upgrade for the effect. { Colors = new ColorGradient(Color.DodgerBlue); Direction = 0; IncreaseBrightness = 10; GifSpeed = 1; ColorEffect = ColorEffect.None; MovementRate = 4; } } _movementX = 0.0; _movementY = 0.0; }
protected override void PopulateDefaults() { Colors.DefaultValue = ColorGradient.GetUnicornBarf(); WaveSize.DefaultValue = 100; Orientation.DefaultValue = LinearGradientOrientationMode.Horizontal; RepeatMode.DefaultValue = LinearGradientRepeatMode.Repeat; }
public VUMeterData() { DecayTime = 1500; AttackTime = 50; Normalize = true; Gain = 0; Range = 10; RedColorPosition = 95; GreenColorPosition = 25; MeterColorStyle = MeterColorTypes.Custom; LowPass = false; LowPassFreq = 100; HighPass = false; HighPassFreq = 500; IntensityCurve = new Curve(); IntensityCurve.Points.Clear(); IntensityCurve.Points.Add(new ZedGraph.PointPair(0, 0)); IntensityCurve.Points.Add(new ZedGraph.PointPair(100, 100)); ColorGradient linearGradient = new ColorGradient(Color.White); MeterColorGradient = linearGradient; DepthOfEffect = 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; }
private void MakeBasicSurface() { var editor = new SadConsole.Surfaces.SurfaceEditor(basicSurface); editor.Print(0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890".Repeat(9)); ColorGradient gradient = new ColorGradient(StarterProject.Theme.Blue, StarterProject.Theme.Yellow); for (int i = 0; i < 510; i += 10) { var point = editor.TextSurface.GetPointFromIndex(i); editor.Print(point.X, point.Y, gradient.ToColoredString(editor.GetString(i, 10))); } // Mirror 1 int startSet1 = new Point(0, 3).ToIndex(34); int startSet2 = new Point(0, 6).ToIndex(34); int startSet3 = new Point(0, 9).ToIndex(34); for (int i = 0; i < 34 * 3; i++) { basicSurface.Cells[startSet1 + i].Mirror = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically; basicSurface.Cells[startSet1 + i].Background = StarterProject.Theme.PurpleDark; basicSurface.Cells[startSet2 + i].Mirror = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally; basicSurface.Cells[startSet2 + i].Background = StarterProject.Theme.OrangeDark; basicSurface.Cells[startSet3 + i].Mirror = Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipHorizontally | Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically; basicSurface.Cells[startSet3 + i].Background = StarterProject.Theme.GreenDark; } }
private void Populate_Gradients() { listViewGradients.BeginUpdate(); listViewGradients.Items.Clear(); listViewGradients.LargeImageList = new ImageList { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(48, 48) }; foreach (KeyValuePair <string, ColorGradient> kvp in _colorGradientLibrary) { ColorGradient gradient = kvp.Value; string name = kvp.Key; var result = new Bitmap(gradient.GenerateColorGradientImage(new Size(48, 48), false), 48, 48); Graphics gfx = Graphics.FromImage(result); gfx.DrawRectangle(new Pen(Color.Black, 2), 0, 0, 48, 48); listViewGradients.LargeImageList.Images.Add(name, result); ListViewItem item = new ListViewItem(); item.Text = name; item.Name = name; item.ImageKey = name; listViewGradients.Items.Add(item); } listViewGradients.EndUpdate(); toolStripButtonEditGradient.Enabled = toolStripButtonDeleteGradient.Enabled = false; }
public static ColorGradient Create(Gradient gradient) { ColorGradient cg = _new(); cg.gradient = gradient; return(cg); }
protected override void PopulateDefaults() { Colors.DefaultValue = ColorGradient.GetUnicornBarf(); MinAndMax.DefaultValue = new FloatRange(0, 100); AutoExpandMinValue.DefaultValue = false; AutoExpandMaxValue.DefaultValue = false; }
public override IEnumerator ReceivePayload(VisualPayload payload) { var textureSize = TextureSize.GetFirstValue(payload.Data); var newTexture = new Texture2D(textureSize, textureSize); var newPixels = new Color[textureSize * textureSize]; var gradient = ColorGradient.GetFirstValue(payload.Data); for (int x = 0; x < textureSize; x++) { for (int y = 0; y < textureSize; y++) { var proportion = x / (float)textureSize; var color = gradient.Evaluate(proportion); newPixels[x + y * textureSize] = color; } } newTexture.SetPixels(newPixels); newTexture.Apply(); TextureTarget.SetValue(newTexture, payload.Data); var iterator = Router.TransmitAll(payload); while (iterator.MoveNext()) { yield return(null); } }
public MetricMapping(string metricName, BuildingProperty buildingProperty, ValueConverter valueConverter, ColorGradient colorGradient) { this.metricName = metricName; this.buildingProperty = buildingProperty; this.valueConverter = valueConverter; this.colorGradient = colorGradient; }
public static Texture2D GenerateNoiseTexture(int textureSize, int lowerOctave, int upperOctave, float persistence, ColorGradient colorGradient, int bitDepth = 64, float spectrumMultiplier = 1f) { var newTexture = new Texture2D(textureSize, textureSize); var outColors = new Color[textureSize * textureSize]; int i = 0; for (int x = 0; x < textureSize; x++) { for (int y = 0; y < textureSize; y++) { //outColors[i++] = Color.red; int xS = Mathf.FloorToInt((x / (float)textureSize) * bitDepth) * (textureSize / bitDepth); int yS = Mathf.FloorToInt((y / (float)textureSize) * bitDepth) * (textureSize / bitDepth); outColors[i++] = colorGradient.Evaluate( MultiplySpectrum( Perlin2d(xS / (float)textureSize, yS / (float)textureSize, lowerOctave, upperOctave, persistence) , spectrumMultiplier) ); } //outColors[i++] = Color.white*Mathf.PerlinNoise(5f * x / (float)TextureSize, 5f * y / (float)TextureSize), .5f, .5f) // + new Color(.5f, Mathf.PerlinNoise(50f * x / (float)TextureSize, 50f * y / (float)TextureSize), .5f); } newTexture.SetPixels(outColors); newTexture.Apply(); return(newTexture); }
public VerticalMeterData() { Inverted = false; DecayTime = 1500; AttackTime = 50; Normalize = true; Gain = 0; Range = 10; RedColorPosition = 95; GreenColorPosition = 25; MeterColorStyle = MeterColorTypes.Linear; LowPass = false; LowPassFreq = 100; HighPass = false; HighPassFreq = 500; Color[] myColors = { Color.Lime, Color.Yellow, Color.Red }; float[] myPositions = { 0, (float)GreenColorPosition / 100, (float)RedColorPosition / 100 }; ColorBlend linearBlend = new ColorBlend(); linearBlend.Colors = myColors; linearBlend.Positions = myPositions; ColorGradient linearGradient = new ColorGradient(linearBlend); IntensityCurve = new Curve(); IntensityCurve.Points.Clear(); IntensityCurve.Points.Add(new ZedGraph.PointPair(0, 100)); IntensityCurve.Points.Add(new ZedGraph.PointPair(100, 100)); MeterColorGradient = linearGradient; DepthOfEffect = 0; }
/// <summary> /// Triggered when the user double clicks the left mouse button. /// </summary> /// <param name="ev">Information about the mouse event.</param> private void OnPointerDoubleClicked(PointerEvent ev) { if (ev.IsUsed) { return; } Vector2I panelPos = ScreenToKeyEditorPos(ev.ScreenPos); Rect2I guiGradientBounds = guiGradientTexture.Bounds; if (guiGradientBounds.Contains(panelPos)) { Vector2I canvasPos = panelPos - new Vector2I(guiGradientBounds.x, guiGradientBounds.y); float time = canvasPos.x / (float)Math.Max(guiGradientBounds.width - 1, 1); if (time >= 0.0f && time <= 1.0f) { List <ColorGradientKey> keys = new List <ColorGradientKey>(gradient.GetKeys()); keys.Add(new ColorGradientKey(Color.Black, time)); keys.Sort((lhs, rhs) => lhs.time.CompareTo(rhs.time)); gradient = new ColorGradient(keys.ToArray()); UpdateTexture(); editor.Rebuild(keys); UpdateKeyLines(); } } else { editor.OnPointerDoubleClicked(panelPos, ev.Button); } }
private void cmbGradient_GradientSelected(object sender, gView.Framework.Symbology.UI.Controls.GradientSelectedEventArgs args) { if (_renderer == null || _renderer.Keys == null || _renderer.Keys.Count == 0 || args == null || args.ColorGradient == null) { return; } try { double span = _renderer.Keys.Count; ColorGradient gradient = args.ColorGradient; int i = 0; foreach (string key in _renderer.Keys) { ISymbol symbol = _renderer[key]; if (symbol is ISymbol) { Helper.AlterSymbolColor(symbol, gradient.Color1, gradient.Color2, (double)i / span); } i++; } BuildList(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exeception"); } }
public static ColorGradient Create(RGB zero, RGB hundred) { ColorGradient cg = _new(); cg.gradient = new Gradient(zero, hundred); return(cg); }
// 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. var allPointsTimeOrdered = _GetAllSignificantDataPoints(levelCurve, colorGradient); 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(elementNode)) { 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); }
public MeteorsData() { Colors = new List <ColorGradient> { new ColorGradient(Color.Red), new ColorGradient(Color.Lime), new ColorGradient(Color.Blue) }; PixelCountCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 10.0, 10.0 })); Direction = 180; SpeedVariationCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 12.0, 12.0 })); CenterSpeedCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 14.0, 14.0 })); MinDirection = 0; MaxDirection = 360; RandomBrightness = false; EnableGroundLevel = false; MeteorEffect = MeteorsEffect.None; ColorType = MeteorsColorType.Palette; LengthCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 5.0, 5.0 })); GroundLevelCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 0.0, 0.0 })); LevelCurve = new Curve(CurveType.Flat100); Orientation = StringOrientation.Vertical; GroundColor = new ColorGradient(Color.ForestGreen); MeteorPerString = false; MeteorStartPosition = MeteorStartPosition.InitiallyRandom; FlipDirection = false; CountPerString = false; XCenterSpeedCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 50.0, 50.0 })); YCenterSpeedCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 50.0, 50.0 })); XSpeedVariationCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 0.0, 0.0 })); YSpeedVariationCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 0.0, 0.0 })); MeteorMovement = MeteorMovement.None; WobbleCurve = new Curve(new PointPairList(new[] { 0.0, 33.0, 66.0, 100.0 }, new[] { 30.0, 70.0, 30.0, 70.0 })); WobbleVariationCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 10.0, 10.0 })); }
/// <inheritdoc /> public override void Render(SKCanvas canvas, SKRect bounds, SKPaint paint) { _lastBounds = bounds; // For brevity's sake ColorGradient gradient = Properties.Colors.BaseValue; SKMatrix matrix = SKMatrix.Concat( SKMatrix.CreateRotationDegrees(Properties.Rotation, bounds.MidX, bounds.MidY), SKMatrix.CreateTranslation(_scrollX, _scrollY) ); // LinearGradientRepeatMode.Mirror is currently the only setting that requires a different tile mode SKShaderTileMode tileMode = Properties.RepeatMode.CurrentValue == LinearGradientRepeatMode.Mirror ? SKShaderTileMode.Mirror : SKShaderTileMode.Repeat; // Render gradient paint.Shader = SKShader.CreateLinearGradient( new SKPoint(bounds.Left, bounds.Top), new SKPoint( (Properties.Orientation == LinearGradientOrientationMode.Horizontal ? bounds.Right : bounds.Left) * _waveSizeNormalized, (Properties.Orientation == LinearGradientOrientationMode.Horizontal ? bounds.Top : bounds.Bottom) * _waveSizeNormalized ), gradient.GetColorsArray(0, Properties.RepeatMode.CurrentValue == LinearGradientRepeatMode.RepeatSeamless), gradient.GetPositionsArray(0, Properties.RepeatMode.CurrentValue == LinearGradientRepeatMode.RepeatSeamless), tileMode, matrix ); canvas.DrawRect(bounds, paint); paint.Shader?.Dispose(); paint.Shader = null; }
private void cmbGradient_GradientSelected(object sender, gView.Framework.Symbology.UI.Controls.GradientSelectedEventArgs args) { if (_renderer == null || _renderer.QuantityClasses == null || _renderer.QuantityClasses.Count == 0 || args == null || args.ColorGradient == null) return; try { List<QuantityRenderer.QuantityClass> qClasses = _renderer.QuantityClasses; double span = qClasses[qClasses.Count - 1].Min - qClasses[0].Min; ColorGradient gradient = args.ColorGradient; for (int i = 0; i < qClasses.Count; i++) { if (qClasses[i] == null) return; double fac = (span == 0.0) ? 0.0 : (qClasses[i].Min - qClasses[0].Min) / span; Helper.AlterSymbolColor(qClasses[i].Symbol, gradient.Color1, gradient.Color2, fac); } BuildList(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exeception"); } }
private async void Button_Start(object sender, RoutedEventArgs e) { try { List <ControlPoint> list = GetControlPoints(); ColorGradient colorGradient = new ColorGradient(list); int iterations; if (((TextBlock)ComboBox_Iter.SelectedItem).Text == "Custom") { iterations = Convert.ToInt32(TextBox_CustomIter.Text); } else { iterations = Convert.ToInt32(((TextBlock)ComboBox_Iter.SelectedItem).Text); } GoMandelbrot( Convert.ToDouble(textbox_xpos.Text.Replace('.', ',')), Convert.ToDouble(textbox_ypos.Text.Replace('.', ',')), Convert.ToDouble(textbox_width.Text.Replace('.', ',')), Convert.ToInt32(textbox_res.Text), iterations, colorGradient); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//Validate that the we are using valid colors and set appropriate defaults if not. private void CheckForInvalidColorData() { // check for sane default colors when first rendering it HashSet <Color> validColors = new HashSet <Color>(); validColors.AddRange(TargetNodes.SelectMany(x => ColorModule.getValidColorsForElementNode(x, true))); //Validate Color 1 if (validColors.Any() && (!validColors.Contains(_data.Color1.ToArgb()) || !_data.ColorGradient1.GetColorsInGradient().IsSubsetOf(validColors))) { Color1 = validColors.First(); ColorGradient1 = new ColorGradient(validColors.First()); } //Validate color 2 if (validColors.Any() && (!validColors.Contains(_data.Color2.ToArgb()) || !_data.ColorGradient2.GetColorsInGradient().IsSubsetOf(validColors))) { if (validColors.Count > 1) { Color2 = validColors.ElementAt(1); ColorGradient2 = new ColorGradient(validColors.ElementAt(1)); } else { Color2 = validColors.First(); ColorGradient2 = new ColorGradient(validColors.First()); } } }
private void DrawTextAcrossGradient(IEnumerable <String> textLines, Graphics g, Point p, LinearGradientMode mode) { int i = 0; foreach (var text in textLines) { var size = g.MeasureString(text, _newfont); var offset = _maxTextSize - (int)size.Width; var offsetPoint = new Point(p.X + offset / 2, p.Y); ColorGradient cg = Colors[i % Colors.Count()]; var brush = new LinearGradientBrush(new Rectangle(0, 0, BufferWi, BufferHt), Color.Black, Color.Black, mode) { InterpolationColors = cg.GetColorBlend() }; DrawTextWithBrush(text, brush, g, CenterText ? offsetPoint : p); brush.Dispose(); p.Y += (int)size.Height; if (TextMode == TextMode.Normal) { i++; } else { if (text == Environment.NewLine) { i++; } } } }
public ChaseData() { ColorHandling = ChaseColorHandling.StaticColor; PulseOverlap = 0; DefaultLevel = 0; StaticColor = Color.White; ColorGradient = new ColorGradient(); PulseCurve = new Curve(); ChaseMovement = new Curve(); }
public GumpGradient(int x, int y, int width, int height, Direction45 dirTo, ColorGradient gradient) { _X = x; _Y = y; _Width = width; _Height = height; _Direction = dirTo; _Gradient = gradient; }
public ColorGradientEditor(ColorGradient gradient, bool discreteColors, IEnumerable<Color> validDiscreteColors) { InitializeComponent(); Icon = Common.Resources.Properties.Resources.Icon_Vixen3; gradientEditPanel.GradientChanged += GradientChangedHandler; Gradient = gradient; _discreteColors = discreteColors; _validDiscreteColors = validDiscreteColors; PopulateFormWithGradient(_gradient); }
public CurtainData() { Gradient = new ColorGradient(); Gradient.Colors.Clear(); Gradient.Colors.Add(new ColorPoint(Color.Red, 0.0)); Gradient.Colors.Add(new ColorPoint(Color.Lime, 1.0)); Direction = CurtainDirection.CurtainOpen; Speed = 1; Edge = CurtainEdge.Center; Swag = 1; LevelCurve = new Curve(CurveType.Flat100); Orientation=StringOrientation.Vertical; }
public ChaseData() { ColorHandling = ChaseColorHandling.StaticColor; PulseOverlap = 0; DefaultLevel = 0; StaticColor = Color.White; ColorGradient = new ColorGradient(Color.White); PulseCurve = new Curve(); ChaseMovement = new Curve(); DepthOfEffect = 0; ExtendPulseToStart = false; ExtendPulseToEnd = false; }
public WipeData() { Curve = new Curve(); Curve.Points.Clear(); Curve.Points.Add(0, 0); Curve.Points.Add(50, 100); Curve.Points.Add(100, 0); Direction = WipeDirection.Right; ColorGradient = new ColorGradient(Color.White); PulseTime = 1000; WipeByCount = false; PassCount = 1; PulsePercent = 33; }
public ColorGradientEditor(ColorGradient gradient, bool discreteColors, IEnumerable<Color> validDiscreteColors) { InitializeComponent(); ForeColor = ThemeColorTable.ForeColor; BackColor = ThemeColorTable.BackgroundColor; ThemeUpdateControls.UpdateControls(this); Icon = Resources.Icon_Vixen3; gradientEditPanel.GradientChanged += GradientChangedHandler; Gradient = gradient; _discreteColors = discreteColors; _validDiscreteColors = validDiscreteColors; PopulateFormWithGradient(_gradient); }
public TwinkleData() { IndividualChannels = true; MinimumLevel = 0; MaximumLevel = 100; LevelVariation = 50; AveragePulseTime = 400; PulseTimeVariation = 30; AverageCoverage = 50; ColorHandling = TwinkleColorHandling.GradientForEachPulse; StaticColor = Color.Empty; ColorGradient = new ColorGradient(Color.White); DepthOfEffect = 0; }
public ColorWashData() { Gradient = new ColorGradient(); Gradient.Colors.Clear(); Gradient.Colors.Add(new ColorPoint(Color.Red, 0.0)); Gradient.Colors.Add(new ColorPoint(Color.Lime, .5)); Gradient.Colors.Add(new ColorPoint(Color.Blue, 1.0)); Type = ColorWashType.Center; Iterations = 1; VerticalFade = false; HorizontalFade = false; LevelCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 100.0, 100.0 })); Orientation=StringOrientation.Vertical; }
public TreeData() { Colors = new List<ColorGradient>{new ColorGradient(Color.Red), new ColorGradient(Color.Lime), new ColorGradient(Color.Blue)}; BackgroundColor = new ColorGradient(Color.Red); ColorType = TreeColorType.Static; BranchDirection = TreeBranchDirection.Up; Speed = 10; ToggleBlend = true; Branches = 10; LevelCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 100.0, 100.0 })); BlendCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 70.0, 70.0 })); BackgroundLevelCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 70.0, 70.0 })); Orientation=StringOrientation.Vertical; }
public AlternatingData() { Level1 = 1; Level2 = 1; Color1 = Color.White; Color2 = Color.Red; Enable = true; Interval = 500; DepthOfEffect = 0; GroupEffect = 1; StaticColor1 = StaticColor2 = true; ColorGradient1 = new ColorGradient(Color.White); ColorGradient2 = new ColorGradient(Color.Red); Curve1 = new Curve(); Curve2 = new Curve(); }
public ButterflyData() { Gradient = new ColorGradient(); Gradient.Colors.Clear(); Gradient.Colors.Add(new ColorPoint(Color.Red,0.0)); Gradient.Colors.Add(new ColorPoint(Color.Lime, 1.0)); Iterations = 1; ColorScheme = ColorScheme.Gradient; ButterflyType = ButterflyType.Type1; Repeat = 1; BackgroundSkips = 2; BackgroundChunks = 1; Direction = Direction.Forward; LevelCurve = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { 100.0, 100.0 })); Orientation=StringOrientation.Vertical; }
public SpinData() { SpeedFormat = SpinSpeedFormat.RevolutionCount; PulseLengthFormat = SpinPulseLengthFormat.EvenlyDistributedAcrossSegments; ColorHandling = SpinColorHandling.StaticColor; RevolutionCount = 3; RevolutionFrequency = 2; RevolutionTime = 500; PulseTime = 100; PulsePercentage = 10; DefaultLevel = 0; StaticColor = Color.White; ColorGradient = new ColorGradient(); PulseCurve = new Curve(); ReverseSpin = false; }
public ShockwaveData() { Gradient = new ColorGradient(); Gradient.Colors.Clear(); Gradient.Colors.Add(new ColorPoint(Color.Red,0.0)); Gradient.Colors.Add(new ColorPoint(Color.Lime, .5)); Gradient.Colors.Add(new ColorPoint(Color.Blue, 1.0)); StartWidth = 5; EndWidth = 10; StartRadius = 1; EndRadius = 10; CenterX = 50; CenterY = 50; Acceleration = 0; BlendEdges = true; Orientation=StringOrientation.Vertical; }
private static void AddIntentsToElement(Element element, double[] allPointsTimeOrdered, Curve levelCurve, ColorGradient colorGradient, TimeSpan duration, EffectIntents elementData, bool allowZeroIntensity, Color? color = null) { if (element != null) { double lastPosition = allPointsTimeOrdered[0]; TimeSpan lastEnd = TimeSpan.Zero; for (var i = 1; i < allPointsTimeOrdered.Length; i++) { double position = allPointsTimeOrdered[i]; TimeSpan startTime = lastEnd; TimeSpan timeSpan = TimeSpan.FromMilliseconds(duration.TotalMilliseconds * (position - lastPosition)); if (color == null) { var startColor = colorGradient.GetColorAt(lastPosition); var endColor = colorGradient.GetColorAt(position); var startIntensity = levelCurve.GetValue(lastPosition * 100) / 100; var endIntensity = levelCurve.GetValue(position * 100) / 100; if (allowZeroIntensity || !(startIntensity.Equals(0) && endIntensity.Equals(0))) { IIntent intent = IntentBuilder.CreateIntent(startColor, endColor, startIntensity, endIntensity, timeSpan); elementData.AddIntentForElement(element.Id, intent, startTime); } } else { var startIntensity = (colorGradient.GetProportionOfColorAt(lastPosition, (Color)color) * levelCurve.GetValue(lastPosition * 100) / 100); var endIntensity = (colorGradient.GetProportionOfColorAt(position, (Color)color) * levelCurve.GetValue(position * 100) / 100); if (allowZeroIntensity || !(startIntensity.Equals(0) && endIntensity.Equals(0))) { IIntent intent = IntentBuilder.CreateDiscreteIntent((Color)color, startIntensity, endIntensity, timeSpan); elementData.AddIntentForElement(element.Id, intent, startTime); } } lastPosition = position; lastEnd = startTime + timeSpan; } } }
private void PopulateFormWithGradient(ColorGradient item) { gradientEditPanel.Gradient = item; gradientEditPanel.DiscreteColors = _discreteColors; gradientEditPanel.ValidDiscreteColors = _validDiscreteColors; // if we're editing one from the library, treat it special if (item.IsCurrentLibraryGradient) { if (LibraryItemName == null) { labelCurve.Text = "This gradient is a library gradient."; Text = "Color Gradient Editor: Library Gradient"; } else { labelCurve.Text = string.Format("This gradient is the library gradient: {0}", LibraryItemName); Text = string.Format("Color Gradient Editor: Library Gradient {0}", LibraryItemName); } gradientEditPanel.ReadOnly = false; buttonSaveToLibrary.Enabled = false; buttonLoadFromLibrary.Enabled = false; buttonUnlink.Enabled = false; buttonEditLibraryItem.Enabled = false; } else { if (item.IsLibraryReference) { labelCurve.Text = string.Format("This gradient is linked to the library: {0}", item.LibraryReferenceName); } else { labelCurve.Text = "This gradient is not linked to any in the library."; } gradientEditPanel.ReadOnly = item.IsLibraryReference; buttonSaveToLibrary.Enabled = !item.IsLibraryReference; buttonLoadFromLibrary.Enabled = true; buttonUnlink.Enabled = item.IsLibraryReference; buttonEditLibraryItem.Enabled = item.IsLibraryReference; Text = @"Color Gradient Editor"; } gradientEditPanel.Invalidate(); }
private void timelineControl_GradientDropped(object sender, ToolDropEventArgs e) { List<Element> elementList = new List<Element>(); if (e.Element.Selected) elementList = TimelineControl.SelectedElements.ToList(); else elementList.Add(e.Element); ColorGradient droppedGradient = _colorGradientLibrary.GetColorGradient(e.Data.GetData(DataFormats.StringFormat).ToString()); foreach (Element elem in elementList) { ColorGradient gradient = new ColorGradient(droppedGradient); if (ToolsForm.LinkGradients) { gradient.LibraryReferenceName = e.Data.GetData(DataFormats.StringFormat).ToString(); } else { gradient.LibraryReferenceName = string.Empty; gradient.UnlinkFromLibrary(); } gradient.IsCurrentLibraryGradient = false; object[] parms = elem.EffectNode.Effect.ParameterValues; switch (elem.EffectNode.Effect.EffectName) { case "Alternating": if (e.MouseButton == MouseButtons.Right || Control.ModifierKeys.HasFlag(Keys.Control)) { parms[9] = false; parms[11] = gradient; } else { parms[8] = false; parms[10] = gradient; } break; case "Pulse": parms[1] = gradient; break; case "Chase": parms[0] = ToolsForm.GradientHandling; parms[4] = gradient; break; case "Spin": parms[2] = ToolsForm.GradientHandling; parms[10] = gradient; break; case "Twinkle": parms[7] = ToolsForm.GradientHandling; parms[9] = gradient; break; case "Wipe": parms[0] = gradient; break; } elem.EffectNode.Effect.ParameterValues = parms; TimelineControl.grid.RenderElement(elem); } sequenceModified(); }
private void buttonLoadFromLibrary_Click(object sender, EventArgs e) { ColorGradientLibrarySelector selector = new ColorGradientLibrarySelector(); if (selector.ShowDialog() == System.Windows.Forms.DialogResult.OK && selector.SelectedItem != null) { // make a new curve that references the selected library curve, and set it to the current Curve ColorGradient newGradient = new ColorGradient(selector.SelectedItem.Item2); newGradient.LibraryReferenceName = selector.SelectedItem.Item1; newGradient.IsCurrentLibraryGradient = false; Gradient = newGradient; } }
public override void Dispose() { _Gradient = null; base.Dispose(); }
private void listViewGradient_ItemDrag(object sender, ItemDragEventArgs e) { //StartGradientDrag(this, e); ColorGradient newGradient = new ColorGradient((ColorGradient)listViewGradients.SelectedItems[0].Tag); if (LinkGradients) { newGradient.LibraryReferenceName = listViewGradients.SelectedItems[0].Name; } newGradient.IsCurrentLibraryGradient = false; listViewGradients.DoDragDrop(newGradient, DragDropEffects.Copy); }
private void AddGradientToLibrary(ColorGradient cg, bool edit = true) { Common.Controls.TextDialog dialog = new Common.Controls.TextDialog("Gradient name?"); while (dialog.ShowDialog() == DialogResult.OK) { if (dialog.Response == string.Empty) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Please enter a name.", "Warning", false, false); messageBox.ShowDialog(); continue; } if (_colorGradientLibrary.Contains(dialog.Response)) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Warning; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("There is already a gradient with that name. Do you want to overwrite it?", "Overwrite gradient?", true, true); messageBox.ShowDialog(); if (messageBox.DialogResult == DialogResult.OK) { _colorGradientLibrary.AddColorGradient(dialog.Response, cg); if (edit) { _colorGradientLibrary.EditLibraryItem(dialog.Response); } break; } if (messageBox.DialogResult == DialogResult.Cancel) { break; } } else { _colorGradientLibrary.AddColorGradient(dialog.Response, cg); if (edit) { _colorGradientLibrary.EditLibraryItem(dialog.Response); } break; } } }
//Validate that the we are using valid colors and set appropriate defaults if not. private void CheckForInvalidColorData() { // check for sane default colors when first rendering it HashSet<Color> validColors = new HashSet<Color>(); validColors.AddRange(TargetNodes.SelectMany(x => ColorModule.getValidColorsForElementNode(x, true))); //Validate Color 1 if (validColors.Any() && (!validColors.Contains(_data.Color1.ToArgb()) || !_data.ColorGradient1.GetColorsInGradient().IsSubsetOf(validColors))) { Color1 = validColors.First(); ColorGradient1 = new ColorGradient(validColors.First()); } //Validate color 2 if (validColors.Any() && (!validColors.Contains(_data.Color2.ToArgb()) || !_data.ColorGradient2.GetColorsInGradient().IsSubsetOf(validColors))) { if (validColors.Count > 1) { Color2 = validColors.ElementAt(1); ColorGradient2 = new ColorGradient(validColors.ElementAt(1)); } else { Color2 = validColors.First(); ColorGradient2 = new ColorGradient(validColors.First()); } } }
private void timelineControl_ColorDropped(object sender, ToolDropEventArgs e) { List<Element> elementList = new List<Element>(); if (e.Element.Selected) elementList = TimelineControl.SelectedElements.ToList(); else elementList.Add(e.Element); Color color = (Color)e.Data.GetData(typeof(Color)); foreach (Element elem in elementList) { object[] parms = elem.EffectNode.Effect.ParameterValues; switch (elem.EffectNode.Effect.EffectName) { case "Alternating": if (e.MouseButton == MouseButtons.Right || Control.ModifierKeys.HasFlag(Keys.Control)) { parms[3] = color; parms[9] = true; } else { parms[1] = color; parms[8] = true; } break; case "Set Level": parms[1] = color; break; case "Pulse": parms[1] = new ColorGradient(color); break; case "Chase": parms[0] = 0; // StaticColor parms[3] = color; break; case "Spin": parms[2] = 0; // StaticColor parms[9] = color; break; case "Twinkle": parms[7] = 0; // StaticColor parms[8] = color; break; case "Wipe": parms[0] = new ColorGradient(color); break; } //TODO: //this would be a good place to build a list of target elements, and the new parameters //list could be passed to a ModifyElements method to do the work in "one step" elem.EffectNode.Effect.ParameterValues = parms; TimelineControl.grid.RenderElement(elem); } sequenceModified(); }
//Switch statements are the best method at this time for these methods private void ApplyColorGradientToEffects(String LibraryReferenceName, ColorGradient colorGradient) { bool strayElement = false; foreach (Element elem in TimelineControl.SelectedElements) { ColorGradient newColorGradient = new ColorGradient(colorGradient); newColorGradient.LibraryReferenceName = LibraryReferenceName; newColorGradient.IsCurrentLibraryGradient = false; string effectName = elem.EffectNode.Effect.EffectName; object[] parms = new object[elem.EffectNode.Effect.ParameterValues.Count()]; Array.Copy(elem.EffectNode.Effect.ParameterValues, parms, parms.Count()); switch (effectName) { case "Alternating": case "Candle Flicker": case "Custom Value": case "LipSync": case "Nutcracker": case "Set Level": case "Launcher": case "RDS": strayElement = true; break; case "Pulse": parms[1] = newColorGradient; break; case "Chase": parms[0] = 1; //GradientThroughWholeEffect; parms[4] = newColorGradient; break; case "Spin": parms[2] = 1; //GradientThroughWholeEffect; parms[10] = newColorGradient; break; case "Twinkle": parms[7] = 1; //GradientThroughWholeEffect; parms[9] = newColorGradient; break; case "Wipe": parms[0] = newColorGradient; break; } elem.EffectNode.Effect.ParameterValues = parms; TimelineControl.grid.RenderElement(elem); } sequenceModified(); if (strayElement) MessageBox.Show("One or more effects were selected that do not support color gradients.\nAll effects that do were updated."); }
private void ApplyColorCollection(ColorCollection Collection, bool RandomOrder) { if (!Collection.Color.Any()) return; bool strayElement = false; Color thisColor, thisColor2 = Color.White; int iPos = 0; foreach (Element elem in TimelineControl.SelectedElements) { string effectName = elem.EffectNode.Effect.EffectName; object[] parms = new object[elem.EffectNode.Effect.ParameterValues.Count()]; List<Color> validColors = new List<Color>(); Array.Copy(elem.EffectNode.Effect.ParameterValues, parms, parms.Count()); validColors.AddRange(elem.EffectNode.Effect.TargetNodes.SelectMany(x => ColorModule.getValidColorsForElementNode(x, true))); if (RandomOrder) { int r1 = rnd.Next(Collection.Color.Count()); int r2 = rnd.Next(Collection.Color.Count()); int n = 0; while (r1 == r2 && n <= 5) { r2 = rnd.Next(Collection.Color.Count()); n++; } thisColor = Collection.Color[r1]; thisColor2 = Collection.Color[r2]; } else { if (iPos == Collection.Color.Count()) { iPos = 0; } thisColor = Collection.Color[iPos]; iPos++; if (effectName == "Alternating") { thisColor2 = Collection.Color[iPos]; iPos++; } } if (validColors.Any() && !validColors.Contains(thisColor)) { thisColor = validColors[rnd.Next(validColors.Count())]; } if (effectName == "Alternate") { if (validColors.Any() && !validColors.Contains(thisColor2)) { thisColor2 = validColors[rnd.Next(validColors.Count())]; } int n2 = 0; while (thisColor2 == thisColor && n2 <= 5) { thisColor2 = validColors[rnd.Next(validColors.Count())]; n2++; } } switch (effectName) { case "Candle Flicker": case "LipSync": case "Nutcracker": case "Launcher": case "RDS": strayElement = true; break; case "Custom Value": //Disabled until we fix the custom value null reference errors - not related to this. //parms[0] = 4; //Set it to a type of color value //parms[5] = thisColor; strayElement = true; break; case "Alternating": parms[1] = thisColor; parms[3] = thisColor2; parms[8] = parms[9] = true; break; case "Set Level": parms[1] = thisColor; break; case "Pulse": parms[1] = new ColorGradient(thisColor); break; case "Chase": parms[0] = 0; // StaticColor parms[3] = thisColor; break; case "Spin": parms[2] = 0; // StaticColor parms[9] = thisColor; break; case "Twinkle": parms[7] = 0; // StaticColor parms[8] = thisColor; break; case "Wipe": parms[0] = new ColorGradient(thisColor); break; } elem.EffectNode.Effect.ParameterValues = parms; TimelineControl.grid.RenderElement(elem); } sequenceModified(); if (strayElement) MessageBox.Show("One or more effects were selected that do not support curves.\nAll effects that do were updated."); }
//Validate that the we are using valid colors and set appropriate defaults if not. private void CheckForInvalidColorData() { var validColors = GetValidColors(); if (validColors.Any()) { if (!Data.MeterColorGradient.GetColorsInGradient().IsSubsetOf(validColors)) { //Our color is not valid for any elements we have. //Try to set a default color gradient from our available colors if (validColors.Count > 1) { //Try to make some kind of transitions List<float> positions = new List<float>(validColors.Count); positions.AddRange(validColors.Select((t, i) => i/(float) (validColors.Count - 1))); ColorBlend linearBlend = new ColorBlend(); linearBlend.Colors = validColors.ToArray(); linearBlend.Positions = positions.ToArray(); MeterColorGradient = new ColorGradient(linearBlend); } else { MeterColorGradient = new ColorGradient(validColors.First()); } } //ensure we are using Custom and we can't change it. We are limited in discrete color mode MeterColorStyle = MeterColorTypes.Custom; EnableColorTypesSelection(false); } else { EnableColorTypesSelection(true); } }
public override void Compose() { if (this.IsDirty) { this.Fill(Color.White, Color.Black, 0, null); _positions = Width; ColorGradient gradient = new ColorGradient(Color.Red, Color.Yellow, Color.Green, Color.Turquoise, Color.Blue, Color.Purple, Color.Red); for (int x = 0; x < Width; x++) { this[x, 0].GlyphIndex = 219; this[x, 0].Foreground = gradient.Lerp((float)x / (float)(Width - 1)); } this[_selectedPosition, 1].GlyphIndex = 30; this[_selectedPosition, 1].Foreground = Color.LightGray;//this[_selectedPosition, 0].Foreground; // Build an array of all the colors Color[] colors = new Color[Width]; for (int x = 0; x < Width; x++) colors[x] = this[x, 0].Foreground; List<int> colorIndexesFinished = new List<int>(Width); foreach (var stop in gradient.Stops) { ColorMine.ColorSpaces.Rgb rgbColorStop = new ColorMine.ColorSpaces.Rgb() { R = stop.Color.R, G = stop.Color.G, B = stop.Color.B }; Tuple<Color, double, int>[] colorWeights = new Tuple<Color, double, int>[Width]; // Create a color weight for every cell compared to the color stop for (int x = 0; x < Width; x++) { if (!colorIndexesFinished.Contains(x)) { ColorMine.ColorSpaces.Rgb rgbColor = new ColorMine.ColorSpaces.Rgb() { R = colors[x].R, G = colors[x].G, B = colors[x].B }; ColorMine.ColorSpaces.Cmy cmyColor = rgbColor.To<ColorMine.ColorSpaces.Cmy>(); colorWeights[x] = new Tuple<Color, double, int>(colors[x], rgbColorStop.Compare(cmyColor, new ColorMine.ColorSpaces.Comparisons.Cie1976Comparison()), x); } else colorWeights[x] = new Tuple<Color, double, int>(colors[x], 10000, x); } var foundColor = colorWeights.OrderBy(t => t.Item2).First(); this[foundColor.Item3, 0].Foreground = stop.Color; colorIndexesFinished.Add(foundColor.Item3); } this.IsDirty = false; } }