Skip to content

Commit faa9a20

Browse files
author
Mathieu Amiot
committed
Added alpha option support to loadImage()
1 parent f3358f3 commit faa9a20

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

js/load-image.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,14 @@
122122
destX,
123123
destY,
124124
destWidth,
125-
destHeight
125+
destHeight,
126+
alpha
126127
) {
127-
canvas.getContext('2d').drawImage(
128+
var ctx = canvas.getContext('2d');
129+
if (!!alpha)
130+
ctx.globalAlpha = alpha;
131+
132+
ctx.drawImage(
128133
img,
129134
sourceX,
130135
sourceY,
@@ -259,7 +264,8 @@
259264
0,
260265
0,
261266
destWidth,
262-
destHeight
267+
destHeight,
268+
options.alpha
263269
);
264270
}
265271
img.width = destWidth;

0 commit comments

Comments
 (0)