Last active
April 2, 2016 23:31
-
-
Save jsundram/c23575c00bc1b66270d903c055fd3af3 to your computer and use it in GitHub Desktop.
Test out each of the blend modes; need to run 3x, one for each render mode.
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
# Code for https://github.com/processing/processing/issues/4376 | |
# See processing/core/src/processing/core/PConstants.java for render/blend mode constants. | |
labels = 'REPLACE, BLEND, ADD, SUBTRACT, LIGHTEST, DARKEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN'.split(', ') | |
blend_modes = [REPLACE, BLEND, ADD, SUBTRACT, LIGHTEST, DARKEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN] | |
blend_mode_names = dict(zip(blend_modes, labels)) | |
render_modes = [JAVA2D, P2D, P3D] | |
render_mode = render_modes[0] | |
def setup(): | |
size(300, 1000, render_mode) | |
noLoop() | |
def draw(): | |
background(255) | |
noStroke() | |
colors = [color(255, 0, 0, 255), color(0, 255, 0, 255), color(0, 0, 255, 255)] # R, G, B | |
margin = 20 | |
h_inc = (height - 2*margin) / len(blend_modes) | |
h = margin | |
r = h_inc / 2 | |
fill(0) | |
text("Render Mode: %s" % render_mode, margin, margin) | |
for blend_mode in blend_modes: | |
pushStyle() | |
blendMode(REPLACE) | |
fill(0) | |
text("Blend Mode: %s (%s)" % (blend_mode_names[blend_mode], blend_mode), margin, h + margin) | |
rect(width/2, h + margin + 1, width, h_inc - margin - 1) | |
popStyle() | |
blendMode(blend_mode) | |
for i, c in enumerate(colors, 1): | |
fill(c) | |
x = 2*margin + .5*i*r | |
y = h + margin/2 + r | |
ellipse(x, y, r, r) | |
ellipse(x + width/2, y, r, r) | |
h += h_inc | |
saveFrame('issue_4376_%s.png' % (render_mode)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment