Beispiel #1
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 #2
0
 public override void Execute(EpsInterpreter interpreter)
 {
     ClipHelper.SetClip(interpreter, interpreter.GraphicState.CurrentGeometry);
 }