コード例 #1
0
ファイル: NameOperand.cs プロジェクト: Egaros/ShapeConverter
        public override void Execute(EpsInterpreter interpreter)
        {
            if (!IsExecutable)
            {
                interpreter.OperandStack.Push(Copy());
            }
            else
            {
                var name = new NameOperand(this.Value);
                var op   = DictionaryStackHelper.FindValue(interpreter.DictionaryStack, name);

                if (op != null)
                {
                    interpreter.Execute(op);
                }
            }
        }
コード例 #2
0
ファイル: ArrayOperand.cs プロジェクト: Egaros/ShapeConverter
        /// <summary>
        /// Execute the operands
        /// </summary>
        /// <param name="interpreter"></param>
        public override void Execute(EpsInterpreter interpreter)
        {
            if (!IsExecutable || interpreter.BreakCurrentLoop)
            {
                return;
            }

            foreach (var op in Values)
            {
                interpreter.Execute(op.Operand);

                if (interpreter.BreakCurrentLoop)
                {
                    break;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Run the given formula with the given parameters
        /// </summary>
        /// <param name="script"></param>
        public List <double> RunFormula(string script, List <double> parameters)
        {
            List <double> results = null;

            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(script);
            var    ms    = new MemoryStream(bytes);

            var scriptStream = new StreamReader(ms);

            try
            {
                var interpreter  = new EpsInterpreter();
                var operandStack = interpreter.OperandStack;

                foreach (var parameter in parameters)
                {
                    operandStack.Push(new RealOperand(parameter));
                }

                interpreter.Run(scriptStream, 3);

                results = new List <double>();

                while (operandStack.Count > 0)
                {
                    results.Add(operandStack.PopRealValue());
                }

                results.Reverse();
            }
            catch
            {
            }

            scriptStream.Dispose();
            ms.Dispose();

            return(results);
        }
コード例 #4
0
        /// <summary>
        /// Init
        /// </summary>
        public void Init(EpsInterpreter interpreter, ArrayOperand colorSpaceDetails)
        {
            this.interpreter       = interpreter;
            this.colorSpaceDetails = colorSpaceDetails;

            var colorSpaceOp = colorSpaceDetails.Values[1].Operand;

            baseColorSpace = ColorSpaceActivator.CreateColorSpace(interpreter, colorSpaceOp);
            hival          = ((IntegerOperand)colorSpaceDetails.Values[2].Operand).Value;

            switch (colorSpaceDetails.Values[3].Operand)
            {
            case StringOperand stringOperand:
                useProcedure = false;
                hexString    = stringOperand.Value;
                break;

            case ArrayOperand arrayOperand:
                useProcedure = true;
                tintTransformationProcedure = arrayOperand;
                break;
            }
        }
コード例 #5
0
        /// <summary>
        /// Create a color space
        /// </summary>
        public static IColorSpace CreateColorSpace(EpsInterpreter interpreter, Operand colorSpaceOperand)
        {
            string       colorSpaceName    = null;
            ArrayOperand colorSpaceDetails = null;

            switch (colorSpaceOperand)
            {
            case NameOperand nameOperand:
            {
                colorSpaceName = nameOperand.Value;
                break;
            }

            case ArrayOperand arrayOperand:
            {
                colorSpaceName    = OperandHelper.GetStringValue(arrayOperand.Values[0].Operand);
                colorSpaceDetails = arrayOperand;
                break;
            }
            }

            return(CreateColorSpace(interpreter, colorSpaceName, colorSpaceDetails));
        }
コード例 #6
0
 /// <summary>
 /// Init
 /// </summary>
 public void Init(EpsInterpreter interpreter, ArrayOperand colorSpaceDetails)
 {
     this.colorSpaceDetails = colorSpaceDetails;
 }
コード例 #7
0
 /// <summary>
 /// Init
 /// </summary>
 public void Init(EpsInterpreter interpreter, ArrayOperand colorSpaceArray)
 {
 }
コード例 #8
0
        /// <summary>
        /// Create a color space
        /// </summary>
        public static IColorSpace CreateColorSpace(EpsInterpreter interpreter, string colorSpaceName, ArrayOperand colorSpaceDetails = null)
        {
            IColorSpace colorSpace = null;

            switch (colorSpaceName)
            {
            case EpsKeys.DeviceRGB:
            {
                colorSpace = new RGBDeviceColorSpace();
                break;
            }

            case EpsKeys.DeviceCMYK:
            {
                colorSpace = new CMYKDeviceColorSpace();
                break;
            }

            case EpsKeys.DeviceGray:
            {
                colorSpace = new GrayDeviceColorSpace();
                break;
            }

            case EpsKeys.DevicePattern:
            {
                colorSpace = new PatternColorSpace();
                break;
            }

            case EpsKeys.Separation:
            case EpsKeys.DeviceN:
            {
                colorSpace = new DeviceNColorSpace();
                break;
            }

            case EpsKeys.Indexed:
            {
                colorSpace = new IndexedColorSpace();
                break;
            }

            case EpsKeys.CIEBasedABC:
            {
                colorSpace = new UnknownColorSpace(3);
                break;
            }

            case EpsKeys.CIEBasedA:
            {
                colorSpace = new UnknownColorSpace(1);
                break;
            }

            default:
            {
                colorSpace = new UnknownColorSpace(1);
                break;
            }
            }

            colorSpace.Init(interpreter, colorSpaceDetails);

            return(colorSpace);
        }