Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit 688e98a

Browse files
committed
feat: add setBlendedVisiblePixel to drawRectangle
1 parent 4af0d6b commit 688e98a

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/draw/drawRectangle.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Mask } from '../Mask';
33
import { Point } from '../utils/geometry/points';
44
import { getDefaultColor } from '../utils/getDefaultColor';
55
import { getOutputImage, maskToOutputMask } from '../utils/getOutputImage';
6+
import { setBlendedVisiblePixel } from '../utils/setBlendedVisiblePixel';
67
import checkProcessable from '../utils/validators/checkProcessable';
78

89
export interface DrawRectangleOptions<OutType> {
@@ -82,16 +83,24 @@ export function drawRectangle(
8283
currentColumn < column + width;
8384
currentColumn++
8485
) {
85-
newImage.setVisiblePixel(currentColumn, row, strokeColor);
86-
newImage.setVisiblePixel(currentColumn, row + height - 1, strokeColor);
86+
setBlendedVisiblePixel(newImage, currentColumn, row, {
87+
color: strokeColor,
88+
});
89+
setBlendedVisiblePixel(newImage, currentColumn, row + height - 1, {
90+
color: strokeColor,
91+
});
8792
}
8893
for (
8994
let currentRow = row + 1;
9095
currentRow < row + height - 1;
9196
currentRow++
9297
) {
93-
newImage.setVisiblePixel(column, currentRow, strokeColor);
94-
newImage.setVisiblePixel(column + width - 1, currentRow, strokeColor);
98+
setBlendedVisiblePixel(newImage, column, currentRow, {
99+
color: strokeColor,
100+
});
101+
setBlendedVisiblePixel(newImage, column + width - 1, currentRow, {
102+
color: strokeColor,
103+
});
95104
}
96105
}
97106
if (fillColor !== 'none') {
@@ -105,8 +114,12 @@ export function drawRectangle(
105114
currentColumn < column + width - 1;
106115
currentColumn++
107116
) {
108-
newImage.setVisiblePixel(currentColumn, currentRow, fillColor);
109-
newImage.setVisiblePixel(currentColumn, currentRow, fillColor);
117+
/* setBlendedVisiblePixel(newImage, currentColumn, currentRow, {
118+
color: fillColor,
119+
});*/
120+
setBlendedVisiblePixel(newImage, currentColumn, currentRow, {
121+
color: fillColor,
122+
});
110123
}
111124
}
112125
}

0 commit comments

Comments
 (0)