Example #1
0
        private void AddQuads(QuadCollection quads, string word, Vector2 positionOffset, Color quadColor)
        {
            var charPos = positionOffset;

            foreach (var c in word)
            {
                var charInfo = resource.GetCharInfo(c) ?? resource.GetDefaultCharInfo();
                var frame    = resource.frames[charInfo.frameNum];

                var anchorPoint = new Vector2(
                    anchor.x + frame.textureAnchor.x,
                    anchor.y + frame.textureAnchor.y);

                var framePos = new Vector2(
                    charPos.x + charInfo.offset.x * fontScale,
                    charPos.y + charInfo.offset.y * fontScale);

                charPos.x += (charInfo.symbolWidth + resource.letterSpacing) * fontScale;

                var drawColor = new ColorTransform(quadColor);
                ColorTransform.Compose(ref drawColor, ref compositeColor, out drawColor);

                AddQuad(quads, frame, ref framePos, ref anchorPoint, ref drawColor);
            }
        }
Example #2
0
        protected void AddQuad(QuadCollection quads, SheetFrame frame,
                               ref Vector2 charPos, ref Vector2 anchor, ref ColorTransform colorMult)
        {
            var texture       = frame.texture;
            var textureBounds = frame.textureBounds;

            Matrix4x4 localMatrix, globalMatrix;
            var       letterScale    = fontScale * frame.textureScale;
            var       letterScaleVec = new Vector2(letterScale, letterScale);

            MatrixUtil.Create2D(ref letterScaleVec, 0, ref charPos, out localMatrix);
            MatrixUtil.Multiply(ref localMatrix, ref compositeMatrix, out globalMatrix);

            var textureSize = new Vector2(texture.width, texture.height);

            var spriteQuad = new SpriteQuad();

            spriteQuad.UpdateTransform(ref globalMatrix, ref textureBounds, ref textureSize, ref anchor);
            spriteQuad.UpdateColor(ref colorMult);

            quads.Add(spriteQuad);
        }