public static CellArray CellArray(MetafileReader reader)
        {
            var p = reader.ReadPoint();
            var q = reader.ReadPoint();
            var r = reader.ReadPoint();

            int nx = reader.ReadInteger();
            int ny = reader.ReadInteger();

            // TODO: not really used in text encoding; but in case we ever need it,
            //       the same check for zero as in binary encoding needs to happen.
            //       intentionally unused until that time comes.
            int localColorPrecision = reader.ReadInteger();

            int totalCount = nx * ny;
            var colors     = new List <MetafileColor>();

            while (reader.HasMoreData())
            {
                colors.Add(reader.ReadColor());
            }
            // FIXME: for parenthesized lists, every row is enclosed by parenthesis (which right now are ignored by the parser).
            //        The number of cells between parentheses shall be less than or equal to the row length.
            //        If a row is not complete, then the last defined cell in the row is replicated to fill the row.
            //        Since the parser ignores parenthesis, we can only fill the last row with the last color of all rows;
            //        but not every row with the last color of each row.
            if (colors.Count < totalCount)
            {
                var lastColor = colors.Last();
                colors.AddRange(Enumerable.Range(0, totalCount - colors.Count).Select(i => lastColor));
            }
            return(new CellArray(p, q, r, nx, ny, colors.ToArray()));
        }
Esempio n. 2
0
        public static InterpolatedInterior InterpolatedInterior(MetafileReader reader)
        {
            int style             = reader.ReadIndex();
            var referenceGeometry = new List <PointF>();
            var stageDesignators  = new List <double>();
            var colorSpecifiers   = new List <MetafileColor>();

            // Legal values of the style parameter are positive integers. [ISO/IEC 8632-1 7.7.43]
            // Values greater than 3 are reserved for future standardization and registration.
            if (style >= 1 && style <= 3)
            {
                // parallel: the number of scalars shall be 2. The FILL REFERENCE POINT is one defining
                //      point of a reference line. A second defining point of the reference line is defined by
                //      the 2 scalars, which are respectively the x and y offset of the second point from the
                //      FILL REFERENCE POINT.
                // elliptical: the number of scalars shall be 4. The FILL REFERENCE POINT is the centre of a
                //      reference ellipse. The first pair of scalars are respectively the x and y offset from
                //      the FILL REFERENCE POINT to the first CDP of ellipse and the second pair are
                //      respectively the x and y offset from the FILL REFERENCE POINT to the second
                //      CDP of ellipse.
                // triangular: the number of scalars shall be 4. The first pair of scalars are respectively the x and
                //      y offset from the FILL REFERENCE POINT to the second corner of a reference
                //      triangle and the second pair are respectively the x and y offset from the FILL
                //      REFERENCE POINT to the third corner of the reference triangle. The number of
                //      stages shall be 0 and the list of stage designators shall be empty.
                int geoCount;
                if (style == 1)
                {
                    geoCount = 2;
                }
                else
                {
                    geoCount = 4;
                }
                for (int i = 0; i < geoCount / 2; i++)
                {
                    double rgX = reader.ReadSizeSpecification(reader.Descriptor.InteriorStyleSpecificationMode);
                    double rgY = reader.ReadSizeSpecification(reader.Descriptor.InteriorStyleSpecificationMode);
                    referenceGeometry.Add(new PointF((float)rgX, (float)rgY));
                }

                int numberOfStages = reader.ReadInteger();
                for (int i = 0; i < numberOfStages; i++)
                {
                    stageDesignators.Add(reader.ReadReal());
                }

                int numberOfColors = style == 3 ? 3 : numberOfStages + 1;
                for (int i = 0; i < numberOfColors; i++)
                {
                    colorSpecifiers.Add(reader.ReadColor());
                }
            }
            return(new InterpolatedInterior(style, referenceGeometry.ToArray(), stageDesignators.ToArray(), colorSpecifiers.ToArray()));
        }
Esempio n. 3
0
        public static PatternTable PatternTable(MetafileReader reader)
        {
            int index = reader.ReadIndex();
            int nx    = reader.ReadInteger();
            int ny    = reader.ReadInteger();
            // TODO: not really used in text encoding; but in case we ever need it,
            //       the same check for zero as in binary encoding needs to happen.
            //       intentionally unused until that time comes.
            int localColorPrecision = reader.ReadInteger();
            var colors = new List <MetafileColor>();
            int count  = nx * ny;

            while (reader.HasMoreData(3) && count-- > 0)
            {
                colors.Add(reader.ReadColor());
            }

            return(new PatternTable(index, nx, ny, colors.ToArray()));
        }
 public static AuxiliaryColor AuxiliaryColor(MetafileReader reader)
 {
     return(new AuxiliaryColor(reader.ReadColor()));
 }
Esempio n. 5
0
 public static TextColor TextColor(MetafileReader reader)
 {
     return(new TextColor(reader.ReadColor()));
 }
Esempio n. 6
0
 public static MarkerColor MarkerColor(MetafileReader reader)
 {
     return(new MarkerColor(reader.ReadColor()));
 }
Esempio n. 7
0
 public static LineColor LineColor(MetafileReader reader)
 {
     return(new LineColor(reader.ReadColor()));
 }
Esempio n. 8
0
 public static EdgeColor EdgeColor(MetafileReader reader)
 {
     return(new EdgeColor(reader.ReadColor()));
 }
Esempio n. 9
0
 public static FillColor FillColor(MetafileReader reader)
 {
     return(new FillColor(reader.ReadColor()));
 }