GMU:Bots 'n' Plots/Constantin Oestreich

From Medien Wiki
< GMU:Bots 'n' Plots
Revision as of 06:40, 16 June 2015 by ConstOest (talk | contribs) (Midtermbot)

Page of Constantin Oestreich

Twitter: @ConstOest

 

Animated Robot

 

Thumb doesnt work - find it here:

Animated Robot: [1]

Robot Code


"""

My Animated Robot

"""

#Variablen

widthBox = 400
heightBox = widthBox
centerx = widthBox / 2
centery = heightBox / 2
koerper = widthBox / 3
kopf = koerper / 1.5
auge = kopf / 6
blauKopf = 0
gruenKopf = 90
rotKopf = 100



#Ausgabe

def setup():
    size (widthBox,heightBox)
    colorMode (RGB, 100)


def draw():
    
    #Moving per Frame
    frameRate (25)
    angle = PI/8 * sin(frameCount * 0.1)
    
    #Growing Up
    
    global auge
    if auge<30:
        auge=auge+2
    else:
        auge=10
        
    global kopf
    if kopf<140:
        kopf=kopf+2
    else:
        kopf = koerper / 1.5
        
    global blauKopf
    global gruenKopf
    global rotKopf    
    if kopf>koerper / 1.5 and kopf<130:
        blauKopf = blauKopf + 5
        gruenKopf = gruenKopf -2
        rotKopf = rotKopf -2
    
    elif kopf > 130 and kopf < 140:
        blauKopf = 0
        gruenKopf = 0
        rotKopf = 100
        
    else:
        blauKopf=0
        gruenKopf = 90
        rotKopf = 100   
    
    #Variablen BG
    R = random(30,60)
    G = random(50,80)
    B = random(70,90) 
    
    #Variablen Fill
    RF = random(20,50)
    GF = random(0,30)
    BF = random(10,40)
    
    #define
    background(R,G,B)
    rectMode(CENTER)
    fill (RF,GF,BF)
    stroke (90)
    strokeWeight(5)    

    #---Körper---
    rect (centerx, centery, koerper, koerper)

    #---Kopf---
    pushStyle()
    fill (rotKopf, gruenKopf, blauKopf)
    ellipse (centerx, centery-koerper+(kopf*0.25), kopf, kopf)
    popStyle()
    
    # Variablen Auge
    
    AugeX1 = centerx - 17
    AugeY1 = centerx - koerper*0.875
    AugeX2 = centerx + 17
    AugeY2 = centerx - koerper*0.875
    
    #---Auge01---
    
    drawAuge(AugeX1, AugeY1, 1)
    
    
    #---Auge02---
    
    drawAuge(AugeX2, AugeY2, -1)
    
    # Arm positions
    posLx = centerx - koerper / 2
    posLy = centery - koerper / 2
    posRx = centerx + koerper / 2
    posRy = centery - koerper / 2
    
    # Bein positions
    posBLx = centerx - koerper / 2
    posBLy = centery + koerper / 2
    posBRx = centerx + koerper / 2
    posBRy = centery + koerper / 2
    
    #---Left Arm---
    drawArm(posLx-30, posLy-15, 1, angle)
    
    #---Right Arm---
    drawArm(posRx+30, posRy-15, -1, angle) 
    
    #---Bein Links---
    drawBein(posBLx, posBLy)
    
    #---Bein Rechts---
    drawBein(posBRx-40, posBRy)
  
      
#Eigene Funktionen

def drawAuge (xpos, ypos, direction):
    pushMatrix()
    pushStyle()
    fill (80,80,100)
    stroke (40)
    strokeWeight(2) 
    translate (xpos, ypos)  
    scale(direction,1) 
    ellipse (0,0,auge,auge)  
    popStyle()           
    popMatrix()

def drawArm (xpos, ypos, direction, angle):
    pushMatrix()
    translate(xpos,ypos)
    scale(direction,1)
    rotate(angle)
    rectMode(CORNER)
    rect(0,0,30,130)
    popMatrix()
    
def drawBein (xpos, ypos):
    pushMatrix()
    pushStyle()
    fill(10,10,40)
    translate(xpos,ypos)
    rectMode(CORNER)
    rect(0,0,40,90)
    popMatrix()
    popStyle()
    
    
    saveFrame("robot_const_###.png")
    


Midtermbot


"""

midtermbot.py

"""

###Import###

#Import Modules for Project
from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageColor
import tweepy
import time
import random
import requests
from io import BytesIO

#Import aus Dateien
from twitterkeys import *
from textposts import text
from imagefuncs import blur, emboss, edges, invert, transpose

##############
###Programm###
##############

###Twitter connect###

#TwitterPassVariable for Test without posting on Twitter
#True = Post on Twitter / False = just open Image and show text local
check = False

#Define TwitterKeys to variables
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.secure = True
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

#Find Images and URL in Account on Twitter
timeline = api.user_timeline(screen_name = "C64_Bot") 
for tweet in timeline: 
   for media in tweet.entities.get("media",[{}]):
    if media.get("type",None) == "photo":
        url = media["media_url"]

###Load Image from URL###
#"http://maui.hawaii.edu/tlc/wp-content/uploads/sites/53/2013/11/testing.jpg"
response = requests.get(url)
image = Image.open(BytesIO(response.content))

#Test Bild laden
#image = Image.open("test.png")

#Liste der verschiedenen Funktionen erstellen
functions_list = [blur, emboss, edges, invert, transpose]

#Mainfunction
if __name__ == "__main__":    
    
    #Random eine Funktion aufrufen
    imagefunc = random.choice(functions_list)
    #Random Funktion anwenden
    image = imagefunc(image)
    
    #2.Runde Random Filter anwenden
    #Random eine Funktion aufrufen
    imagefunc = random.choice(functions_list)
    #Random Funktion anwenden
    image = imagefunc(image)
    
    if check == True:
        filename = "final.png"
        image.save(filename)
        api.update_with_media(filename,text)  
    
    else:
        image.show()
        print(text)



"""

imagefuncs.py

"""

from PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageColor, ImageEnhance


#verschiedene Bildbearbeitungfunktionen

#Bild blur
def blur (image):
    return image.filter(ImageFilter.BLUR)

def emboss (image):
    return image.filter(ImageFilter.EMBOSS)

def edges (image):
    return image.filter(ImageFilter.FIND_EDGES)

def transpose(image):
    return image.transpose(Image.FLIP_LEFT_RIGHT)

def invert(image):
    return image.point(lambda x: 255-x)



"""

textposts.py

"""

#Import Modules for Project
import random


#Verschiedene Texte die gepostet werden können
a="Yeah, a new Image is Ready"
b="I'am an artist.What you think about?"
c="Uh, which great Effekt"
d="Nice"
e="Thats what I do"
f="Mhmmm, what you mean? Is this art?"
g="Yes I post"
h="I should do an exhibition whith this works."
i="Tell me what you think about."
j="This is my job! Post Pictures..."
k="Funky..."


#Liste mit allen Textinhalten erstellen
text_list = [a, b, c, d, e, f, g, h, i, j, k]


#Zufällige auswahl eines Inhalts
text = random.choice(text_list)