Skip to content

Commit ebc3eef

Browse files
authored
added support for globalCompositeOperation (BlazorExtensions#108)
1 parent c03d39b commit ebc3eef

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Blazor.Extensions.Canvas/Canvas2D/Canvas2DContext.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class Canvas2DContext : RenderingContext
5454
private const string RESTORE_METHOD = "restore";
5555
private const string DRAW_IMAGE_METHOD = "drawImage";
5656
private const string CREATE_PATTERN_METHOD = "createPattern";
57+
private const string GLOBAL_COMPOSITE_OPERATION_PROPERTY = "globalCompositeOperation";
5758

5859
private readonly string[] _repeatNames = new[]
5960
{
@@ -96,6 +97,8 @@ public class Canvas2DContext : RenderingContext
9697

9798
public float GlobalAlpha { get; private set; } = 1.0f;
9899

100+
public string GlobalCompositeOperation { get; private set; } = "source-over";
101+
99102
#endregion Properties
100103

101104
public Canvas2DContext(BECanvasComponent reference) : base(reference, CONTEXT_NAME)
@@ -200,6 +203,12 @@ public async Task SetGlobalAlphaAsync(float value)
200203
await this.BatchCallAsync(GLOBAL_ALPHA_PROPERTY, isMethodCall: false, value);
201204
}
202205

206+
public async Task SetGlobalCompositeOperationAsync(string value)
207+
{
208+
this.GlobalCompositeOperation = value;
209+
await this.BatchCallAsync(GLOBAL_COMPOSITE_OPERATION_PROPERTY, isMethodCall: false, value);
210+
}
211+
203212
#endregion Property Setters
204213

205214
#region Methods

0 commit comments

Comments
 (0)