Example #1
0
        private string sample18(ICanvasRenderingContext2D ctx)
        {
            ctx.shadowOffsetX = 2;
            ctx.shadowOffsetY = 2;
            ctx.shadowBlur = 2;
            ctx.shadowColor = "rgba(0, 0, 0, 0.5)";

            ctx.font = "20px Times New Roman";
            //ctx.textAlign = "end";
            //ctx.textBaseLine = "bottom";
            ctx.fillStyle = "Black";
            ctx.fillText("Sample String", 35, 30);
            return @"Originals\Text\sample18.png";
        }
Example #2
0
        private string TextPositions(ICanvasRenderingContext2D ctx)
        {
            int i, j;
            string text = "Hello world";
            var align = new[] {"left", "center", "right"};
            var baseline = new[] {"top", "hanging", "middle", "alphabetic", "ideographic", "bottom"};

            ctx.fillStyle = "#000";
            ctx.strokeStyle = "#f00";
            ctx.font = "20px Arial";
            ctx.translate(70, 30);

            for (i = 0; i < align.Length; i++)
            {
                for (j = 0; j < baseline.Length; j++)
                {
                    ctx.save();
                    ctx.translate(i*170 + 0.5, j*50 + 0.5);

                    ctx.textAlign = align[i];
                    ctx.textBaseLine = baseline[j];

                    ctx.fillText(text, 0, 0);

                    ctx.beginPath();
                    ctx.moveTo(-50, 0);
                    ctx.lineTo(50, 0);

                    ctx.moveTo(0, -10);
                    ctx.lineTo(0, 10);
                    ctx.closePath();

                    ctx.stroke();
                    ctx.restore();
                }
            }
            return @"Originals\Text\TextPositions.png";
        }
Example #3
0
        private string TextStrokeFill(ICanvasRenderingContext2D ctx)
        {
            string fillText = "fill. う~ぱ~";
            string strokeText = "stroke. う~ぱ~";

            ctx.textBaseLine = "top";
            ctx.font = "32pt Arial";

            ctx.fillStyle = "orange"; // shadow color
            ctx.fillText(fillText, 22, 22);
            ctx.fillStyle = "red";
            ctx.fillText(fillText, 20, 20);

            ctx.strokeStyle = "blue";
            ctx.strokeText(strokeText, 20, 80);
            return @"Originals\Text\TextStrokeFill.png";
        }