Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions random_art.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import random

from math import cos, sin, tan, pi, sqrt


import random
# Your job is to create better version of create_expression and
# run_expression to create random art.
# Your expression should have a __str__() function defined for it.
Expand All @@ -8,9 +11,41 @@
def create_expression():
"""This function takes no arguments and returns an expression that
generates a number between -1.0 and 1.0, given x and y coordinates."""
expr = lambda x, y: (random.random() * 2) - 1
return expr
p = [.0987665432, .06793, sin(-1), cos(-1), -0.0000567, .08,]
circle = 2 * pi + .0987654321
triangle = random.triangular()
l = 2 * random.choice(p) - 1
w = cos(-1) * sin(1) + pi
g = random.random() - cos(2) - sin(1)
m = -2 / 23
z = cos(random.triangular())* sin(random.randint(1, 1))

def another_expression(x, y):
square = random.random() * x * -6 * y/3 % .123456789 - y / z % cos(0) - 2
return sin(square*2 + l**2) % (cos(circle**-1/2 - z)) + random.randint(-1,1) % tan(triangle*1/2 - circle)

return another_expression








#def nuts_expression(x,y):
#return (sin(-1) + cos(1))

#def ultimate_function(x,y):

#return tan(-1) - 1
#return ultimate_function()


#return crazy_expression

#return expr
#expr = lambda x, y: (random.random() * 8**2) - 1

def run_expression(expr, x, y):
"""This function takes an expression created by create_expression and
Expand Down