private string GetWrappedString(asd.Font font, string title) { string result = title; if (font.CalcTextureSize(result, asd.WritingDirection.Horizontal).X <= Size.X) { return(result); } while (font.CalcTextureSize(result + "…", asd.WritingDirection.Horizontal).X > Size.X) { result = result.Substring(0, result.Length - 1); } return(result + "…"); }
public Button(string text, float x, float y, int fontsize, asd.Color color) { font = asd.Engine.Graphics.CreateDynamicFont(string.Empty, fontsize, color, 1, new asd.Color(255, 255, 255, 255)); Font = font; size = font.CalcTextureSize(text, asd.WritingDirection.Horizontal); CenterPosition = new asd.Vector2DF(size.X / 2.0f, size.Y / 2.0f); Position = new asd.Vector2DF(x, y); Text = text; }
public GameOverScene(string message) { asd.Layer2D layer = new asd.Layer2D(); asd.Font font48 = asd.Engine.Graphics.CreateDynamicFont("", 48, new asd.Color(255, 255, 255, 255), 2, new asd.Color(255, 100, 100, 255)); asd.Font font12 = asd.Engine.Graphics.CreateDynamicFont("", 12, new asd.Color(255, 255, 255, 255), 0, new asd.Color(0, 0, 0, 0)); asd.TextObject2D title = new asd.TextObject2D(); title.Font = font48; title.Text = message; float titleWidth = font48.CalcTextureSize(title.Text, asd.WritingDirection.Horizontal).X; title.Position = new asd.Vector2DF((asd.Engine.WindowSize.To2DF().X - titleWidth) / 2, 250); layer.AddObject(title); asd.TextObject2D prompt = new asd.TextObject2D(); prompt.Font = font12; prompt.Text = "PRESS SPACE KEY TO TITLE"; float promptWidth = font12.CalcTextureSize(prompt.Text, asd.WritingDirection.Horizontal).X; prompt.Position = new asd.Vector2DF((asd.Engine.WindowSize.To2DF().X - promptWidth) / 2, 400); layer.AddObject(prompt); AddLayer(layer); }
/// <summary> /// 描画テキストの縦方向の描画領域を計算する。 /// </summary> public static asd.Vector2DI VerticalSize(this asd.Font obj, string text) { return(obj.CalcTextureSize(text, asd.WritingDirection.Vertical)); }