Example #1
0
        /// <summary>
        /// Gets the color.
        /// </summary>
        public static ColorSpaceColor GetColor(StructureDescriptor colorDescriptor)
        {
            ColorSpaceColor colorBase = null;

            var colorSpace = colorDescriptor.ClassId;

            switch (colorSpace)
            {
            case "RGBC":
                colorBase = GetRgbColor(colorDescriptor);
                break;

            case "CMYC":
                colorBase = GetCmykColor(colorDescriptor);
                break;

            case "LbCl":
                colorBase = GetLabColor(colorDescriptor);
                break;

            case "Grsc":
                colorBase = GetGrayColor(colorDescriptor);
                break;

            default:
                colorBase = GetUnknownColor();
                break;
            }

            return(colorBase);
        }
Example #2
0
        public override StructureBehavior Initialize(StructureDescriptor programming, IOwner owner, GridCoordinate coordinate)
        {
            base.Initialize(programming, owner, coordinate);

            _cellReference = owner.AssociatedGrid[coordinate];
            return(this);
        }
Example #3
0
        protected override void ReadData(PsdReader reader, object userData)
        {
            var vstkDescriptor = new StructureDescriptor(reader, true);
            var strokeStyleContentDescriptor = (StructureDescriptor)vstkDescriptor.Items["strokeStyleContent"];

            switch (strokeStyleContentDescriptor.ClassId)
            {
            case "solidColorLayer":
            {
                Color = ColorReader.GetSolidColor(strokeStyleContentDescriptor);
                break;
            }

            case "gradientLayer":
            {
                Color = ColorReader.GetLinearGradientColor(strokeStyleContentDescriptor);
                break;
            }

            case "patternLayer":
            {
                var solidColor = new SolidColor();
                solidColor.Color = ColorReader.GetUnknownColor();
                Color            = solidColor;
                break;
            }
            }

            var slwv = (StructureUnitFloat)vstkDescriptor.Items["strokeStyleLineWidth"];

            WidthUnit = slwv.Unit;
            Width     = slwv.Value;
        }
Example #4
0
        /// <summary>
        /// Ready a gray color
        /// </summary>
        private static ColorGray GetGrayColor(StructureDescriptor colorDescriptor)
        {
            var gray = (double)((StructureDouble)colorDescriptor.Items["Gry"]).Value;

            return(new ColorGray {
                Gray = gray
            });
        }
Example #5
0
        /// <summary>
        /// Gets a linear gradient definition.
        /// </summary>
        public static RadialGradientColor GetRadialGradientColor(StructureDescriptor descriptor)
        {
            var radialGradientColor = new RadialGradientColor();

            radialGradientColor.GradientStops = GetGradientColor(descriptor, radialGradientColor);

            return(radialGradientColor);
        }
 public void Setup()
 {
     _layout = ScriptableObject.CreateInstance <WorldLayout>();
     _layout.Resize(new GridBasedSize(3, 3));
     _structure1 = ScriptableObject.CreateInstance <StructureDescriptor>();
     _structure2 = ScriptableObject.CreateInstance <StructureDescriptor>();
     _structure3 = ScriptableObject.CreateInstance <StructureDescriptor>();
 }
Example #7
0
        /// <summary>
        /// Ready a Lab color
        /// </summary>
        private static ColorLab GetLabColor(StructureDescriptor colorDescriptor)
        {
            var L = (double)((StructureDouble)colorDescriptor.Items["Lmnc"]).Value;
            var A = (double)((StructureDouble)colorDescriptor.Items["A"]).Value;
            var B = (double)((StructureDouble)colorDescriptor.Items["B"]).Value;

            return(new ColorLab {
                L = L, A = A, B = B
            });
        }
Example #8
0
        /// <summary>
        /// Gets a linear gradient definition.
        /// </summary>
        public static LinearGradientColor GetLinearGradientColor(StructureDescriptor descriptor)
        {
            var linearGradientColor = new LinearGradientColor();

            linearGradientColor.GradientStops = new List <GradientColorStop>();

            linearGradientColor.GradientStops = GetGradientColor(descriptor, linearGradientColor);

            return(linearGradientColor);
        }
