/// <summary>
        /// init
        /// </summary>
        /// <param name="functionDict"></param>
        public void Init(DictionaryOperand functionDict)
        {
            var domainArray    = functionDict.Dictionary.GetArray(EpsKeys.Domain);
            var functionsArray = functionDict.Dictionary.GetArray(EpsKeys.Functions);
            var encodeArray    = functionDict.Dictionary.GetArray(EpsKeys.Encode);

            var e0 = OperandHelper.GetRealValue(encodeArray.Values[0].Operand);
            var e1 = OperandHelper.GetRealValue(encodeArray.Values[1].Operand);

            // It doesn't make sense to revert only one function
            // we assume either none or all functions are reverted
            reverse = e0 > e1;

            var boundsArray = functionDict.Dictionary.GetArray(EpsKeys.Bounds);

            bounds = OperandHelper.GetRealValues(boundsArray);
            bounds.Insert(0, OperandHelper.GetRealValue(domainArray.Values[0].Operand));
            bounds.Add(OperandHelper.GetRealValue(domainArray.Values[1].Operand));

            functions = new List <IFunction>();

            for (int i = 0; i < functionsArray.Values.Count; i++)
            {
                var fDict    = (DictionaryOperand)functionsArray.Values[i].Operand;
                var function = FunctionActivator.CreateFunction(fDict);
                functions.Add(function);
            }
        }
Beispiel #2
0
        public override void Execute(EpsInterpreter interpreter)
        {
            var operandStack = interpreter.OperandStack;

            var operand2 = operandStack.Pop();
            var operand1 = operandStack.Pop();

            var integer1 = operand1 as IntegerOperand;
            var integer2 = operand2 as IntegerOperand;

            if (integer1 != null && integer2 != null)
            {
                var res = new IntegerOperand();
                res.Value = integer1.Value / integer2.Value;
                operandStack.Push(res);
            }
            else
            {
                var double1 = OperandHelper.GetRealValue(operand1);
                var double2 = OperandHelper.GetRealValue(operand2);

                var res = new RealOperand();
                res.Value = double1 / double2;
                operandStack.Push(res);
            }
        }
