public void move(Point p, double span) { Texture.move(p, span); TextTexture.move(new Point(p.X + 50, p.Y), span); lineTwo.move(new Point(p.X + 50, p.Y + 30), span); Bounds = new Rectangle(p.X, p.Y, Bounds.Width, Bounds.Height); }
public void TestRenderText() { var game = new DX11Game(); game.InitDirectX(); var txt = new TextTexture(game, 100, 100); txt.DrawText("The Wizards", new Vector2(0, 0), new Color4(0.3f, 0.3f, 0.3f)); txt.UpdateTexture(); game.GameLoopEvent += delegate { txt.Clear(); txt.DrawText("The Wizards", new Vector2(0, 0), new Color4(0.3f, 0.3f, 0.3f)); txt.UpdateTexture(); game.Device.ImmediateContext.OutputMerger.BlendState = game.HelperStates.AlphaBlend; game.TextureRenderer.Draw(txt.GPUTexture.View, new Vector2(0, 0), new Vector2(100, 100)); }; game.Run(); }
public void moveY(Point p, double span) { Texture.moveY(p.Y, span); TextTexture.moveY(p.Y, span); lineTwo.moveY(p.Y + 30, span); Bounds = new Rectangle(p.X, p.Y, Bounds.Width, Bounds.Height); }
private void LoadingProcess(object param) { LoadingResourcesDlg dlg = (LoadingResourcesDlg)param; try { // load symbols for elements ElementPTFactory elements = ElementPTFactory.Instance; System.Drawing.Font font = new System.Drawing.Font("Tahoma", 20); float onePer = 100.0f / elements.Size; float prog = 0; foreach (PeriodicTableElement element in elements) { Texture tex = TextTexture.DrawTextToTexture(element.Symbol, font, device, 64, 64).Texture; symbolTextures[element.Symbol] = tex; prog += onePer; dlg.Progress = (int)prog; } dlg.TryClose(); } catch { } }
/// <summary> /// 各種パラメータを指定して DebugText クラスの新しいインスタンスを初期化します。 /// </summary> /// <param name="options">デバッグ表示のテキストに用いられるテキストオプション。</param> /// <param name="Window">デバッグ表示が行われるウィンドウ。</param> public DebugText(TextOptions options, SitrineWindow window) { if (options == null) { throw new ArgumentNullException("options"); } if (window == null) { throw new ArgumentNullException("window"); } this.textOptions = options; this.textOptions.SetSolidBrushes(Color.White, Color.FromArgb(128, Color.Black), Color.Green, Color.Yellow, Color.Red); this.textOptions.ShadowIndex = 1; this.textOptions.DrawShadow = true; this.debugTexture = new TextTexture(this.textOptions, new Size(window.TargetSize.Width, (int)options.LineHeight + 1)); this.debugTextTexture = new TextTexture(this.textOptions, new Size(window.TargetSize.Width, (int)(options.LineHeight + 1) * 4 + 1)); this.debugTextTexture.Position = new PointF(0f, options.LineHeight + 1); this.window = window; this.textures = window.Textures; this.textQueue = new LinkedList <TextItem>(); #if DEBUG this.IsVisible = true; #else this.IsVisible = false; #endif }
public override void OnRenderFrame(OpenTK.FrameEventArgs e) { base.OnRenderFrame(e); texture.draw(e); TextTexture.draw(e); lineTwo.draw(e); }
// Color customtemp; public override void OnRenderFrame(OpenTK.FrameEventArgs e) { base.OnRenderFrame(e); texture.draw(e); if (stretchable) { end1.draw(e); end2.draw(e); } TextTexture.draw(e); }
public MainMenu() { one = 1; textures = new DictionaryStringInt1024(); textTextures = new TextTexture[256]; textTexturesCount = 0; screen = new ScreenMain(); screen.menu = this; loginClient = new LoginClientCi(); assets = new AssetList(); assetsLoadProgress = new FloatRef(); }
public Label(Game game, Point location, string text) : base(game, text) { bounds = new Rectangle(location, new Size(0, 0)); OnLoad(null); SizeF temp = TextTexture.getStringSize(); if (temp.IsEmpty) { temp = new SizeF(1, 1); } TextTexture.TextureSize = new Size((int)temp.Width, (int)temp.Height); bounds = new Rectangle(location, new Size((int)temp.Width, (int)temp.Height)); }
private void Init() { //load background //backGroundTexture = new Texture(new Bitmap(GraphicsLib.Properties.Resources.main_background)); labelTextures = new TextTexture[5]; textFont = new Font(FontFamily.GenericMonospace, 22, FontStyle.Bold, GraphicsUnit.Pixel); //Incapsulate it in factory in the future textColor = Color4.White; labelTextures[0] = new TextTexture(textFont, Properties.StringItems.strSinglePlayer); labelTextures[1] = new TextTexture(textFont, Properties.StringItems.strMultiPlayer); labelTextures[2] = new TextTexture(textFont, Properties.StringItems.strOptions); labelTextures[3] = new TextTexture(textFont, Properties.StringItems.strAuthors); labelTextures[4] = new TextTexture(textFont, Properties.StringItems.strExit); }
TextTexture GetTextTexture(string text, FontCi font) { for (int i = 0; i < textTexturesCount; i++) { TextTexture t = textTextures[i]; if (t == null) { continue; } if (t.text == text && t.font.size == font.size && t.font.family == font.family && t.font.style == font.style) { return(t); } } TextTexture textTexture = new TextTexture(); Text_ text_ = new Text_(); text_.text = text; text_.font = font; text_.color = Game.ColorFromArgb(255, 255, 255, 255); BitmapCi textBitmap = textColorRenderer.CreateTextTexture(text_); int texture = p.LoadTextureFromBitmap(textBitmap); IntRef textWidth = new IntRef(); IntRef textHeight = new IntRef(); p.TextSize(text, font, textWidth, textHeight); textTexture.texture = texture; textTexture.texturewidth = p.FloatToInt(p.BitmapGetWidth(textBitmap)); textTexture.textureheight = p.FloatToInt(p.BitmapGetHeight(textBitmap)); textTexture.text = text; textTexture.font = font; textTexture.textwidth = textWidth.value; textTexture.textheight = textHeight.value; p.BitmapDelete(textBitmap); textTextures[textTexturesCount++] = textTexture; return(textTexture); }
/// <summary> /// テキスト画像を更新します。 /// </summary> private void UpdateTexture() { var texture = TextureCache.GetTextTexture(Text, Font); if (texture == null) { // 取得できない場合は諦める TextTexture = null; return; } // メッシュがない場合はデフォルトのメッシュで初期化します。 if (Mesh == null) { Mesh = Mesh.CreateDefault(1, 1, 0, 0); } TextTexture = texture; }
public void Simulate() { foreach (var change in TW.Data.GetChangesOfType <Textarea>()) { var area = change.ModelObject as Textarea; if (change.Change == TheWizards.Data.ModelChange.Removed) { areas.Remove(area); area.get <TextTexture>().Dispose(); continue; } if (change.Change == TheWizards.Data.ModelChange.Added) { areas.Add(area); area.set(new Data()); } var data = area.get <Data>(); var tex = area.get <TextTexture>(); if ((data.OldSize - area.Size).LengthSquared() > 0.001) { // Size changed if (tex != null) { tex.Dispose(); } tex = new TextTexture(TW.Graphics, (int)area.Size.X, (int)area.Size.Y); area.set(tex); } tex.SetFont(area.FontFamily, area.FontSize); tex.Clear(area.BackgroundColor); tex.DrawText(area.Text, new Vector2(), area.Color); tex.UpdateTexture(); } render(); }
public static ITexture CreateTextureAssetFromText(string text, DX11Game game) { var texSize = 1024; TWDir.Cache.CreateSubdirectory("BoxText"); var fontSize = 100; // not really used?? var name = "BoxText\\" + GetInt64HashCode(text) + "Auto8.dds"; var file = TWDir.Cache + "\\" + name; if (!File.Exists(file)) { var tex = new TextTexture(game, texSize, texSize); tex.SetFont("Arial", fontSize); var size = tex.MeasureString(text); var scale = Math.Min(texSize / size.X, texSize / size.Y); tex.SetFont("Arial", fontSize * scale); size = tex.MeasureString(text); tex.Clear(new Color4(1, 1, 1, 1)); tex.DrawText(text, new Vector2(texSize / 2 - size.X / 2, texSize / 2 - size.Y / 2), new Color4(0, 0, 0)); tex.UpdateTexture(); Resource.SaveTextureToFile(game.Device.ImmediateContext, tex.GPUTexture.Resource, ImageFileFormat.Dds, file); } //TODO: remove TW dependency var texture = TW.Assets.LoadTextureFromCache(name); return(texture); }
private void initializeTW() { game = TW.Graphics; deferredRenderer = TW.Graphics.AcquireRenderer(); var boxRenderer = BoxRenderer.Instance; throw new NotImplementedException(); //boxRenderer.SetGame(game); if (hideAxes) { //Hide axes, ugly hack PropertyInfo prop = game.GetType().GetProperty("RenderAxis", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); prop.SetValue(game, false, null); } cameraLight = deferredRenderer.CreatePointLight(); cameraLight.LightRadius = 75; extraLight = deferredRenderer.CreatePointLight(); extraLight.LightRadius = 100f; extraLight.ShadowsEnabled = true; extraLight.Color = new Vector3(1, 1, 0.85f); extraLight.LightPosition = new Vector3(1000, 1000, 1000); sun = deferredRenderer.CreatePointLight(); sun.LightRadius = 1000; float intensity = 1.25f; sun.Color = new Vector3(0.75f * intensity, 0.75f * intensity, 0.5f * intensity); sun.ShadowsEnabled = true; sun.LightPosition = new Vector3(-5, 30, 10); seedDisplay = new TextTexture(game, 500, 50); batchDisplay = new TextTexture(game, 500, 50); infoDisplay = new TextTexture(game, 500, 50); }
public Texture this[string symbol] { get { Texture tex = null; if (symbolTextures.TryGetValue(symbol, out tex)) { return(tex); } // try load ElementPTFactory elements = ElementPTFactory.Instance; PeriodicTableElement element = elements.getElement(symbol); if (element != null) { System.Drawing.Font font = new System.Drawing.Font("Tahoma", 20); tex = TextTexture.DrawTextToTexture(element.Symbol, font, device, 64, 64).Texture; return(symbolTextures[element.Symbol] = tex); } return(null); } }
internal void DrawText(string text, FontCi font, float x, float y, TextAlign align, TextBaseline baseline) { TextTexture t = GetTextTexture(text, font); int dx = 0; int dy = 0; if (align == TextAlign.Center) { dx -= t.textwidth / 2; } if (align == TextAlign.Right) { dx -= t.textwidth; } if (baseline == TextBaseline.Middle) { dy -= t.textheight / 2; } if (baseline == TextBaseline.Bottom) { dy -= t.textheight; } Draw2dQuad(t.texture, x + dx, y + dy, t.texturewidth, t.textureheight); }
TextTexture GetTextTexture(string text, float fontSize) { for (int i = 0; i < textTexturesCount; i++) { TextTexture t = textTextures[i]; if (t == null) { continue; } if (t.text == text && t.size == fontSize) { return t; } } TextTexture textTexture = new TextTexture(); Text_ text_ = new Text_(); text_.text = text; text_.fontsize = fontSize; text_.fontfamily = "Arial"; text_.color = Game.ColorFromArgb(255, 255, 255, 255); BitmapCi textBitmap = textColorRenderer.CreateTextTexture(text_); int texture = p.LoadTextureFromBitmap(textBitmap); IntRef textWidth = new IntRef(); IntRef textHeight = new IntRef(); p.TextSize(text, fontSize, textWidth, textHeight); textTexture.texture = texture; textTexture.texturewidth = p.FloatToInt(p.BitmapGetWidth(textBitmap)); textTexture.textureheight = p.FloatToInt(p.BitmapGetHeight(textBitmap)); textTexture.text = text; textTexture.size = fontSize; textTexture.textwidth = textWidth.value; textTexture.textheight = textHeight.value; p.BitmapDelete(textBitmap); textTextures[textTexturesCount++] = textTexture; return textTexture; }