0
点赞
收藏
分享

微信扫一扫

以倒影效果显示文字

爱做梦的夏夏 2022-08-02 阅读 143

//倒影字体
private void DaoYing()
{
//倒影文字
Brush backBrush = Brushes.BlueViolet;
Brush foreBrush = Brushes.Red;
Font font = new Font("幼圆", Convert.ToInt16(60), FontStyle.Regular);
Graphics g = this.pan_sanke.CreateGraphics();
string text = "GAME OVER";
SizeF size = g.MeasureString(text, font);
int posX = (this.pan_sanke.Width - Convert.ToInt16(size.Width)) / 2;
int posY = (this.pan_sanke.Height - Convert.ToInt16(size.Height)) / 2;
g.TranslateTransform(posX, posY);
int ascent = font.FontFamily.GetCellAscent(font.Style);
int spacing = font.FontFamily.GetLineSpacing(font.Style);
int lineHeight = System.Convert.ToInt16(font.GetHeight(g));
int height = lineHeight * ascent / spacing;
GraphicsState state = g.Save();
g.ScaleTransform(1, -1.0F);
g.DrawString(text, font, backBrush, 0, -height);
g.Restore(state);
g.DrawString(text, font, foreBrush, 0, -height);
}

举报

相关推荐

0 条评论