Skip to main content

Disable Images

Processing Sketches

https://mail.google.com/mail/?ui…

66Comments

Processing: How to code least common denominator

Does anyone know how i could write a program to find the least common denominator say between 3 and 4 in processing?

55Comments

processing OOP

I'm having trouble with some objects in processing.
the code should have two objects displayed and moving. but i only see one object displayed and moving. maybe there's something i'm missing. check out the code.

Rule myRule;
Rule myRule1;

void setup() {
size(200,200);
smooth();

//Initialize rule objects
myRule = new Rule(0,100,1);
myRule1 = new Rule(0,110,1);
}

void draw() {
background(255);
//int x1 = 0;
//int y1 = 0;
//Operate Rule object
myRule.move();
myRule.display();
myRule1.move();
myRule1.display();
}

class Rule {

float x;
float y;
float spacing;
float speed;

Rule(float x1, float y1, float s1) {
x = x1;
y = y1;
spacing = 10;
speed = s1;
}

void move() {
x = x + speed;
if((x > width) || (x < 0)) {
speed = speed * -1;
}

}

//Display lines at x location
void display() {
stroke(0);
fill(175);
line(x, height/2, width/2, height/2);
}

}

55Comments

code redesign

so i'm thinking that perhaps the best way to learn some programming is to redesign code. there are some differences between the code below. I believe in the idea of designing one thing and then move on to the next. I've also started working backwards and forwards simultaneously. i think i have a better understanding of what i'm doing that way...perhaps it's a quirk.

notes: i started of using nested parentheses, then adjusting the values. The original code doesn't use nested parentheses (minor point, i guess for my thinking it makes sense! but for the original it isn't required. perhaps not succinct enough in my version.

c1dir = c1dir * -1; //in my version
c1dir * = -1; //in 'official' version

these are obviously not different, but the 'official' version's syntax was a bit perplexing...mine made more sense to me...i guess it was reading the c1dir * that through me off.

let me know what you guys think...beauty is also a criteria!

Here's my version:

float c1 = 0;
float c2 = 255;

float c1dir = 0.1;
float c2dir = -0.1;

void setup() {
size(200, 200);
}

void draw() {
noStroke();

//Adjust values
c1 = c1 + c1dir;
c2 = c2 + c2dir;

//if color 1 is less than 0 or color 1 is greater than 255 reverse direction
if ((c1 < 0) || (c1 > 255)) {
c1dir = c1dir * -1;
}

// if color 2 is less than 0 or color 2 is greater than 255 reverse direction
if ((c2 < 0) || (c2 > 255)) {
c2dir = c2dir * -1;
}

//Draw left rectangle
fill(c1,0,c2);
rect(0,0,100,200);

//Draw right rectangle
fill(c2,0,c1);
rect(100,0,100,200);
}

Here is the official version

// Two variables for color.
float c1 = 0;
float c2 = 255;

// Start by incrementing c1.
float c1dir = 0.1;
// Start by decrementing c2.
float c2dir = -0.1;

void setup() {
size(200,200);
}

void draw() {
noStroke();

// Draw rectangle on left
fill(c1,0,c2);
rect(0,0,100,200);

// Draw rectangle of right
fill(c2,0,c1);
rect(100,0,100,200);

// Adjust color values
c1 = c1 + c1dir;
c2 = c2 + c2dir;

// Instead of reaching the edge of a window, these variables reach the "edge" of color:
// 0 for no color and 255 for full color.
// When this happens the direction is reversed.

// Reverse direction of color change
if (c1 < 0 || c1 > 255) {
c1dir *= -1;
}

if (c2 < 0 || c2 > 255) {
c2dir *= -1;
}
}

44Comments

Boolean variables

I need to understand why or if it is necessary to set the boolean variable to 'false', why not 'true'? confused...

and i've figured out that going with my intuition is pretty much always false...i need to think like a computer...still learning how that goes beyond following instructions...question is "which instructions to set, where? why?

// Boolean variable starts as false
boolean going = false;

// Location of circle
int circleX = 0;
int circleY = 100;

void setup() {
size(200,200);
smooth();
}
void draw() {
background(255);

// Draw the circle
stroke(0);
fill(175);
ellipse(circleX,circleY,50,50);

// Only move the circle when "going" is true
if (going) {
circleX = circleX + 1;
}
}

