Last active
December 24, 2020 15:34
-
-
Save toomasv/eee95ae869b71d221076aebf2da7bb8a to your computer and use it in GitHub Desktop.
Turn a color in image transparent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Description: "Make some color of image transparent" | |
Date: 23-December-2020 | |
] | |
context [ | |
smudge: function [b [tuple!]][ | |
a: b - 1 c: b + 1 | |
reduce [ | |
charset reduce [a/1 b/1 c/1] | |
charset reduce [a/2 b/2 c/2] | |
charset reduce [a/3 b/3 c/3] | |
] | |
] | |
set 'transparent function [img [image!] color [tuple!]][ | |
spec: load mold img | |
color: smudge color | |
alpha: rejoin parse spec/3/2 [ | |
collect some [ | |
color keep (#{FF}) | |
| 3 skip keep (#{00}) | |
] | |
] | |
append spec/3 alpha | |
do spec | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Examples:
To see what colors you have in image: