GMU:Bots 'n' Plots/Shubhra Bhatt: Difference between revisions

From Medien Wiki
No edit summary
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 2: Line 2:
*E-mail : shubhra.bhatt@uni-weimar.de
*E-mail : shubhra.bhatt@uni-weimar.de
*Works Examples : http://www.openprocessing.org/user/45747
*Works Examples : http://www.openprocessing.org/user/45747
==== News Graffiti Twitter Bot ====
The News Graffiti Twitter Bot places speech bubbles on the images taken from the news accounts on twitter.
[[Image:Screen_Shot_2015-10-19_at_12.30.52_am.png]]
====  Screen Shot ====
[[Image:Screen_Shot_2015-10-19_at_1.20.42_am.png]]
==== Timeline conversation between Tony Blair & David Cameron ====
[[Image:Screen_Shot_2015-10-19_at_1.13.43_am.png]]
== code ==
The Bot is divided in to two parts.
1)  Placing the speech bubble on the images<br>
2) Posting the images on the Twitter <br>
following is the code for the first part.
[http://pastebin.com/JPw0gKAf link to the code] <br>


==== First Python Image ====
==== First Python Image ====


[[Image:My Bot-Bot.png]]
[[Image:My Bot-Bot.png]]
==Code ==
"""
My Bot-Bot
"""
def setup():
    size(400, 400)
    background(250, 250, 250)
    noStroke()
    fill(250, 138, 120)
    global pX
    pX = width/2
    global pY
    pY = 80
def draw():
    background(250, 250, 250)
        # Head , Eye & Body
    triangle(pX, pY + 80, pX - 80, pY, pX + 80, pY)
    fill(250, 240, 250)
    ellipse(pX - 20, pY + 20, 10, 10)
    ellipse(pX + 20, pY + 20, 10, 10)
    rect(pX - 10, pY + 50, 20, 4)
   
    fill(250, 138, 120)
        # Left Arm
    pushMatrix()
    translate(pX - 50, pY + 80)
    rect(0, 0, 100, 150)
    triangle(0, 0, -50, 80, -60, 50)
    ellipse(50, 180, 80, 80)
    fill(250, 240, 250)
    ellipse(50, 180, 60, 60)
   
        # Right Arm
    popMatrix()
    fill(250, 138, 120)
    pushMatrix()
    translate(pX + 50, pY + 80)
    scale(-1, 1)
    triangle(0, 0, -50, 80, -60, 50)
    popMatrix()   
    saveFrame("My Bot-Bot.png")
==== First Python Animation ====
[[File:AnimatedBot.gif]]
==Code ==
"""
My Bot-Bot animation
"""
def setup():
    size(400, 400)
    background(250, 250, 250)
    stroke(255, 240, 250)
    fill(250, 138, 120)
    global pX
    pX = 80
    global pY
    pY = 80
    global prV
    prV=10
   
def draw():
    bgR = random(50,200)
    bgG = random(50,150)
    bgB = random(240,250)
    background(bgR,bgG,bgB)
    global prV
    global pX
    if pX>0 and pX<width:
      pX=pX+10
    elif pX>width:
        pX=pX-100
    else:
        pX=80   
        # Head , Eye & Body
    triangle(pX, pY + 80, pX - 80, pY, pX + 80, pY)
    fill(250, 240, 250)
    ellipse(pX - 20, pY + 20, 10, 10)
    ellipse(pX + 20, pY + 20, 10, 10)
    rect(pX - 10, pY + 50, 20, 4)
   
    fill(250, 138, 120)
        # Wheel
    pushMatrix()
    translate(pX - 50, pY + 80)
    rect(0, 0, 100, 150)
    ellipse(50, 180, 80, 80)
    fill(bgR, bgG, bgB)
    ellipse(50, 180, 60, 60)
    fill(250, 138, 120)
        # Left Arm
    rotate(-PI/8 * sin(frameCount * 0.1))
    triangle(0, 0, -50, 80, -60, 50)
   
   
        # Right Arm
    popMatrix()
    fill(250, 138, 120)
    pushMatrix()
    translate(pX + 50, pY + 80)
    rotate(PI/8 * sin(frameCount * 0.1))
    scale(-1, 1)
    triangle(0, 0, -50, 80, -60, 50)
    popMatrix()
    delay(80)
    saveFrame("bot###.png")

Latest revision as of 23:22, 18 October 2015

Shubhra bhatt

News Graffiti Twitter Bot

The News Graffiti Twitter Bot places speech bubbles on the images taken from the news accounts on twitter.

Screen Shot 2015-10-19 at 12.30.52 am.png

Screen Shot

Screen Shot 2015-10-19 at 1.20.42 am.png


Timeline conversation between Tony Blair & David Cameron

Screen Shot 2015-10-19 at 1.13.43 am.png

code

The Bot is divided in to two parts. 1) Placing the speech bubble on the images
2) Posting the images on the Twitter

following is the code for the first part.

link to the code


First Python Image

My Bot-Bot.png

Code

""" My Bot-Bot """

def setup():

   size(400, 400)
   background(250, 250, 250)
   noStroke()
   fill(250, 138, 120)
   global pX
   pX = width/2
   global pY
   pY = 80

def draw():

   background(250, 250, 250)
       # Head , Eye & Body
   triangle(pX, pY + 80, pX - 80, pY, pX + 80, pY)
   fill(250, 240, 250)
   ellipse(pX - 20, pY + 20, 10, 10)
   ellipse(pX + 20, pY + 20, 10, 10)
   rect(pX - 10, pY + 50, 20, 4)
   
   fill(250, 138, 120)
       # Left Arm
   pushMatrix()
   translate(pX - 50, pY + 80)
   rect(0, 0, 100, 150)
   triangle(0, 0, -50, 80, -60, 50)
   ellipse(50, 180, 80, 80)
   fill(250, 240, 250)
   ellipse(50, 180, 60, 60)
   
       # Right Arm
   popMatrix()
   fill(250, 138, 120)
   pushMatrix()
   translate(pX + 50, pY + 80)
   scale(-1, 1)
   triangle(0, 0, -50, 80, -60, 50)
   popMatrix()    
   saveFrame("My Bot-Bot.png")


First Python Animation

AnimatedBot.gif

Code

""" My Bot-Bot animation """

def setup():

   size(400, 400)
   background(250, 250, 250)
   stroke(255, 240, 250)
   fill(250, 138, 120)
   global pX
   pX = 80
   global pY
   pY = 80
   global prV
   prV=10 
   

def draw():

   bgR = random(50,200)
   bgG = random(50,150)
   bgB = random(240,250)
   background(bgR,bgG,bgB)
   global prV
   global pX
   if pX>0 and pX<width:
      pX=pX+10
   elif pX>width:
       pX=pX-100
   else:
       pX=80    
       # Head , Eye & Body
   triangle(pX, pY + 80, pX - 80, pY, pX + 80, pY)
   fill(250, 240, 250)
   ellipse(pX - 20, pY + 20, 10, 10)
   ellipse(pX + 20, pY + 20, 10, 10)
   rect(pX - 10, pY + 50, 20, 4)


   fill(250, 138, 120)
       # Wheel
   pushMatrix()
   translate(pX - 50, pY + 80)
   rect(0, 0, 100, 150)
   ellipse(50, 180, 80, 80)
   fill(bgR, bgG, bgB)
   ellipse(50, 180, 60, 60)
   fill(250, 138, 120)
       # Left Arm
   rotate(-PI/8 * sin(frameCount * 0.1))
   triangle(0, 0, -50, 80, -60, 50)
   
   
       # Right Arm
   popMatrix()
   fill(250, 138, 120)
   pushMatrix()
   translate(pX + 50, pY + 80)
   rotate(PI/8 * sin(frameCount * 0.1))
   scale(-1, 1)
   triangle(0, 0, -50, 80, -60, 50)
   popMatrix()
   delay(80)
   saveFrame("bot###.png")