Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Generative Art
-
Greetings all,
I am a studying maritime engineer, and the increasing relevance and importance of software engineering has driven me to make this foray into a new language.
I’m completely fresh into this, however a trusted friend and software engineer recommended learning Python - as a result I’ve begun completing Al Sweigart’s Encryption/Decryption book while using Pythonista. This same friend also reiterated Sweigart’s advice that I take on some sort of personal interest project in order to better engage and build literacy while using the system.
Recently, I visited a generative art gallery in Austin, TX, and after a little digging, have decided I wish to create kaleidoscopic-type images (understanding full-well that ‘normal’ shapes may be the best starting point).
So, how can I best get started? Thanks!
tl;dr: I want to start making generative art while learning Python. Advice??
-
Hello
The book "Doing Math With Python" has a chapter on drawing shapes and Fractals. Also some Mandelbrot stuff. I like this book because of the different examples.
Good luck on your quest
-
@VOdestroyers @zacbir created a framework that may be of some use:
https://github.com/zacbir/geometer/blob/master/README.md
You should also look at the ui.Path and ui.draw documentation.
-
I made a tree drawing thing a couple of years when I saw this vid, I recommend checking out some of his other videos, they aren’t in python but it’s some really nice concepts and he explains them in terms that can translate to other languages
from ui import ImageContext, Path, set_color, fill_rect from math import sin, cos, pi from random import random #help(random) def r(x, y, t): # t = t +(random() -0.5)*0.5 return x*cos(t) - y*sin(t), y*sin(t) + x*cos(t) class tree: def __init__(self): self.startlen = 50 self.maxit = 9 self.th = 5*pi/4 self.thl = pi/12 self.thr = -pi/12 self.p = Path() self.short = 0.85 self.size = 1000 def draw(self): self.p = Path() self.stopn = self.startlen * (self.short ** self.maxit) with ImageContext(self.size, self.size) as cx: set_color((255,255,255)) fill_rect(0,0,self.size, self.size) set_color((0,0,0)) self.p.line_width = 0.9 self.p.move_to(self.size/2, self.size) self.branch(self.startlen, self.size/2, self.size*4/5, 5*pi/4) self.p.stroke() cx.get_image().show() def branch(self, len, x, y, t): self.p.line_to(x, y) if len > self.stopn: self.p.move_to(x,y) x1, y1 = r(len, len, self.thl+t) self.branch(len*self.short, x+x1, y+y1, self.thl+t) self.p.move_to(x,y) x1, y1 = r(len, len, self.thr+t) self.branch(len*self.short, x+x1, y+y1, self.thr+t) #self.branch(len*self.short, x+x1, y+y1, self.thr+t) self.p.move_to(x,y) if __name__ == '__main__': s = tree() #s.thl += 0.25 #for i in range(100): s.draw()