18
15
u/Sirmikon Jan 18 '20
Cool. I love stuff like this! Nice job!
(Chernoff Faces immediately spring to mind as an orthinological application for this! Basically, instead of pure random generation, link different bird features with data from a real dataset.
You could model birds’ sizes based on weight, feather color based on habitat, eye size based on intelligence, talon type based on diet, etc...
It would be really cool to see how the algorithm would draw different birds.
9
u/thebuffed Jan 18 '20
I am extremely interested in this, I'll have to look into gathering some data or hitting an API for bird attributes. Thanks for pointing this out!
8
u/bens1989 Jan 18 '20
I did a bit of sleuthing for bird info. With a minor adjustment to the ebird API, I got it to send me back data on all of their birds (16.5k results). Some of the data might be helpful, but disappointingly it does not give things like weight, height, etc.
import requests
import json
import pandas as pd
df = pd.DataFrame(json.loads(requests.get(r'https://api.ebird.org/v2/ref/taxonomy/ebird?fmt=json&locale=en_US').content))
df.to_excel('bird_data.xlsx')2
1
u/ericonr Jan 19 '20
Does request cache stuff? It's probably faster to download that dataset just once, right?
1
u/bens1989 Jan 19 '20
No requests doesn’t cache. You can write the content to a file. I formatted the content as a dataframe and then wrote it to a spreadsheet. After the first call you can just read from the file.
2
6
6
u/gibran800 Jan 18 '20
This is really, really amazing! Just one question, I was looking at the source code and I noticed that your file has a .pyde extension. What's the difference between that and the regular .py? Thanks!
11
u/thebuffed Jan 18 '20
Thank you so much! Yeah, .pyde is the the file that Processing runs through it's python module. I think it's built off of something called Jython, so you're writing Python code, but you have access to Java libraries. I guess it's not "pure" python, but working with graphic libraries like pycairo and pillow is significantly more complicated than using Processing.
4
3
u/Verslizzle Jan 18 '20
Nice work. How did you come up with this idea and where do you plan on taking it?
4
u/thebuffed Jan 18 '20
Thanks! I randomly came across these designs and thought they seemed perfect for some generative work. I will probably keep messing around with some of the settings and colors, but mostly I just want some cool posters
39
u/Tweak_Imp Jan 18 '20
Now create pythons!
59
u/EquationTAKEN Jan 18 '20
print("_______/")16
u/conventionistG Jan 18 '20
echo "ssssssssssssSSSSSSsssssss"
15
5
1
u/Casseroli Jan 19 '20
Oh my god this is so awesome! Projects like this really motivate me a lot to learn more python!
2
1
u/brrrbrbr Jan 19 '20
Amazing work. I’m a beginner and was looking for projects and generative art seems really interesting!
1
u/thebuffed Jan 19 '20
Thanks! You should totally try it out, there's a lot of great beginner tutorials, and then you just let your imagination go wild
1
3
2
u/PharoahChromium Jan 18 '20
Wow! This is super cool! It is always great to see projects that merge the tech and art. Thank you for sharing.
2
2
2
u/eli_mintz Jan 20 '20
Very nice!
Perhaps you could do this also using SVG (https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg) in addition to Processing and then generate images that can be viewed in a browser. Just something to think about.
1
1
1
1
1
Jan 19 '20
Very cool! Here's a decorator for the sticky cycling if you want
def sticky(frequency):
""" regenerate value frequency% of the time """
def dec(func):
stored = [func()]
def inner():
if random.random() < frequency:
stored[0] = func()
return stored[0]
return inner
return dec
@sticky(0.1)
def color():
return random.choice(['red', 'black', 'green'])1
u/kwelzel Jan 19 '20
Why should stored be a list if it only holds one value?
1
Jan 19 '20
It's an old scope hack for python2. In python3,
def sticky(frequency): def dec(func): stored = func() def inner(): nonlocal stored if random.random() < frequency: stored = func() return stored return inner return decwill work instead
1
u/kwelzel Jan 19 '20
Ahh, good to know
1
Jan 19 '20 edited Jan 19 '20
I've never used processing before this but after installing the processing.py extension and when executing the .pyde from the processing GUI, I see
import sys sys.version2.7.1 (v2.7.1:dd7e191d4c90+, Sep 24 2017, 10:11:23)which isn't even my system default (2.7.15) or the python that it should find if it's reading my $PATH correctly (3.8.0)
(apparently it's running jython and wont have access to any packages I install)
1
1
1
u/monsto Jan 19 '20
The Partridge Fambly called.
On further reflection, how fucking old am I jesus H.
1
u/--_-__-__l-___-_- Jan 18 '20
This could be the idea that starts an empire. You just need to find the right business partner...
0
Jan 18 '20
[deleted]
1
u/thebuffed Jan 18 '20
Thanks for the tip!
2
u/kwelzel Jan 19 '20
Your
draw_linesmethod is also unnecessarily complicated:The following lines are all the same if
p1[0] != p3[0]first_x_sep = sqrt(pow(p1[0] - p3[0], 2))/lines * first_x_adj first_x_sep = abs(p1[0] - p3[0])/lines * first_x_adj first_x_sep = abs(p1[0] - p3[0])/lines * (p3[0] - p1[0])/abs(p3[0] - p1[0]) first_x_sep = abs(p1[0] - p3[0]) * (p3[0] - p1[0])/abs(p3[0] - p1[0]) / linesNow
(p3[0] - p1[0])/abs(p3[0] - p1[0])gives you the sign ofp3[0] - p1[0](+1 if positive and -1 if negative) and by multiplying it withabs(p1[0] - p3[0])you get a number which has the absolute value ofp1[0] - p3[0]with the sign ofp3[0] - p1[0], but this number is justp3[0] - p1[0]itself.So I propose you get rid of the
_adjvariables and just writefirst_x_sep = (p3[0] - p1[0]) / linesFortunately, this also works for the
p1[0] == p3[0]case, because you don't need to divide by zero
0
Jan 18 '20
[deleted]
2
u/thebuffed Jan 18 '20
Yeah! It's essentially the same thing as the Java processing, but you get to write in Python! Also there is P5.js, which is processing for javascript!
0
80
u/thebuffed Jan 18 '20 edited Jan 18 '20
Trying to replicate the style of these designs, but in a generative way. Work in progress, but pretty happy so far
Source code: https://github.com/erdavids/Birds-of-a-Feather
More projects: https://github.com/erdavids/Generative-Art