Example #1
0
        /// <summary>
        /// Adds the given color to the collection of named colors that are used
        /// in the generation of other Kimono Objects. If a color is already in
        /// the collection, its `ElementName` is returned.
        /// </summary>
        /// <returns>The `ElementName` for the supporting color.</returns>
        /// <param name="color">The `KimonoColor` to add to the collection.</param>
        public static string AddSupportingColor(KimonoColor color)
        {
            // Is there a supporting color?
            if (color.BaseColor != null)
            {
                // Yes, add it to the supporting colors first
                AddSupportingColor(color.BaseColor);
            }

            // Scan all colors
            foreach (KimonoColor supportColor in SupportingColors)
            {
                // Already in collection?
                if (supportColor == color)
                {
                    return(supportColor.ElementName);
                }
            }

            // Generate element name and add to collection
            color.ElementName = MakeElementName(color.Name);
            SupportingColors.Add(color);

            // Return the new element name
            return(color.ElementName);
        }
Example #2
0
        /// <summary>
        /// Clone this instance.
        /// </summary>
        /// <returns>The clone.</returns>
        public KimonoColor Clone()
        {
            // Duplicate color
            var newColor = new KimonoColor()
            {
                UniqueID              = this.UniqueID,
                _baseColor            = this._baseColor,
                Name                  = this.Name,
                Hue                   = this.Hue,
                Saturation            = this.Saturation,
                Brightness            = this.Brightness,
                Alpha                 = this.Alpha,
                _adjustHue            = this._adjustHue,
                _adjustSaturation     = this._adjustSaturation,
                _adjustBrightness     = this._adjustBrightness,
                _adjustAlpha          = this._adjustAlpha,
                _hueAdjustment        = this._hueAdjustment,
                _saturationAdjustment = this._saturationAdjustment,
                _brightnessAdjustment = this._brightnessAdjustment,
                _alphaAdjustment      = this._alphaAdjustment,
                _color                = CloneColor(this._color)
            };

            // Clone any property connections
            foreach (KimonoPropertyConnection connection in PropertyConnections)
            {
                // Add duplicate connection
                newColor.PropertyConnections.Add(connection.Clone());
            }

            // Return new instance
            return(newColor);
        }
Example #3
0
        /// <summary>
        /// Updates a `KimonoPropertyConnectionPoint` on this `KimonoColor` with the results
        /// of a Obi Script run on an attached `KimonoProperty`.
        /// </summary>
        /// <param name="connection">Connection.</param>
        public virtual void UpdatePropertyConnectionPoint(KimonoPropertyConnection connection)
        {
            // Take action based on the connection point
            switch (connection.ConnectionPoint)
            {
            case KimonoPropertyConnectionPoint.BaseColor:
                _baseColor = connection.ConnectedProperty.ToColor();
                break;

            case KimonoPropertyConnectionPoint.AdjustsHue:
                _adjustHue = connection.ConnectedProperty.ToBool();
                break;

            case KimonoPropertyConnectionPoint.HueAdjustment:
                _hueAdjustment = connection.ConnectedProperty.ToFloat();
                break;

            case KimonoPropertyConnectionPoint.AdjustsSaturation:
                _adjustSaturation = connection.ConnectedProperty.ToBool();
                break;

            case KimonoPropertyConnectionPoint.SaturationAdjustment:
                _saturationAdjustment = connection.ConnectedProperty.ToFloat();
                break;

            case KimonoPropertyConnectionPoint.AdjustsBrightness:
                _adjustBrightness = connection.ConnectedProperty.ToBool();
                break;

            case KimonoPropertyConnectionPoint.BrightnessAdjustment:
                _brightnessAdjustment = connection.ConnectedProperty.ToFloat();
                break;

            case KimonoPropertyConnectionPoint.AdjustsAlpha:
                _adjustAlpha = connection.ConnectedProperty.ToBool();
                break;

            case KimonoPropertyConnectionPoint.AlphaAdjustment:
                _alphaAdjustment = connection.ConnectedProperty.ToInt();
                break;
            }
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:KimonoCore.KimonoColor"/> class.
 /// </summary>
 /// <param name="baseColor">Base color.</param>
 public KimonoColor(KimonoColor baseColor)
 {
     // Initialize
     BaseColor = baseColor;
 }