Mapping to Kinect!

I connected to the kinect platform for the first time ever. And it was a delightful experience, finally a breakthrough after many hours hitting walls.

While I may not end up using the kinect at all - it is for my final project where I intend to allow an individual to "fly" by flapping their arms, and leaning. This will control a bird on the screen that flies around a pre-made terrain.  Not sure where to begin with 3D, so it might end up being a different game with similar actions. I believe I can execute a similar solution using accelerometers and distance sensors. However the kinect is cool. As you can see, though, it does respond quite slowly to my movements - but that's probably just my machine.

Here's a video:

Application Program Interfaces - APIs - The Holy Grail

This is really what I've been waiting for. Finally being able to access the treasure trove of information at our fingertips is very exciting. I feel like this is the first time I can really get my hands dirty into what I came here to do - combining life sciences with computer science in some way... whatever way. 

One of the examples given was weather.com, saying it had plenty of APIs that were well documented and it was a popular site to use. I figured it must have something related to pollution, and lo and behold I was right. Their API for pollution is cool, and I figured out how to do something with it at least. I made a graph of the carbon monoxide mixing ration in New York City. Check it out! Looks like at least on the CO front we're safe for now :)

Oh and I had to figure out how to map the values using log(), that was actually kind of fun, even if it was a little bit tedious and involved a good amount of guess and check. But once figured out it looks so nice and neat! Still wondering how to stop the array at the end of the reading the values. I set it arbitrarily to end at a value I knew to be larger than the values present so when it gets to one beyond the available in the array - the code just stops.  Also, wanted to put more data on the page, and make it editable and responsive, but that task was a little offset by my Pcomp midterm - so perhaps it will happen this Friday at the ICM hackathon!

Source code:

var pollution;
var latANDlong = "10,74"

function setup() {
    createCanvas(400, 1200);
    background(180, 230, 255);
    textAlign(CENTER)
    var url = 'http://api.openweathermap.org/pollution/v1/co/' + latANDlong + '/current.json?appid=86b1f68187923c62492ece8193264951'

    loadJSON(url, gotData)

    textAlign(RIGHT)
    text("Carbon Monoxide mixing ratio\nof New York City", width / 1.01, 280)
    textSize(12)

    text("Levels of CO above\n12,800 ppm are deadly\n12,800ppm = 0.0128", width / 1.01, 330)
    pop()

}

function gotData(data) {
    pollution = data;
}

function draw() {
    fill(0)

    if (pollution) {
        for (var i = 0; i < 45; i++) {

            // syntax for .length of string?

            var pressure = pollution.data[i].pressure
            var COlevel = pollution.data[i].value
            var loggedP = log(pressure)
            var Ypos = map(loggedP, -12, 7, height - 50, 10)
            var Height = map(COlevel, 0, 0.0000003, 0, width / 1.5)
            line(180, Ypos, 180 + Height, Ypos);
            push()
            textSize(8)
            textAlign(LEFT)
            text("Pressure: " + pressure + "\nCO Level: " + COlevel, 20, Ypos)
            pop()

            // Find Sea Level

            if (pressure == 1) {
                push()
                fill(100, 200, 255)
                textSize(22)
                textAlign(CENTER)
                text("Sea Level", width - 70, Ypos - 5)
                strokeWeight(3)
                stroke(100, 200, 255)
                line(width, Ypos, width - 150, Ypos, 10);
                pop();

            }

        }
    }
}

Source: http://alpha.editor.p5js.org/samchasan/ske...

Object oriented programming

Using a for loop we were able to create many things from a simple line of code. Now, using objects, we can do the same, just a bit more powerful. If I understand it correctly, a for loop is helpful for replicating one thing many times, but if you want some nuance and unique elements to each thing you are creating, you need objects. See my examples below.

The big accomplishment here is using arrays to distinguish one object from another, and using a for loop within object creation to get separate instances of the same object - but with different parameters. 

Next up, adding real interactive elements, but first, got to get the bucket working! And I don't know what I'm to do about the party confetti, just that it was fun to make, and a good test, as it is the same problem/solution as the raindrops.

Getting Interactive

The whole point of this program is not to learn how to build websites, but to go beyond the tools learned to create inspiring stories via whatever means best suited. In my opinion, games are a fantastic avenue for this, so it suits me to whip up some fun codes that can be enjoyed repeatedly. These games have plenty of work to be added - scoring functions, stop/start buttons, power ups/downs, levels, game ends, etc. But still fun to get some proof-of-concepts down!

The Cleaner - Wipe away the marks as they appear!  // <s>

Raindrops - position the box using the mouse to catch the rain// <s>

This is just a slider, but it's still fun, and I was happy to get the logic right so the slider stayed in the right spot, and something happens as a result of sliding the slider.  // <s>

