Example #1
0
 ////////////////////////////////////////////////////////////////////
 /// <summary>
 ///     Set tiling type
 /// </summary>
 /// <param name="TilingType">Tiling type</param>
 ////////////////////////////////////////////////////////////////////
 public void SetTilingType
 (
     TilingType TilingType
 )
 {
     // by default the constructor set tiling type to 1 = constant
     Dictionary.AddInteger("/TilingType", (int)TilingType);
 }
Example #2
0
        ////////////////////////////////////////////////////////////////////
        // Set tiling type
        ////////////////////////////////////////////////////////////////////

        public void SetTilingType
        (
            TilingType TilingType
        )
        {
            // by default the constructor set tiling type to 1 = constant
            AddToDictionary("/TilingType", ((Int32)TilingType).ToString());
            return;
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:PdfTilingPattern" /> class.
        /// </summary>
        /// <param name="pdf">The PDF.</param>
        /// <param name="stencil">if set to <c>true</c> [stencil].</param>
        public PdfTilingPattern(PdfDocument pdf, bool stencil)
        {
            this.bBox       = new PdfRectangle(0f, 0f, 50f, 50f);
            this.tilingType = TilingType.ConstantSpacing;
            this.xStep      = 50f;
            this.yStep      = 50f;
            this.pdf        = pdf;
            base.Properties.Add(PdfName.Type, PdfName.Pattern);
            base.Properties.Add(PdfName.PatternType, PdfNumber.One);
            base.Properties[PdfName.PaintType] = stencil ? PdfNumber.Two : PdfNumber.One;
            this.stencil = stencil;
            PdfResources resources = (this.pdf != null) ? new PdfResources(this.pdf.ResourcesManager) : new PdfResources();

            resources.IsLabeled = true;
            base.Properties.Add(PdfName.Resources, resources);
        }
Example #4
0
        public UncoloredTilingPatternColorspace(float width, float height)
        {
            _stream     = new MemoryStream();
            _resources  = new Resources();
            _canvas     = new Canvas(_stream, _resources, width, height);
            _streamDict = new PDFDictionaryStream(new PDFDictionary(), _stream);
            _paintType  = PDFTilingPaintType.UncoloredTilingPattern;
            _tilingType = PDF.TilingType.ConstantSpacing;
            _height     = height;
            _width      = width;
            _matrix     = new float[6];
            _matrix[0]  = 1;
            _matrix[1]  = 0;
            _matrix[2]  = 0;
            _matrix[3]  = 1;
            _matrix[4]  = 0;
            _matrix[5]  = 0;
            _xstep      = width;
            _ystep      = height;
            _color      = new ColorRGB(0, 0, 0);

            PDFDictionary dict = _streamDict.Dictionary;

            dict.AddItem("Type", new PDFName(Name));
            dict.AddItem("PatternType", new PDFNumber((float)PDFPatternType.TilingPattern));
            dict.AddItem("PaintType", new PDFNumber((float)_paintType));
            dict.AddItem("TilingType", new PDFNumber((float)_tilingType));
            PDFArray rect = new PDFArray();

            rect.AddItem(new PDFNumber(0));
            rect.AddItem(new PDFNumber(0));
            rect.AddItem(new PDFNumber(_width));
            rect.AddItem(new PDFNumber(_height));
            dict.AddItem("BBox", rect);
            dict.AddItem("XStep", new PDFNumber(_xstep));
            dict.AddItem("YStep", new PDFNumber(_ystep));
            dict.AddItem("Resources", _resources.Dictionary);
            PDFArray array = new PDFArray();

            for (int i = 0; i < 6; ++i)
            {
                array.AddItem(new PDFNumber((_matrix[i])));
            }
            dict.AddItem("Matrix", array);
            _name = "";
        }
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Set tiling type
        /// </summary>
        /// <param name="TilingType">Tiling type</param>
        ////////////////////////////////////////////////////////////////////
        public void SetTilingType(
			TilingType	TilingType
			)
        {
            // by default the constructor set tiling type to 1 = constant
            Dictionary.AddInteger("/TilingType", (Int32) TilingType);
            return;
        }
    void GenerateQuads()
    {
        if (!shouldRecreateMaterial &&
            !forceUpdate &&
            innerSize == numberOfTiles &&
            innerSprite == sprite &&
            innerShader == baseShader &&
            innerSharedMaterial == sharedMaterial &&
            innerTilingType == tilingType
            )
        {
            return;
        }

        Vector2 spriteScale = sprite.bounds.size;

        this.Scale = spriteScale;

        innerSize       = numberOfTiles;
        innerSprite     = sprite;
        innerTilingType = tilingType;
        innerShader     = baseShader;
        forceUpdate     = false;

        if (baseShader == null)
        {
            return;
        }

        MeshRenderer mr = this.gameObject.GetComponent <MeshRenderer>();

        if (mr == null)
        {
            mr = this.gameObject.AddComponent <MeshRenderer>();
        }
        mr.hideFlags = HideFlags.NotEditable;
        var mat = sharedMaterial.GetInstanceID() != 0 ? sharedMaterial : (mr.sharedMaterial == innerSharedMaterial ? null : mr.sharedMaterial);

        innerSharedMaterial = sharedMaterial;

        if (mat == null || (shouldRecreateMaterial))
        {
            mat = new Material(baseShader);
        }

        shouldRecreateMaterial = false;

        mat.mainTexture          = innerSprite.texture;
        mat.mainTexture.wrapMode = TextureWrapMode.Repeat;

        if (innerTilingType == TilingType.SingleQuadChangeScaling)
        {
            mat.mainTextureScale = numberOfTiles;
        }

        if (mat != innerSharedMaterial)
        {
            mat.name = "Autogenerated Material";
        }

        mr.sortingOrder   = sortingOrder;
        mr.sharedMaterial = mat;
        mr.hideFlags      = HideFlags.NotEditable;

        MeshFilter mf = this.gameObject.GetComponent <MeshFilter>();

        if (mf == null)
        {
            mf = this.gameObject.AddComponent <MeshFilter>();
        }
        var mesh = tilingType == TilingType.SingleQuadChangeScaling ? GenerateSingleQuad() : GenerateMultipleQuads();

        mf.mesh      = mesh;
        mf.hideFlags = HideFlags.NotEditable;
    }