My incomplete notes from another awesome #CCFestNYC hosted at @ITP_NYU today! #STEMed #CSforAllNYC

#! /usr/bin/env python3
# Make an api call
####### install the needed modules #######
import json, requests
####### url vars #######
api_token = ‘*****my private token*****’
lat = ‘40.7128’
lon = ‘-74.0060’
print(url)
####### make api call #######
data = requests.get(url).json()
####### parse data #######
temp = data[‘currently’][‘temperature’]
wind_speed = data[‘currently’][‘windSpeed’]
print(temp)
print(wind_speed)

var chosenCaption;
var fontColor;
var fontSize;
var chosenFont;
var fonts = [“Helvetical”,”Impact”,”Courier”]
var captions=[“Words matter.”,”#LoveTrumpsHate”,”What, me worry?”,”All the feelz.”,”I woke up like this.”,”Nevertheless, she persisted.”]
var kid1;
var kid2;
var kid3;
var kid4;
var kid5;
var images;
var chosenImage;

function preload(){
kid1=loadImage(“DT1.jpg”)
kid2=loadImage(“DT2.jpeg”)
kid3=loadImage(“DT3.jpeg”)
kid4=loadImage(“DT4.jpg”)
kid5=loadImage(“DT5.png”)
}

function setup() {
createCanvas(400, 400);
images=[kid1,kid2,kid3,kid4,kid5];
pickRandom();
}

function draw() {
background(220);
image(chosenImage,0,0,width,height);
textFont(chosenFont);
textSize(fontSize);
fill(fontColor);
strokeWeight(3);
stroke(255);
text(chosenCaption,20,height/2,300,200);
}

function mouseClicked(){
pickRandom();
}

function pickRandom(){
chosenImage = images[floor(random(images.length))]
chosenCaption = captions[floor(random(captions.length))]
chosenFont = fonts[floor(random(fonts.length))]
fontColor = color(random(255),random(255),random(255))
fontSize = random(20,45)
}

 

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s