Learning Logic

Wow. What a week it's been. Learning through the logic of variables, loops, and objects allowed me to really get into the weeds this week and thoroughly enjoy myself. Nothing I made is particularly useful, but it makes good use of plenty we learned this week - for some interesting results. Again, nothing I'm trying to do ad infinitum, but I find I do learn better if I involve a little bit of play. Kind of went to town. Enjoy! 

Examples of some little javascripts I created. Click on the links to view the individual works and edit the code.

gradient // disco balls // shapes appear // rainbow with cloud // click the box // scroll over the box // bouncing ball // colorful somewhat responsive animation // responsive generative art

This week's question was: What do computers call their fathers? To that I do not have a good answer.

We humans often call the fathers of computers ‘parents,’ as we tend to anthropomorphize anything remotely similar to what we can perceive. But what do computers themselves call their fathers, or mothers? Probably nothing.

What does a stone call the boulder it was chipped from?

What does the carbon dioxide that escapes my lungs call me?

Again, nothing. Because they don’t have the ability to do anything other than respond to external forces.

So, if anything, a computer would only call its creator that which its creator has programmed it to ‘say’ – meaning it would really simply be creating a noise that we could approximate as close as possible to a word we understand and have a value for.

At the end of the day, we can only program machines to do exactly what we program them to do, so if we really wanted, we could have these machines call us ‘Hero’ or ‘Luke Skywalker’ or ‘Your Great Majesty, Ruler of All that is Holy, Protector of the Earth and all its Inhabitants, First of Your Name, Last of the First Humans, The Magnificent, The Gracious, The Wise’ – if we were that egotistical.

Or maybe I’m wrong, computers do have a true and consistent for the title for their fathers, and I’m simply missing something.

Why to Code?

The answers are here. So why do I want to code?

Do I want to do stuff like this?  Or like a Mondrian?

Tihs was more fun as I modded the colors to get a cool blue. I like blue. It's cool.&nbsp;

Tihs was more fun as I modded the colors to get a cool blue. I like blue. It's cool. 

I modded the zombie to make it a bat... but I could have easily made this in Illustrator. For a much more interesting result.&nbsp; And again, after messing with these shapes for a while. I became frustrated. Being used to shape building in a much more efficient manner this tedium really got to me. This is probably why I am much happier with my drawings which kind of get around the prompt rather than address it head on - they were quick, simply, and produced a beautiful result. I already know this is something I will need to fight back against the entire time I am at ITP. But I think it will be easier when the problems stray further from my area of expertise.

I modded the zombie to make it a bat... but I could have easily made this in Illustrator. For a much more interesting result.  And again, after messing with these shapes for a while. I became frustrated. Being used to shape building in a much more efficient manner this tedium really got to me. This is probably why I am much happier with my drawings which kind of get around the prompt rather than address it head on - they were quick, simply, and produced a beautiful result. I already know this is something I will need to fight back against the entire time I am at ITP. But I think it will be easier when the problems stray further from my area of expertise.

This i basically copied code - well I still needed to set up HTML - but then I drew. Nice to see something come together.&nbsp;

This i basically copied code - well I still needed to set up HTML - but then I drew. Nice to see something come together. 

Sure. It’s fun, but it’s not really what I’m here to do.

 

To me coding represents as essential middle ground between humans and the rest of nature. We have already converted so many signals from the surrounding world into languages we can read and understand and respond to, I have a distinct hunch that there are tidal waves of obviously helpful technologies just hiding around the corner.

 

And perhaps because of my ego - large, or because of how I view the world – perpetually seeking understanding & simultaneously endlessly creating, or because I know I know so little in this arena, I have a strong feeling that all I need is to be well versed in this subject for me to have a powerful impact. And that naivety is exactly what I need to make such an impact.

 

For we live in a world of fear, of indecision, of simplicity, of ease, of convenience – or at least, that is the American world.

 

And those are not bad things in and of themselves. But together, their compounding negativity is overwhelming.

 

So why coding? Because the opportunities are endless, the power is immense, the capabilities so much more powerful than I in specific ways, and the applications broad. How can I quickly determine what toxins may be present in a body of water, in real time, in different locations? How can I gather energy from a hurricane? How can I power a self-contained sink (I have a quarter bath that contains just a toilet so this is actually a burning question). How can I recycle plastic bags in an efficient way?

 

These are not just complex problems, they are problems with answers that support an ecosystem, they improve life in general, and most importantly they are not human-centered.

 

I want to code ecosystem centered projects, nature centered projects, life-centered proejcts which acknowledge our small role to play in the vastness of this planet. For we are but one player in a seemingly infinite web of organisms, let’s not forget it.