Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: Blog
Views: 68
%html Author: Vincent J. Matsko<br /> Date: 4 September 2015, Day002<br /> Post: Josef Albers and Interaction of Color
Author: Vincent J. Matsko
Date: 4 September 2015, Day002
Post: Josef Albers and Interaction of Color
Interact: please open in CoCalc
# This code snippet explores the color contrast of Josef Albers. # Slide the r, g, and b controls to change color of the interior rectangles. # Slide the deltar, deltag, and deltab controls to change the colors of the exterior rectangles. # Note how the colors are defined for S1 and S2! # To use, place your cursor anyone in the code, then hit shift+enter - hold down the shift key, and while you're holding it, hit the enter key. # Hitting shift and enter separately won't work! # # NOTE: To get an "Albers" effect, make sure your delta values aren't too large. See the blog post for more comments. # Negative RGB values become 0, and values greater than 1 are truncated to 1. def RGBValue (value): if value < 0: return 0 else: if value > 1: return 1 else: return value # Changing "True" to "False" in the next line will allow you change ALL the sliders and then press an Update button. # However, the most recent image disappears when you do this. @interact(auto_update=True) def _(r=slider(0, 1.0, default=0.5, step_size=0.01, width=30), # Will default to neutral gray. g=slider(0, 1.0, default=0.5, step_size=0.01, width=30), b=slider(0, 1.0, default=0.5, step_size=0.01, width=30), deltar=slider(0, 1.0, default=0, step_size=0.01, width=30), deltag=slider(0, 1.0, default=0, step_size=0.01, width=30), deltab=slider(0, 1.0, default=0, step_size=0.01, width=30)): P1 = plot(polygon2d([[0.15,0.15],[0.15,0.85],[0.35,0.85],[0.35,0.15]], rgbcolor=(r,g,b))) P2 = plot(polygon2d([[0.65,0.15],[0.65,0.85],[0.85,0.85],[0.85,0.15]], rgbcolor=(r,g,b))) S1 = plot(polygon2d([[0,0],[0,1],[0.5,1],[0.5,0]], rgbcolor=(RGBValue(r - deltar), RGBValue(g - deltag), RGBValue(b - deltab)))) S2 = plot(polygon2d([[0.5,0],[0.5,1],[1,1],[1,0]], rgbcolor=(RGBValue(r + deltar), RGBValue(g + deltag), RGBValue(b + deltab)))) show(S1 + S2 + P1 + P2, aspect_ratio=1, axes=False)
Interact: please open in CoCalc