Example #9
0
        /// <summary>
        /// Gets a solid color definition from a descriptor that contains a Clr definition.
        /// </summary>
        public static SolidColor GetSolidColor(StructureDescriptor descriptor)
        {
            var colorDescriptor = (StructureDescriptor)descriptor.Items["Clr"];

            var solidColor = new SolidColor();

            solidColor.Color = GetColor(colorDescriptor);

            return(solidColor);
        }
Example #10
0
        /// <summary>
        /// Read an RGB color
        /// </summary>
        private static ColorRGB GetRgbColor(StructureDescriptor colorDescriptor)
        {
            var red   = (int)((StructureDouble)colorDescriptor.Items["Rd"]).Value;
            var green = (int)((StructureDouble)colorDescriptor.Items["Grn"]).Value;
            var blue  = (int)((StructureDouble)colorDescriptor.Items["Bl"]).Value;

            return(new ColorRGB {
                R = red, G = green, B = blue
            });
        }
Example #11
0
        /// <summary>
        /// Get a the gradient color definition
        /// </summary>
        private static List <GradientColorStop> GetGradientColor(StructureDescriptor descriptor, GradientColor gradientColor)
        {
            StructureItem item = null;

            if (descriptor.Items.TryGetValue(ref item, "Angl"))
            {
                var anglDesc = (StructureUnitFloat)item;
                gradientColor.Angle = anglDesc.Value;
            }

            if (descriptor.Items.TryGetValue(ref item, "Rvrs"))
            {
                var rvrsDesc = (StructureBool)item;
                gradientColor.IsReverse = rvrsDesc.Value;
            }

            if (descriptor.Items.TryGetValue(ref item, "Scl"))
            {
                var sclDesc = (StructureUnitFloat)item;
                gradientColor.Scale = sclDesc.Value;
            }
            else
            {
                gradientColor.Scale = 100;
            }

            var gradDesc = (StructureDescriptor)descriptor.Items["Grad"];

            var intrDescriptor = (StructureDouble)gradDesc.Items["Intr"];

            gradientColor.MaxPosition = intrDescriptor.Value;

            var clrsDesc = (StructureList)gradDesc.Items["Clrs"];
            List <GradientColorStop> stops = new List <GradientColorStop>();

            foreach (var clrtItem in clrsDesc.Items)
            {
                var clrtDesc = (StructureDescriptor)clrtItem;

                GradientColorStop stop = new GradientColorStop();
                stops.Add(stop);

                var colorDescriptor = (StructureDescriptor)clrtDesc.Items["Clr"];
                stop.Color = GetColor(colorDescriptor);

                var positionDescriptor = (StructureLong)clrtDesc.Items["Lctn"];
                stop.Position = positionDescriptor.Value;

                var mdpnDescriptor = (StructureLong)clrtDesc.Items["Mdpn"];
                stop.MiddlePoint = mdpnDescriptor.Value;
            }

            return(stops);
        }
Example #12
0
        /// <summary>
        /// Ready a CMYK color
        /// </summary>
        public static ColorCMYK GetCmykColor(StructureDescriptor colorDescriptor)
        {
            var c = (double)(((StructureDouble)colorDescriptor.Items["Cyn"]).Value);
            var m = (double)(((StructureDouble)colorDescriptor.Items["Mgnt"]).Value);
            var y = (double)(((StructureDouble)colorDescriptor.Items["Ylw"]).Value);
            var k = (double)(((StructureDouble)colorDescriptor.Items["Blck"]).Value);

            return(new ColorCMYK {
                C = c, M = m, Y = y, K = k
            });
        }
Example #13
0
        protected override void ReadData(PsdReader reader, object userData)
        {
            reader.ValidateType("plcL", "LayerResource PlLd");
            var Version     = reader.ReadInt32();
            var UniqueID    = reader.ReadPascalString(1);
            var PageNumbers = reader.ReadInt32();
            var Pages       = reader.ReadInt32();
            var AntiAlias   = reader.ReadInt32();
            var LayerType   = reader.ReadInt32();

            Transformation = reader.ReadDoubles(8);
            reader.ValidateInt32(0, "WarpVersion");
            var Warp = new StructureDescriptor(reader);
        }
