You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e27c5c5
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@
4
4
5
5
### New
6
6
7
+
-**`image.dropShadow({ x, y, blur, spread, color, expand })`**: a shadow behind the image, shaped by its alpha. Without an offset it is a glow: `image.dropShadow({ blur: 8, spread: 2, color: 0xff2fb9ff })`. The image grows to fit it, unless `expand: false`.
7
8
-**`Image.linearGradient(width, height, { stops, angle })`** and **`Image.radialGradient(width, height, { stops, x, y, radius })`**: images with a gradient, with the angle like CSS' `linear-gradient()`. `stops` are positions and colors like `Colors.gradient()` takes them, or just the colors, evenly spaced.
8
9
-**`image.recolor(otherImage)`**: takes the colors from another image of the same size and keeps the alpha. With a gradient it fills a shape, e.g. gradient text: `text.recolor(Image.linearGradient(text.width, text.height, { stops: [0x22d3eeff, 0xfb923cff], angle: 90 }))`.
assert(image.width===10&&image.height===10&&px(image,4,4).join()==='255,128,64,255'&&px(image,2,4)[3]===0,'dropShadow() without offset or blur changes nothing outside of the shape');
683
+
image=square().dropShadow({x: 2,y: 3});
684
+
assert(image.width===12&&image.height===13,`dropShadow({x, y}) grows right and down: ${image.width}x${image.height}`);
685
+
assert(px(image,8,9).join()==='0,0,0,128'&&px(image,4,4).join()==='255,128,64,255'&&px(image,9,9)[3]===0,`dropShadow: the shadow is 50% black behind the shape, shifted: ${px(image,8,9)}`);
assert(image.width===12&&image.height===11&&px(image,3,3).join()==='255,0,0,255'&&px(image,5,5).join()==='255,128,64,255',`dropShadow({x: -2, y: -1}) grows left and up, the image moves: ${image.width}x${image.height}${px(image,3,3)}`);
assert(image.width===10&&image.height===10&&px(image,8,9).join()==='0,0,0,128','dropShadow({expand: false}) keeps the size');
690
+
image=square().dropShadow({blur: 2});
691
+
assert(image.width===22&&image.height===22,`dropShadow({blur}) leaves room for the blur (3 deviations): ${image.width}x${image.height}`);
692
+
assert(alphaAt(image,3+6-1,3+6+2)>0&&alphaAt(image,0,0)<=1&&alphaAt(image,3+6+1,3+6+1)===255&&px(image,11,11).join()==='255,128,64,255','dropShadow({blur}): a soft shadow around the shape, the shape on top');
assert(image.width===14&&px(image,4,7).join()==='0,255,0,255'&&alphaAt(image,3,7)>64&&alphaAt(image,3,7)<192&&alphaAt(image,2,7)===0,`dropShadow({spread}) grows the shape by the spread: ${[2,3,4].map(x=>alphaAt(image,x,7))}`);
assert(pinks>200&&pinks===(()=>{letn=0;for(leti=0;i<glowing.bitmap.length;i+=4)if(glowing.bitmap[i+3]>0&&glowing.bitmap[i+3]<255)n++;returnn;})(),`a glow is exactly the color all around, also where it's faint: ${pinks} pixels`);
assert(frame.xOffset===0&&frame.yOffset===0&&frame.width===10+2+6&&frame.height===10+5+6&&frame.duration===40,`Frame.dropShadow: ${frame.width}x${frame.height} at ${frame.xOffset},${frame.yOffset}`);
710
+
assert(px(frame,2+4,5+4).join()==='255,128,64,255','Frame.dropShadow: the pixels stay where they were on the animation canvas');
assert(hdrShadow.gainMap&&Math.abs(hdrShadow.gainMap.width/hdrShadow.width-0.5)<0.1&&Math.abs(hdrShadow.gainMap.height/hdrShadow.height-0.5)<0.1,'dropShadow keeps the gain map at its scale');
677
719
}
678
720
679
721
// Colors: the color helpers, and the deprecated Image ones they replaced, give the same values
0 commit comments