Beispiel #3
0
        public override void Execute(EpsInterpreter interpreter)
        {
            var operandStack = interpreter.OperandStack;

            var op = operandStack.Pop();

            if (op is ArrayOperand arrayOperand)
            {
                var matrix = OperandHelper.GetMatrix(arrayOperand);
                var transY = operandStack.PopRealValue();
                var transX = operandStack.PopRealValue();

                var point = matrix.Transform(new Point(transX, transY));

                operandStack.Push(new RealOperand(point.X));
                operandStack.Push(new RealOperand(point.Y));
            }
            else
            {
                var transY = OperandHelper.GetRealValue(op);
                var transX = operandStack.PopRealValue();

                var ctm   = interpreter.GraphicState.TransformationMatrix;
                var point = ctm.Transform(new Point(transX, transY));

                operandStack.Push(new RealOperand(point.X));
                operandStack.Push(new RealOperand(point.Y));
            }
        }
        public override void Execute(EpsInterpreter interpreter)
        {
            var operandStack = interpreter.OperandStack;

            var op = operandStack.Pop();

            if (op is ArrayOperand arrayOperand)
            {
                var matrix = OperandHelper.GetMatrix(arrayOperand);
                var transY = operandStack.PopRealValue();
                var transX = operandStack.PopRealValue();

                matrix.Invert();
                var vector = matrix.Transform(new Vector(transX, transY));

                operandStack.Push(new RealOperand(vector.X));
                operandStack.Push(new RealOperand(vector.Y));
            }
            else
            {
                var transY = OperandHelper.GetRealValue(op);
                var transX = operandStack.PopRealValue();

                var ctm    = interpreter.GraphicState.TransformationMatrix;
                var matrix = new Matrix(ctm.M11, ctm.M12, ctm.M21, ctm.M22, ctm.OffsetX, ctm.OffsetY);
                matrix.Invert();
                var vector = matrix.Transform(new Point(transX, transY));

                operandStack.Push(new RealOperand(vector.X));
                operandStack.Push(new RealOperand(vector.Y));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Constructor
        /// </summary>
        public RGBDeviceBrushDescriptor(List <Operand> operands)
        {
            values = new List <double>();

            values.Add(OperandHelper.GetRealValue(operands[0]));
            values.Add(OperandHelper.GetRealValue(operands[1]));
            values.Add(OperandHelper.GetRealValue(operands[2]));
        }
Beispiel #6
0
        public override void Execute(EpsInterpreter interpreter)
        {
            var operandStack = interpreter.OperandStack;

            var topOperand   = operandStack.Pop();
            var graphicState = interpreter.GraphicState;
            var ctm          = graphicState.CurrentTransformationMatrix;
            var geometry     = new GraphicPathGeometry();

            switch (topOperand)
            {
            case IntegerOperand integerOperand:
            case RealOperand realOperand:
            {
                var height = OperandHelper.GetRealValue(topOperand);
                var width  = operandStack.PopRealValue();
                var y      = operandStack.PopRealValue();
                var x      = operandStack.PopRealValue();

                AddRectangle(geometry, x, y, width, height, ctm);
                break;
            }

            case ArrayOperand arrayOperand:
            {
                for (int i = 0; i < arrayOperand.Values.Count; i += 4)
                {
                    var x      = OperandHelper.GetRealValue(arrayOperand.Values[i].Operand);
                    var y      = OperandHelper.GetRealValue(arrayOperand.Values[i + 1].Operand);
                    var height = OperandHelper.GetRealValue(arrayOperand.Values[i + 2].Operand);
                    var width  = OperandHelper.GetRealValue(arrayOperand.Values[i + 3].Operand);

                    AddRectangle(geometry, x, y, width, height, ctm);
                }
                break;
            }

            case StringOperand stringOperand:
            {
                var values = HomogeneousNumberArrayDecoder.Decode(stringOperand);

                for (int i = 0; i < values.Count; i += 4)
                {
                    var x      = values[i];
                    var y      = values[i + 1];
                    var height = values[i + 2];
                    var width  = values[i + 3];

                    AddRectangle(geometry, x, y, width, height, ctm);
                }

                break;
            }
            }

            ClipHelper.SetClip(interpreter, geometry);
            interpreter.ResetCurrentGeometry();
        }
Beispiel #7
0
        /// <summary>
        /// init
        /// </summary>
        /// <param name="functionDict"></param>
        public void Init(DictionaryOperand functionDict)
        {
            var domainArray = functionDict.Dictionary.GetArray(EpsKeys.Domain);
            var c0Array     = functionDict.Dictionary.GetArray(EpsKeys.C0);
            var c1Array     = functionDict.Dictionary.GetArray(EpsKeys.C1);

            //var rangeArray = functionDict.Dictionary.GetArray(EpsKeys.Range);
            //var n = functionDict.Dictionary.GetInteger(EpsKeys.N);

            domain0 = OperandHelper.GetRealValue(domainArray.Values[0].Operand);
            domain1 = OperandHelper.GetRealValue(domainArray.Values[1].Operand);

            c0 = OperandHelper.GetRealValues(c0Array);
            c1 = OperandHelper.GetRealValues(c1Array);
        }
Beispiel #8
0
        /// <summary>
        /// Sets the dash pattern
        /// </summary>
        private void SetDashPattern(GraphicsState graphicState, double dashPhase, ArrayOperand dashArray)
        {
            if (dashArray.Values.Count == 0)
            {
                graphicState.Dashes     = null;
                graphicState.DashOffset = 0;
                return;
            }

            var dashes = new List <double>();

            foreach (var val in dashArray.Values)
            {
                var dbl = MatrixUtilities.TransformScale(OperandHelper.GetRealValue(val.Operand), graphicState.CurrentTransformationMatrix);
                dashes.Add(dbl);
            }

            graphicState.Dashes     = dashes;
            graphicState.DashOffset = dashPhase;
        }
Beispiel #9
0
        /// <summary>
        /// init
        /// </summary>
        /// <param name="functionDict"></param>
        public void Init(DictionaryOperand functionDict)
        {
            var domainArray = functionDict.Dictionary.GetArray(EpsKeys.Domain);
            //var rangeArray = functionDict.Dictionary.GetArray(EpsKeys.Range);
            //var encodeArray = functionDict.Dictionary.GetArray(EpsKeys.Encode);
            var decodeArray   = functionDict.Dictionary.GetArray(EpsKeys.Decode);
            var sizeArray     = functionDict.Dictionary.GetArray(EpsKeys.Size);
            var dataSource    = functionDict.Dictionary.GetString(EpsKeys.DataSource);
            var bitsPerSample = functionDict.Dictionary.GetInteger(EpsKeys.BitsPerSample);

            domain0 = OperandHelper.GetRealValue(domainArray.Values[0].Operand);
            domain1 = OperandHelper.GetRealValue(domainArray.Values[1].Operand);

            var decodes = OperandHelper.GetRealValues(decodeArray);
            var size    = (IntegerOperand)sizeArray.Values[0].Operand;
            var data    = RelativeSamplesDecoder.Decode(dataSource, bitsPerSample.Value);

            int valuesPerSample = data.Count / size.Value;

            c0 = GetSample(data, 0, valuesPerSample, decodes);
            c1 = GetSample(data, (data.Count - valuesPerSample), valuesPerSample, decodes);
        }
Beispiel #10
0
        public override void Execute(EpsInterpreter interpreter)
        {
            var operandStack = interpreter.OperandStack;

            var op = operandStack.Pop();

            if (op is ArrayOperand arrayOperand)
            {
                var matrix = OperandHelper.GetMatrix(arrayOperand);
                var scaleY = operandStack.PopRealValue();
                var scaleX = operandStack.PopRealValue();

                matrix.Scale(scaleX, scaleY);

                var array = new ArrayOperand();
                array.Values.Add(new OperandProxy(new RealOperand(matrix.M11)));
                array.Values.Add(new OperandProxy(new RealOperand(matrix.M12)));
                array.Values.Add(new OperandProxy(new RealOperand(matrix.M21)));
                array.Values.Add(new OperandProxy(new RealOperand(matrix.M22)));
                array.Values.Add(new OperandProxy(new RealOperand(matrix.OffsetX)));
                array.Values.Add(new OperandProxy(new RealOperand(matrix.OffsetY)));

                operandStack.Push(array);
            }
            else
            {
                var scaleY = OperandHelper.GetRealValue(op);
                var scaleX = operandStack.PopRealValue();

                GraphicsState graphicState = interpreter.GraphicState;

                var ctm = graphicState.TransformationMatrix;
                ctm.Scale(scaleX, scaleY);
                graphicState.TransformationMatrix = ctm;
            }
        }
Beispiel #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 public GrayBrushDescriptor(Operand operand)
 {
     gray = OperandHelper.GetRealValue(operand);
 }