Example #14
0
        protected override void ReadData(PsdReader reader, object userData)
        {
            int count = reader.ReadInt32();

            List <StructureDescriptor> dss = new List <StructureDescriptor>();

            for (int i = 0; i < count; i++)
            {
                string s  = reader.ReadAscii(4);
                string k  = reader.ReadAscii(4);
                var    c  = reader.ReadByte();
                var    p  = reader.ReadBytes(3);
                var    l  = reader.ReadInt32();
                var    p2 = reader.Position;
                var    ds = new StructureDescriptor(reader);
                dss.Add(ds);
                reader.Position = p2 + l;
            }

            //props["Items"] = dss;
        }
Example #15
0
        private Uri ReadAboluteUri(PsdReader reader)
        {
            IProperties props = new StructureDescriptor(reader).Items;

            if (props.Contains("fullPath") == true)
            {
                Uri absoluteUri = new Uri(props["fullPath"] as string);
                if (File.Exists(absoluteUri.LocalPath) == true)
                {
                    return(absoluteUri);
                }
            }

            if (props.Contains("relPath") == true)
            {
                string relativePath = props["relPath"] as string;
                Uri    absoluteUri  = reader.Resolver.ResolveUri(reader.Uri, relativePath);
                if (File.Exists(absoluteUri.LocalPath) == true)
                {
                    return(absoluteUri);
                }
            }

            if (props.Contains("Nm") == true)
            {
                string name        = props["Nm"] as string;
                Uri    absoluteUri = reader.Resolver.ResolveUri(reader.Uri, name);
                if (File.Exists(absoluteUri.LocalPath) == true)
                {
                    return(absoluteUri);
                }
            }

            if (props.Contains("fullPath") == true)
            {
                return(new Uri(props["fullPath"] as string));
            }

            return(null);
        }
Example #16
0
        protected override void ReadData(PsdReader reader, object userData)
        {
            var colorDescriptor = new StructureDescriptor(reader, true);
            var typeDesc        = (StructureEnumerate)colorDescriptor.Items["Type"];

            switch (typeDesc.Value)
            {
            // linear
            case "Lnr ":
            {
                Color = ColorReader.GetLinearGradientColor(colorDescriptor);
                break;
            }

            // radial
            case "Rdl ":
            {
                Color = ColorReader.GetRadialGradientColor(colorDescriptor);
                break;
            }

            // angle
            case "Angl":

            //reflected
            case "Rflc":

            // diamand
            case "Dmnd":
            default:
            {
                var solid = new SolidColor();
                Color = solid;

                solid.Color = ColorReader.GetUnknownColor();
                break;
            }
            }
        }
        protected override void ReadData(PsdReader reader, object userData)
        {
            int version = reader.ReadInt32();

            if (version == 6)
            {
                var    r1    = reader.ReadInt32();
                var    r2    = reader.ReadInt32();
                var    r3    = reader.ReadInt32();
                var    r4    = reader.ReadInt32();
                string text  = reader.ReadString();
                var    count = reader.ReadInt32();

                List <IProperties> slices = new List <IProperties>(count);

                for (int i = 0; i < count; i++)
                {
                    slices.Add(ReadSliceInfo(reader));
                }

                this.slices = slices.ToArray();
            }

            {
                var descriptor = new StructureDescriptor(reader) as IProperties;

                var items = descriptor["slices.Items[0]"] as object[];
                List <IProperties> slices = new List <IProperties>(items.Length);

                foreach (var item in items)
                {
                    slices.Add(ReadSliceInfo(item as IProperties));
                }

                this.slices = slices.ToArray();
            }
        }
Example #18
0
 protected override void ReadData(PsdReader reader, object userData)
 {
     reader.ValidateType("soLD", "SoLd ID");
     reader.ValidateInt32(4, "SoLd Version");
     var value = new StructureDescriptor(reader, true).Items;
 }
Example #19
0
        protected override void ReadData(PsdReader reader, object userData)
        {
            var soCoDescriptor = new StructureDescriptor(reader, true);

            Color = ColorReader.GetSolidColor(soCoDescriptor);
        }
Example #20
0
 protected override void ReadData(PsdReader reader, object userData)
 {
     reader.ValidateInt32(0, "lfx2 Version");
     var value = new StructureDescriptor(reader, true).Items;
 }