Skip to content

Commit bb1c62d

Browse files
Merge pull request #38 from CodeGod911/bugfix/ColorOfDots
fill disregards strokestyle
2 parents 8fa761f + b0ce96d commit bb1c62d

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

SignaturePad/SignaturePad.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7-
<Version>8.1.2</Version>
7+
<Version>8.1.3</Version>
88
<Description>A simple to use blazor component to draw a signature.</Description>
99
<Copyright>2023</Copyright>
1010
<RepositoryUrl>https://github.com/MarvinKlein1508/SignaturePad</RepositoryUrl>

SignaturePad/SignaturePad.razor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected async override Task OnAfterRenderAsync(bool firstRender)
7272
{
7373
if (firstRender)
7474
{
75-
_jsModule = await jsRuntime.InvokeAsync<IJSObjectReference>("import", "./_content/Blazor.SignaturePad/sigpad.interop.js?ver=8.1.2");
75+
_jsModule = await jsRuntime.InvokeAsync<IJSObjectReference>("import", "./_content/Blazor.SignaturePad/sigpad.interop.js?ver=8.1.3");
7676
await Setup();
7777
await Update();
7878
await UpdateImage();

SignaturePad/wwwroot/sigpad.interop.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Sigpad from "./sigpad.min.js?ver=8.1.2"
1+
import Sigpad from "./sigpad.min.js?ver=8.1.3"
22
var dotNetHelper;
33

44
export function setup(id, reference, options, image) {

SignaturePad/wwwroot/sigpad.min.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
const sigpadMap = new Map();
1010

11-
function drawPoints(ctx, points) {
11+
// finished param: only draw last point after points wont differ from exec to exec
12+
function drawPoints(ctx, points, finished) {
1213
// draw a point instead
1314
if (points.length == 1) {
1415
var b = points[0];
@@ -17,7 +18,7 @@ function drawPoints(ctx, points) {
1718
}
1819

1920
// draw line for just two points
20-
if (points.length == 2) {
21+
if (points.length == 2 && finished) {
2122
ctx.beginPath(), ctx.moveTo(points[0].x, points[0].y);
2223
ctx.lineTo(points[1].x, points[1].y);
2324
ctx.stroke();
@@ -32,7 +33,7 @@ function drawPoints(ctx, points) {
3233
d = (points[i].y + points[i + 1].y) / 2;
3334
ctx.quadraticCurveTo(points[i].x, points[i].y, c, d);
3435
}
35-
if (i < points.length - 1)
36+
if (i < points.length - 1 && finished)
3637
ctx.quadraticCurveTo(points[i].x, points[i].y, points[i + 1].x, points[i + 1].y);
3738
//ctx.closePath();
3839
ctx.stroke();
@@ -98,6 +99,7 @@ export default class Sigpad {
9899
ctx = this._element.getContext("2d");
99100
}
100101
ctx.strokeStyle = this._config.strokeStyle;
102+
ctx.fillStyle = this._config.strokeStyle;
101103
ctx.lineWidth = this._config.lineWidth;
102104
ctx.lineCap = this._config.lineCap;
103105
ctx.lineJoin = this._config.lineJoin;
@@ -230,7 +232,7 @@ export default class Sigpad {
230232
return;
231233
}
232234

233-
data.render();
235+
data.render(true);
234236
data._drawing = false;
235237

236238
const event = new CustomEvent('sigpad.finish', { detail: data.getImage() });
@@ -265,14 +267,16 @@ export default class Sigpad {
265267
}
266268
}
267269

268-
render() {
270+
//finished: signal to renderer that all individual mouse position arrays are complete
271+
render(finished) {
269272
if (this._element.width != this._element.clientWidth) {
270273
this._element.width = this._element.clientWidth;
271274
}
275+
272276
if (this._drawing) {
273277
var ctx = this._element.getContext("2d");
274278
this._applyOptions(ctx);
275-
this._mousePosis.filter((stroke) => stroke.length > 0).forEach((stroke) => drawPoints(ctx, stroke));
279+
this._mousePosis.filter((stroke) => stroke.length > 0).forEach((stroke) => drawPoints(ctx, stroke, finished));
276280
}
277281
}
278282
}
@@ -291,7 +295,7 @@ const requestAnimFrame = (function (callback) {
291295
(function renderSignatures() {
292296
requestAnimFrame(renderSignatures);
293297
Sigpad.getAllInstances().forEach((sigpad, index) => {
294-
sigpad.render();
298+
sigpad.render(false);
295299
});
296300

297301
})();

0 commit comments

Comments
 (0)