示例#1
0
        public static PdfShading SimpleRadial(PdfWriter writer, float x0, float y0, float r0, float x1, float y1, float r1, Color startColor, Color endColor, bool extendStart, bool extendEnd)
        {
            CheckCompatibleColors(startColor, endColor);
            PdfFunction function = PdfFunction.Type2(writer, new float[] { 0, 1 }, null, GetColorArray(startColor),
                                                     GetColorArray(endColor), 1);

            return(Type3(writer, startColor, new float[] { x0, y0, r0, x1, y1, r1 }, null, function, new bool[] { extendStart, extendEnd }));
        }
示例#2
0
        protected internal PdfObject GetSpotObject(PdfWriter writer)
        {
            PdfArray array = new PdfArray(PdfName.SEPARATION);

            array.Add(name);
            PdfFunction func = null;

            if (altcs is ExtendedColor)
            {
                int type = ((ExtendedColor)altcs).Type;
                switch (type)
                {
                case ExtendedColor.TYPE_GRAY:
                    array.Add(PdfName.DEVICEGRAY);
                    func = PdfFunction.Type2(writer, new float[] { 0, 1 }, null, new float[] { 0 }, new float[] { ((GrayColor)altcs).Gray }, 1);
                    break;

                case ExtendedColor.TYPE_CMYK:
                    array.Add(PdfName.DEVICECMYK);
                    CMYKColor cmyk = (CMYKColor)altcs;
                    func = PdfFunction.Type2(writer, new float[] { 0, 1 }, null, new float[] { 0, 0, 0, 0 },
                                             new float[] { cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black }, 1);
                    break;

                default:
                    throw new Exception("Only RGB, Gray and CMYK are supported as alternative color spaces.");
                }
            }
            else
            {
                array.Add(PdfName.DEVICERGB);
                func = PdfFunction.Type2(writer, new float[] { 0, 1 }, null, new float[] { 1, 1, 1 },
                                         new float[] { (float)altcs.R / 255, (float)altcs.G / 255, (float)altcs.B / 255 }, 1);
            }
            array.Add(func.Reference);
            return(array);
        }