Skip to content

Commit

Permalink
Merge pull request #12 from abrunyee/feature/add-textbaseline
Browse files Browse the repository at this point in the history
Added TextBaseline Property to Context and TextBaseline Record
  • Loading branch information
mizrael authored Jan 20, 2025
2 parents 772ae7f + 74dc67a commit be41284
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Blazorex/IRenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ void DrawImage(ElementReference imageRef,
string Font { get; set; }

TextAlign TextAlign { get; set; }
TextBaseline TextBaseline { get; set; }

void SetLineDash(float[] segments);
}
}
}
13 changes: 12 additions & 1 deletion src/Blazorex/RenderContext2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ public TextAlign TextAlign
}
}

private TextBaseline _textBaseline;
public TextBaseline TextBaseline
{
get => _textBaseline;
set
{
_textBaseline = value;
this.SetProperty("textBaseline", value.Value);
}
}

#endregion properties
}
}
}
14 changes: 14 additions & 0 deletions src/Blazorex/TextBaseline.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Blazorex
{
public record TextBaseline : CanvasProperty<string>
{
private TextBaseline(string value) : base(value) { }

public static readonly TextBaseline Alphabetic = new("alphabetic");
public static readonly TextBaseline Top = new("top");
public static readonly TextBaseline Hanging = new("hanging");
public static readonly TextBaseline Middle = new("middle");
public static readonly TextBaseline Ideographic = new("ideographic");
public static readonly TextBaseline Bottom = new("bottom");
}
}

0 comments on commit be41284

Please sign in to comment.