mirror of
https://github.com/Xevion/processing-projects.git
synced 2025-12-06 01:15:57 -06:00
Gradients project
This commit is contained in:
50
visuals/Gradients/Gradients.pyde
Normal file
50
visuals/Gradients/Gradients.pyde
Normal file
@@ -0,0 +1,50 @@
|
||||
import pprint, random, colorsys
|
||||
|
||||
def blend(fromRGB, toRGB, midpoints=10):
|
||||
arr = []
|
||||
R1, G1, B1 = fromRGB
|
||||
R2, G2, B2 = toRGB
|
||||
Rdiv = (R1 - R2) / float(midpoints)
|
||||
Gdiv = (G1 - G2) / float(midpoints)
|
||||
Bdiv = (B1 - B2) / float(midpoints)
|
||||
for x in range(floor(midpoints+1)):
|
||||
R = R1 - (Rdiv * x)
|
||||
G = G1 - (Gdiv * x)
|
||||
B = B1 - (Bdiv * x)
|
||||
arr.append((R, G, B))
|
||||
return arr
|
||||
|
||||
def rndTuple(n):
|
||||
return random.randint(0, n), random.randint(0, n), random.randint(0, n)
|
||||
|
||||
def HSVtuple():
|
||||
preH, preS, preV = random.randint(0, 360) / 360.0, 1, 1
|
||||
preR, preG, preB = colorsys.hsv_to_rgb(preH, preS, preV)
|
||||
return preR * 255, preG * 255, preB * 255
|
||||
|
||||
def regen():
|
||||
global arr, precision
|
||||
precision = 1000.0
|
||||
# Generated via RGB randomization
|
||||
RGB1, RGB2 = rndTuple(255), rndTuple(255)
|
||||
|
||||
# Generated via HSV to RGB randomization
|
||||
RGB1, RGB2 = HSVtuple(), HSVtuple()
|
||||
arr = blend(RGB1, RGB2, midpoints=precision)
|
||||
|
||||
def setup():
|
||||
size(1000, 1000)
|
||||
regen()
|
||||
|
||||
pp = pprint.PrettyPrinter()
|
||||
|
||||
def draw():
|
||||
global arr, precision
|
||||
xDiv = width/precision
|
||||
for x in range(floor(precision)):
|
||||
fill(*arr[x])
|
||||
stroke(0, 0, 0, 0)
|
||||
rect(0, x * xDiv, width, (x + 1) * xDiv)
|
||||
|
||||
def mouseClicked():
|
||||
regen()
|
||||
2
visuals/Gradients/sketch.properties
Normal file
2
visuals/Gradients/sketch.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
mode=Python
|
||||
mode.id=jycessing.mode.PythonMode
|
||||
@@ -8,4 +8,6 @@ All my projects attempting to create vivid or interesting visuals using the Proc
|
||||
|
||||
- **CircleIntersection** Plots circles in places where others aren't, expoonentially becoming slower and slower with each successfully located spot. Somewhat buggy and needs tuning to become much faster using a better algorithm, and probably better methods for deciding where spots are (less random, more organized manner).
|
||||
|
||||
- **EquilateralTriangle** Places squares in increasing size whilst rotating.
|
||||
- **EquilateralTriangle** Places squares in increasing size whilst rotating.
|
||||
|
||||
- **Gradients** Builds simple linear RGB gradients from 1 random color to another.
|
||||
Reference in New Issue
Block a user