Cédric and I had a little chat when he was making his #DuBoisChallenge map (tweet) and wanted a hand-painted effect for the fill color. My recommendation was to try with the blend_with() function of the ggfx package and use a texture image as a “background” of the fill. He ended up using the ggpatern package which gave a much better effect!
Cédric’s map with ggpattern
I really liked the idea of adding a texture to a map and I wanted to test it with ggfx, so I played a little with the map of Greece and a paper texture image:
While testing the different blend types, I thought it would be a good idea to gather all the images as a reference, so here they are!
The blend types were copied from the ggfx documentation as of June 2021. Some plots give, by design, empty plots, I’m not sure if it depends on the specific use case or they always give the same output. The final result depends on the colors of the source and destination layers, so I have two examples, one with a gray map (left) and one with a purple one (right). I haven’t included plots for the modulus__plus and modulus__minus blend types because those option didn’t work at all for me, I got an error message.
The code for making the plots is on GitHub (link)
“source”: Completely disregards the destination, leaving only the source
“destination”: Completely disregards the source, leaving only the destination
“clear”: Disregards both destination and source
“xor”: Composes source on top of destination, setting shared areas to transparent
“over”: Composes source on top of destination
“in”: Shows source, but only where the destination is opaque
“out”: Shows source but only where the destination is transparent
“atop”: Composes source on top of destination, keeping the transparency of destination
“copy”: Like source, but will only affect the area occupied by the source image
[View fullsize
](_paper-source.png)
[View fullsize
](_paper-source-purple.png)
[View fullsize
](_paper-destination-purple.png)
[View fullsize
](_paper-destination.png)
[View fullsize
](_paper-clear-purple.png)
[View fullsize
](_paper-clear.png)
[View fullsize
](_paper-xor-purple.png)
[View fullsize
](_paper-xor.png)
[View fullsize
](_paper-over.png)
[View fullsize
](_paper-over-purple.png)
[View fullsize
](_paper-in.png)
[View fullsize
](_paper-in-purple.png)
[View fullsize
](_paper-out-purple.png)
[View fullsize
](_paper-out.png)
[View fullsize
](_paper-atop.png)
[View fullsize
](_paper-atop-purple.png)
[View fullsize
](_paper-copy.png)
[View fullsize
](_paper-copy-purple.png)
#block-yui_3_17_2_1_1624083449775_15616 .sqs-gallery-block-grid .sqs-gallery-design-grid { margin-right: -5px; } #block-yui_3_17_2_1_1624083449775_15616 .sqs-gallery-block-grid .sqs-gallery-design-grid-slide .margin-wrapper { margin-right: 5px; margin-bottom: 5px; }
“multiply”: Multiplies the channel values of source and destination together (after scaling them to 0-1) to obtain new channel values
“screen”: As multiply except that the channels are scaled to 1-0 before multiplication, and the result is reversed again before being used
“bumpmap”: Like multiple, except source is converted to greyscale first
“divide”: Divide the channel values in source by the channel values in destination
“plus”: Add the channel values together including the alpha channel
“minus”: Subtracts the destination channels from the source channels
“modulus_plus”: As plus, but overflow will wrap around instead of being capped
“modulus_minus”: As minus but overflow (underflow) will wrap around instead of being capped
“difference”: Takes the absolute difference in channel values between source and destination
“exclusion”: source + destination - 2sourcedestination. A sort of averaged difference
“lighten”: Will pick the lightest pixel at each pixel
“darken”: Will pick the darkest pixel at each pixel
“lighten_intensity”: Will pick the most intense colour at each pixel
“darken_intensity”: Will pick the least intense colour at each pixel
[View fullsize
](_paper-multiply.png)
[View fullsize
](_paper-multiply-purple.png)
[View fullsize
](_paper-screen.png)
[View fullsize
](_paper-screen-purple.png)
[View fullsize
](_paper-bumpmap.png)
[View fullsize
](_paper-bumpmap-purple.png)
[View fullsize
](_paper-divide.png)
[View fullsize
](_paper-divide-purple.png)
[View fullsize
](_paper-plus.png)
[View fullsize
](_paper-plus-purple.png)
[View fullsize
](_paper-minus.png)
[View fullsize
](_paper-minus-purple.png)
#block-yui_3_17_2_1_1624083449775_104817 .sqs-gallery-block-grid .sqs-gallery-design-grid { margin-right: -5px; } #block-yui_3_17_2_1_1624083449775_104817 .sqs-gallery-block-grid .sqs-gallery-design-grid-slide .margin-wrapper { margin-right: 5px; margin-bottom: 5px; }
“overlay”: Simultaneously multiplies and screens at the same time based on the colour values of the destination. Will colorize midtones in the destination with the source
“hard_light”: The inverse of overlay (i.e. the source acts as the destination and vice versa)
“soft_light”: Like overlay but will extent the range of colorization past the midtones
“pegtop_light”: Like soft-light, but without any discontinuity in the blend
“linear_light”: Combines dodging and burning so that the destination will be dodged (lightened) when the source is light and burned (darkened) when the source is dark
“vivid_light”: A refinement of linear-light that better avoids shading intense colours
“pin_light”: Preserves midtones of the destination and only shades lighter and darker parts, resulting in harsh, contrasty lightning.
“linear_dodge”: Lighten the destination if the source is light
“linear_burn”: Darked the destination if the source is dark
“color_dodge”: Like linear-dodge, but preserves blacks in the destination image
“color_burn”: Like linear-burn but preserve whites in the destination image
[View fullsize
](_paper-overlay.png)
[View fullsize
](_paper-overlay-purple.png)
[View fullsize
](_paper-hard_light.png)
[View fullsize
](_paper-hard_light-purple.png)
[View fullsize
](_paper-soft_light.png)
[View fullsize
](_paper-soft_light-purple.png)
[View fullsize
](_paper-pegtop_light.png)
[View fullsize
](_paper-pegtop_light-purple.png)
[View fullsize
](_paper-linear_light.png)
[View fullsize
](_paper-linear_light-purple.png)
[View fullsize
](_paper-vivid_light.png)
[View fullsize
](_paper-vivid_light-purple.png)
[View fullsize
](_paper-pin_light.png)
[View fullsize
](_paper-pin_light-purple.png)
[View fullsize
](_paper-linear_dodge.png)
[View fullsize
](_paper-linear_dodge-purple.png)
[View fullsize
](_paper-color_dodge.png)
[View fullsize
](_paper-color_dodge-purple.png)
[View fullsize
](_paper-color_burn.png)
[View fullsize
](_paper-color_burn-purple.png)
#block-yui_3_17_2_1_1624084336819_6515 .sqs-gallery-block-grid .sqs-gallery-design-grid { margin-right: -5px; } #block-yui_3_17_2_1_1624084336819_6515 .sqs-gallery-block-grid .sqs-gallery-design-grid-slide .margin-wrapper { margin-right: 5px; margin-bottom: 5px; }
“copy_opacity”: Will set the opacity of destination to the grayscale version of source. To copy the opacity of source into destination use blend_type = “in” with flip_order = TRUE.
“copy_red”: Copies the red channel in source into the red channel in destination
“copy_green”: Copies the green channel in source into the green channel in destination
“copy_blue”: Copies the blue channel in source into the blue channel in destination
“hue”: Replaces the hue of the destination with the hue of the source
“saturate”: Replaces the saturation of the destination with the saturation of the source
“luminize”: Replaces the luminance of the destination with the luminance of the source
“colorize”: Combines hue and saturate
[View fullsize
](_paper-copy_opacity-purple.png)
[View fullsize
](_paper-copy_opacity.png)
[View fullsize
](_paper-copy_red.png)
[View fullsize
](_paper-copy_red-purple.png)
[View fullsize
](_paper-copy_green.png)
[View fullsize
](_paper-copy_green-purple.png)
[View fullsize
](_paper-copy_blue-purple.png)
[View fullsize
](_paper-copy_blue.png)
[View fullsize
](_paper-hue.png)
[View fullsize
](_paper-hue-purple.png)
[View fullsize
](_paper-saturate.png)
[View fullsize
](_paper-saturate-purple.png)
[View fullsize
](_paper-luminize.png)
[View fullsize
](_paper-luminize-purple.png)
[View fullsize
](_paper-colorize.png)
[View fullsize
](_paper-colorize-purple.png)
#block-yui_3_17_2_1_1624083449775_232306 .sqs-gallery-block-grid .sqs-gallery-design-grid { margin-right: -5px; } #block-yui_3_17_2_1_1624083449775_232306 .sqs-gallery-block-grid .sqs-gallery-design-grid-slide .margin-wrapper { margin-right: 5px; margin-bottom: 5px; }
“unique”: Only keep pixels in the source that differ from the destination.
[View fullsize
](_paper-unique.png)
[View fullsize
](_paper-unique-purple.png)
#block-yui_3_17_2_1_1624083449775_278507 .sqs-gallery-block-grid .sqs-gallery-design-grid { margin-right: -5px; } #block-yui_3_17_2_1_1624083449775_278507 .sqs-gallery-block-grid .sqs-gallery-design-grid-slide .margin-wrapper { margin-right: 5px; margin-bottom: 5px; }