// Set going to true when the mouse is pressed!
void mousePressed() {
going = true;

1010Comments

processing

so i programmed my first piece of code in processing...but it took about 1.5 hours to code something i probably should have done in minutes. the problem i have is with setting with pixel precision arguments on the screen. i figured if the display window had a pixel grid of say 10px intervals, that would help tremendously. anyway, how do i solve spending hours figuring out where to place /*Draws body of creature */ in my code unless i have a grid...it just seemed like making educated guesses. which is definitely not efficient!

//sets size
size(320, 240);
smooth();

/*Draws head of creature */
stroke(0);
fill(240,0,0);
ellipseMode(CENTER);
ellipse(160,60,75,75);

/*Draws eyes of creature */
noStroke();
fill(0,255,15);
ellipseMode(CENTER);
ellipse(140,60,15,25);
ellipse(180,60,15,25);

/*Draws nose of creature */
noStroke();
fill(255);
ellipseMode(CENTER);
ellipse(160,70,15,15);

/*Draws mouth of creature */
stroke(0);
rectMode(CENTER);
rect(160,85,25,2);
println("you're done with the face");

/*Draws body of creature */
stroke(0);
fill(12,34,120);
rectMode(CENTER);
rect(160,133,28,70);

/*Draws line on top of head */
stroke(0);
line(125,23,193,23);

/*Draws right arm */
stroke(0);
line(174,120,200,160);

/*Draws left arm */
stroke(0);
line(146,120,117,160);

/*Draws left leg */
stroke(0);
line(146,169,136,220);

/*Draws right leg */
stroke(0);
line(174,169,185,220);
println("your done with creature");

44Comments

OOP + FP=Scala

To continue our discussion on their respective benefits here comes Scala. Which Twitter apparently is deploying.

http://en.wikipedia.org/wiki/Sca…

55Comments

C++ and Scheme

New to programming. From my research so far it seems like an imperative programming language like C++ is widely popular; however, there's a lot to be said for functional programming languages that are more "stable" such as Lisp or Scheme. I guess it is necessary to learn both styles. Or can one stick to functional programming and be relevant outside academic circles. For you pros out there fill me in.

2020Comments

Symbian OS Vs iPhone OS

Symbian is open source and runs on the Qt framework. iPhone OS is closed as in all things Apple, plus the Qt framework supports Lisp programming language. Thoughts?

66Comments

Steve Job's head

http://asktog.com/columns/082iPa…
interesting article on how steve jobs thinks from someone who worked with him.

2121Comments

User Interface of Xerox Star

&NR=1

This might be better than what we use today and it's from 1982!

1111Comments

Interaction Design V Interacitve

Any thoughts on the the future of design moving in a more interactive realm or more interaction design? I figure the latter is more lucrative and seems to be worthy of an investment to study.

99Comments

TypeKit

Anyone use TypeKit? if so does the developer/designer pay the subscription fee? or does the user?

11Comment

iPad predictions

So the iPad is coming to stores tomorrow. I wonder what the reception is going to be. I think it might surprise a few people...i believe that overall it's going to be a successful product because of its link to apps and especially the publishing world which can now create through social networking tools what I call the hyper-circulation of content...anyway, predictions anyone?

2424Comments

creative circle

they suck ass...i always get their stupid emails...yes i'm bitter!

1313Comments

design&technology parsons

anyone in the masters design and technology program at parsons in nyc? thinking of applying...what's it like? talked to someone at sva computer art program...it seemed pretty hardcore but it wasn't a focused program.

22Comments

Syrup

Anyone worked or interned at Syrup? What's it like? I am thinking of doing an internship there, possibly in interactive. I am a print guy trying to make the switch...so I figure why not intern at Syrup?

99Comments

Stockholm

Any one know of agencies in Stockholm that would be willing to offer an English speaker a creative opportunity? I like the design sensibility of Sweden. My website is below.

www.obinnaizeogu.com

11Comment

Working in Amsterdam

I would like to work in Amsterdam or Stockholm. I have a background in print, but I am trying to work at a place where I can transition into interactive and motion graphics without having those skills set yet (if it sounds awkward, I know). Currently, I don't have an exhaustive list of agencies in Amsterdam or Stockholm that are willing to hire an English speaker with a background in print. Any suggestions will be appreciated. My website:

www.obinnaizeogu.com

22Comments

Skip to main content