public void Draw(GameTime gameTime,string s, Vector2 location, Color col, HorizontalJustification hj, VerticalJustification vj,bool ui) { Vector2 loc = location; switch (hj) { case HorizontalJustification.Center: loc.X -= (((s.Length + 1)* globals._Sprites[myAnim.SpriteName].Width) / 2) + ((globals._Sprites[myAnim.SpriteName].Width) / 2); break; case HorizontalJustification.Right: loc.X -= s.Length * globals._Sprites[myAnim.SpriteName].Width; break; } switch (vj) { case VerticalJustification.Center: loc.Y -= globals._Sprites[myAnim.SpriteName].Height / 2; break; case VerticalJustification.Top: loc.Y -= globals._Sprites[myAnim.SpriteName].Height; break; } int i = 0; foreach (char c in s) { i++; myAnim.gotoAnim(c.ToString(), false); myAnim.Draw(gameTime, new Vector2(loc.X + (globals._Sprites[myAnim.SpriteName].Width * i), loc.Y), SpriteEffects.None, 1.0f, col,false,ui, 1.0f); } }
protected override IEnumerator ProcessPayload(VisualPayload payload) { var label = VisualizerFactory.InstantiateLabelVisualizerPrefab(); label.Initialize(this, payload); var meshRenderer = label.TextComponent.GetComponent <MeshRenderer>(); var targetFont = FontFactory.GetFontPair(FontName.GetFirstValue(payload.Data)); var newMaterial = FontFactory.GenerateNewSpatialMaterial(targetFont.FontTexture); label.TextComponent.font = targetFont.Font; label.TextComponent.fontSize = Mathf.FloorToInt(FontSize.GetFirstValue(payload.Data) * targetFont.FontScale); label.transform.localPosition = new Vector3(0f, label.TextComponent.fontSize * targetFont.VerticalOffset, 0f); label.CharactersPerLine = CharactersPerLine.GetFirstValue(payload.Data); label.MaxLines = MaxLines.GetFirstValue(payload.Data); newMaterial.color = FontColor.GetFirstValue(payload.Data); meshRenderer.material = newMaterial; label.BackgroundPadding = BackgroundPadding.GetFirstValue(payload.Data); label.BackgroundDepth = BackgroundDepth.GetFirstValue(payload.Data); label.LateralJustification = Justification.GetFirstValue(payload.Data); label.VerticalJustification = VerticalJustification.GetFirstValue(payload.Data); label.MinHeight = MinHeight.GetFirstValue(payload.Data); label.MaxHeight = MaxHeight.GetFirstValue(payload.Data); label.Orientation = Orientation.GetFirstValue(payload.Data); label.SetClickState(ClickState); label.RemoveBackground = !ShowBackground.GetFirstValue(payload.Data); label.Text = LabelText.GetFirstValue(payload.Data); var newPayload = new VisualPayload(payload.Data, new VisualDescription(label.Bound)); var iterator = DefaultState.Transmit(newPayload); while (iterator.MoveNext()) { yield return(null); } }
public LayeredTreeDraw( ITreeNode tnRoot, double pxBufferHorizontal, double pxBufferHorizontalSubtree, double pxBufferVertical, VerticalJustification vj) { _pxBufferHorizontal = pxBufferHorizontal; _pxBufferHorizontalSubtree = pxBufferHorizontalSubtree; _pxBufferVertical = pxBufferVertical; PxOverallHeight = 0.0; _tnRoot = tnRoot; _vj = vj; }
public Outline GetTextOutline(string[] lines, ref Outline.Point position, HorizontalJustification h, VerticalJustification v, bool useKerning, float interline) { //int nblines = lines.Length; // total cbox BBox bbox = Measure(lines, interline); float startY = 0; switch (v) { case VerticalJustification.Origin: startY = position.Y; break; case VerticalJustification.Top: startY = position.Y - bbox.yMax; break; case VerticalJustification.Bottom: startY = position.Y - bbox.yMin; break; case VerticalJustification.Center: startY = position.Y + (bbox.yMax - bbox.yMin) / 2 - bbox.yMax; break; } Outline outline = new Outline(); Outline.Point pos = new Outline.Point(); foreach (string line in lines) { pos.X = position.X; pos.Y = startY; Outline o = GetStringOutline(line, ref pos, h, VerticalJustification.Origin, useKerning); outline.AddOutline(o); startY -= Height * interline; } return(outline); }
public Outline GetTextOutline(string[] lines, ref Outline.Point position, HorizontalJustification h, VerticalJustification v, bool useKerning, float interline) { //int nblines = lines.Length; // total cbox BBox bbox = Measure(lines, interline); float startY = 0; switch (v) { case VerticalJustification.Origin: startY = position.Y; break; case VerticalJustification.Top: startY = position.Y - bbox.yMax; break; case VerticalJustification.Bottom: startY = position.Y - bbox.yMin; break; case VerticalJustification.Center: startY = position.Y + (bbox.yMax - bbox.yMin) / 2 - bbox.yMax; break; } Outline outline = new Outline(); Outline.Point pos = new Outline.Point(); foreach (string line in lines) { pos.X = position.X; pos.Y = startY; Outline o = GetStringOutline(line, ref pos, h, VerticalJustification.Origin, useKerning); outline.AddOutline(o); startY -= Height * interline; } return outline; }
public Outline GetStringOutline(string txt, HorizontalJustification h, VerticalJustification v, bool useKerning) { Outline.Point adv = new Outline.Point(); return(GetStringOutline(txt, ref adv, h, v, useKerning)); }
public Outline GetStringOutline(string txt, HorizontalJustification h, VerticalJustification v) { Outline.Point adv = new Outline.Point(); return(GetStringOutline(txt, ref adv, h, v, false)); }
public Outline GetStringOutline(string txt, ref Outline.Point advance, HorizontalJustification h, VerticalJustification v) { return(GetStringOutline(txt, ref advance, h, v, false)); }
public Outline GetStringOutline(string txt, HorizontalJustification h, VerticalJustification v, bool useKerning, float hspacing, float embold) { Outline.Point adv = new Outline.Point(); return(GetStringOutline(txt, ref adv, h, v, useKerning, hspacing, embold, 4)); }
// Compute the outline for a whole line public Outline GetStringOutline(string txt, ref Outline.Point position, HorizontalJustification h, VerticalJustification v, bool useKerning, float spacing, float emboldStrenght, int isteps) { Outline res = new Outline(); // first set pen position according to requested text justification if (h != HorizontalJustification.Origin || v != VerticalJustification.Origin) { // Compute Bounding box and set original advancement according to justification BBox bbox = Measure(txt); switch (h) { case HorizontalJustification.Left: position.X = position.X - bbox.xMin; break; case HorizontalJustification.Right: position.X = position.X - bbox.xMax; break; case HorizontalJustification.Center: position.X = position.X - (bbox.xMin + bbox.xMax) / 2; break; } switch (v) { case VerticalJustification.Top: position.Y = position.Y - bbox.yMax; break; case VerticalJustification.Bottom: position.Y = position.Y - bbox.yMin; break; case VerticalJustification.Center: position.Y = position.Y - (bbox.yMin + bbox.yMax) / 2; break; } } // Console.WriteLine("Original pen position=" + position); if (!HasKerning) { useKerning = false; } uint prev = 0; for (int i = 0; i < txt.Length; ++i) { uint idx = (uint)FT.FT_Get_Char_Index(face_, txt[i]); if (useKerning && prev != 0 && idx != 0) // adjust with kerning properties { position.Translate(GetKerning((uint)prev, idx)); } Outline.Point adv; Outline o = GetGlyphOutline(idx, out adv, true, emboldStrenght, isteps); o.Translate(position); res.AddOutline(o); adv.Scale(spacing); position.Translate(adv); prev = idx; } /* * foreach (char c in txt) * { * Outline.Point adv; * Outline o = GetGlyphOutline(c, out adv, true); * o.Translate(advance); * res.AddOutline(o); * advance.Translate(adv); * } */ return(res); }
public Outline GetStringOutline(string txt, ref Outline.Point position, HorizontalJustification h, VerticalJustification v, bool useKerning) { return(GetStringOutline(txt, ref position, h, v, useKerning, 1)); }
public Outline GetStringOutline(string txt, HorizontalJustification h, VerticalJustification v) { Outline.Point adv = new Outline.Point(); return GetStringOutline(txt, ref adv, h, v, false); }
public static string PadVertical(this string message, int totalRows, VerticalJustification justification = VerticalJustification.CENTER, bool addHorizontalSpaces = false) { string paddedMessage = message; message = message.FilterCarriageReturns(); string[] splitMessage = message.Split('\n'); if (totalRows <= splitMessage.Length) { return(paddedMessage); } string emptyLine = Symbols.CarriageReturnLineFeed; if (addHorizontalSpaces) { int maxHorz = 0; for (int cursor = 0; cursor < splitMessage.Length; cursor++) { if (splitMessage[cursor].Length > maxHorz) { maxHorz = splitMessage[cursor].Length; } } emptyLine = new String(' ', maxHorz) + Symbols.CarriageReturnLineFeed; } int topPadding = (totalRows - splitMessage.Length) / 2; paddedMessage = ""; switch (justification) { case VerticalJustification.BOTTOM: topPadding = totalRows - splitMessage.Length; break; case VerticalJustification.TOP: topPadding = 0; break; default: topPadding = (totalRows - splitMessage.Length) / 2; break; } int pads = topPadding; for (int cursor = 0; cursor < pads; cursor++) { paddedMessage += emptyLine; } for (int cursor = 0; cursor < splitMessage.Length; cursor++) { paddedMessage += splitMessage[cursor] + Symbols.CarriageReturnLineFeed; pads++; } while (pads < totalRows) { paddedMessage += emptyLine; pads++; } // Deliberate // for (pads = pads; pads < totalRows; pads++) // { // paddedMessage += emptyLine; // } return(paddedMessage); }
public Outline GetStringOutline(string txt, HorizontalJustification h, VerticalJustification v, bool useKerning) { Outline.Point adv = new Outline.Point(); return GetStringOutline(txt, ref adv, h, v, useKerning); }
public Outline GetStringOutline(string txt, HorizontalJustification h, VerticalJustification v, bool useKerning, float hspacing, float embold) { Outline.Point adv = new Outline.Point(); return GetStringOutline(txt, ref adv, h, v, useKerning, hspacing, embold,4); }
public Outline GetStringOutline(string txt, ref Outline.Point advance, HorizontalJustification h, VerticalJustification v) { return GetStringOutline(txt, ref advance, h, v, false); }
public Outline GetStringOutline(string txt, ref Outline.Point position, HorizontalJustification h, VerticalJustification v, bool useKerning) { return GetStringOutline(txt, ref position, h, v, useKerning, 1); }
// Compute the outline for a whole line public Outline GetStringOutline(string txt, ref Outline.Point position, HorizontalJustification h, VerticalJustification v, bool useKerning, float spacing, float emboldStrenght, int isteps) { Outline res = new Outline(); // first set pen position according to requested text justification if (h != HorizontalJustification.Origin || v != VerticalJustification.Origin) { // Compute Bounding box and set original advancement according to justification BBox bbox = Measure(txt); switch (h) { case HorizontalJustification.Left: position.X = position.X - bbox.xMin; break; case HorizontalJustification.Right: position.X = position.X - bbox.xMax; break; case HorizontalJustification.Center: position.X = position.X - (bbox.xMin + bbox.xMax) / 2; break; } switch (v) { case VerticalJustification.Top: position.Y = position.Y -bbox.yMax; break; case VerticalJustification.Bottom: position.Y = position.Y -bbox.yMin; break; case VerticalJustification.Center: position.Y = position.Y -(bbox.yMin + bbox.yMax) / 2; break; } } // Console.WriteLine("Original pen position=" + position); if (! HasKerning) { useKerning = false; } int prev = 0; for (int i = 0; i < txt.Length; ++i) { int idx = FT.FT_Get_Char_Index(face_, txt[i]); if (useKerning && prev != 0 && idx != 0) // adjust with kerning properties { position.Translate(GetKerning(prev, idx)); } Outline.Point adv; Outline o = GetGlyphOutline(idx, out adv, true, emboldStrenght,isteps); o.Translate(position); res.AddOutline(o); adv.Scale(spacing); position.Translate(adv); prev = idx; } /* foreach (char c in txt) { Outline.Point adv; Outline o = GetGlyphOutline(c, out adv, true); o.Translate(advance); res.AddOutline(o); advance.Translate(adv); } */ return res; }