public NinePatchRegion2D(TextureRegion2D textureRegion, ThicknessF padding) : base( textureRegion?.Texture, textureRegion?.Name, textureRegion?.X ?? 0, textureRegion?.Y ?? 0, textureRegion?.Width ?? 0, textureRegion?.Height ?? 0) { Padding = padding; CreatePatches(textureRegion !.Bounds, SourcePatches); }
public UITextElement(UIManager manager, BitmapFont font) : base(manager) { _font = font; _segment = new TextSegment(font); _segment.GlyphCallback = GlyphCallback; _quadTree = QuadTreePool <CharSpriteInfo> .Rent(RectangleF.Empty, threshold : 2, allowOverflow : true, fuzzyBoundaries : true); Color = Color.White; CaretColor = Color.Orange; HorizontalAlignment = TextHorizontalAlignment.Left; VerticalAlignment = TextVerticalAlignment.Top; IsShadowed = false; ShadowColor = new Color(Color.Black, 0.75f); ShadowSpacing = new ThicknessF(2, -1, 2, -1); IsMouseEventTrigger = true; OnMouseDown += UITextElement_OnMousePress; }
public static RectangleF ToOffsetRectangle(this ThicknessF thickness, Vector2 scale) { return(new RectangleF( ToOffsetPosition(thickness, scale), ToOffsetSize(thickness, scale))); }
public static SizeF ToOffsetSize(this ThicknessF thickness, Vector2 scale) { return(new SizeF( (thickness.Left + thickness.Right) * scale.X, (thickness.Top + thickness.Bottom) * scale.Y)); }
public static PointF ToOffsetPosition(this ThicknessF thickness, Vector2 scale) { return(new PointF( -thickness.Left * scale.X, -thickness.Top * scale.Y)); }
public NinePatchRegion2D(Texture2D texture, ThicknessF thickness) : this(new TextureRegion2D(texture), thickness) { }
public NinePatchRegion2D(TextureRegion2D textureRegion, ThicknessF padding) : base(textureRegion.Name, textureRegion.Texture, textureRegion.X, textureRegion.Y, textureRegion.Width, textureRegion.Height) { Padding = padding; CachePatches(textureRegion.Bounds, SourcePatches); }
/// <summary> /// Creates a new nine patch texture region and adds it to the list of the <see cref="TextureAtlas" />' regions. /// </summary> /// <param name="name">Name of the texture region.</param> /// <param name="x">X coordinate of the region's top left corner.</param> /// <param name="y">Y coordinate of the region's top left corner.</param> /// <param name="width">Width of the texture region.</param> /// <param name="height">Height of the texture region.</param> /// <param name="thickness">Thickness of the nine patch region.</param> /// <returns>Created texture region.</returns> public NinePatchRegion2D CreateNinePatchRegion(string name, float x, float y, float width, float height, ThicknessF thickness) { if (_regionMap.ContainsKey(name)) { throw new InvalidOperationException($"Region {name} already exists in the texture atlas"); } var textureRegion = new TextureRegion2D(name, Texture, x, y, width, height); var ninePatchRegion = new NinePatchRegion2D(textureRegion, thickness); AddRegion(ninePatchRegion); return(ninePatchRegion); }