FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Beyond Categories
(Moderator: REAS)
   first code
« Previous topic | Next topic »

Pages: 1 2 
   Author  Topic: first code  (Read 6136 times)
grumo

62931736293173 WWW
_Monocells
« Reply #15 on: Mar 18th, 2003, 7:24am »

this is my first shot with processing, a simple field of random cells.  
 
[applet+code] http://www.gramagrass.org/drafts/_monocells/
 
The cells behave randomly and moves away from the mouse pointer if your move it around. Clik+hold to attract the monocells to the pointer. It's a simple algorithm (with a lot of work for tweak and improvement, i guess). Any comments or suggestion will be appreciated.
 
high*
« Last Edit: Sep 24th, 2003, 7:10am by grumo »  
Dan

WWW
Re: first code
« Reply #16 on: Mar 18th, 2003, 2:32pm »

Not the absolute first thing (can't find it) but the second:
 
Code:
//===============================================================
//   Cellular Automata - Moore Neighbourhood
//   by Daniel Pupius (http://pupius.co.uk)
//
//   Created: 16 November 2002
//   Revised: Never
//
//   Rules: (based on number of neighbours)
//     0   Dies
//     1   No change
//     2   Born/Live
//     3   Born/Live
//     4   random live or die
//     5   Dies
//     6   Dies
//     7   Dies
//     8   Dies
//     9   Dies
//
//   Produces stable system
//
//   neighbours:  ###
//      #x#
//      ###
//===============================================================
 
int width = 300;
int height = 300;
int size = 2;
float randomChange = 0.0005;
 
cell[][] ca = new cell[width][height];
 
void setup() {
  size(width, height);
  colorMode(RGB, 100);
  background(50);
 
  for(int x=0;x<width/size;x++) {
    for(int y=0;y<height/size;y++) {
 ca[x][y] = new cell();
 if(random(1)<0.2) ca[x][y].state = 1.0;
    }
  }
}
 
void loop() {
  cell[][] tmp = ca;
 
  for(int x=0;x<width/size;x++) {
    for(int y=0;y<height/size;y++) {
 if(ca[x][y].state > 0.5) {
   rectMode(CORNER);
   fill(100);
   noStroke();
   rect(x*size, y*size, size, size);
 }
 
 int count = 0;
 
 if(x>0 && y<(height/size)-1 &&       tmp[x-1][y+1].state  > 0.5) count++;
 if(y<(height/size)-1 &&    tmp[x][y+1].state    > 0.5) count++;
 if(x<(width/size)-1 && y<(height/size)-1 &&    tmp[x+1][y+1].state  > 0.5) count++;
 
 if(x>0 &&        tmp[x-1][y].state    > 0.5) count++;
 if(x<(width/size)-1 &&     tmp[x+1][y].state    > 0.5) count++;
 
 if(x>0 && y>0 &&      tmp[x-1][y-1].state  > 0.5) count++;
 if(y>0 &&        tmp[x][y-1].state    > 0.5) count++;
 if(x<(width/size)-1 && y>0 &&   tmp[x+1][y-1].state  > 0.5) count++;
 
 if(count == 2 || count == 3) ca[x][y].state = 1;
 
 else if(count==4) ca[x][y].state = random(1);
 else if(count>=6) ca[x][y].state = 0;
    }
  }
}
 
class cell {
  float state;
  cell() {
    state = 0.0;
  }
}
 
Ale_k

WWW
Re: first code
« Reply #17 on: Jul 25th, 2003, 9:23pm »

Hi,
this is my first P5 code,
http://www.ghostagency.net/processing/arbor_1/
it's a simple recursive exercise just to practise with a new language, I used a sample (the rotation sistem) of the Cube_rgb example.
Bye
 
twitch

alteridentity WWW
Re: first code
« Reply #18 on: Aug 22nd, 2003, 7:15am »

This code is tediously primitive; it won't even run as an applet due to the image retrieval operations employed. But I really wanted to do the simplest of things, so think of it has a kind of reverse hello-world.
 
Works great - needs a fairly large screen and a broadband connection.
 
// weather leech
// snags us weather images from unisys and displays them in a desktop mosaic
// by James G. Stallings II aka Twitch
// 2003.08.16 (my 10 yr wedding aniversary!)
 
// the first go at this actually worked although my layout sucks. Amazing because other things in other languages
// that seemed so simple as this have only worked after days of mucking around. Time for a bit of experimentation  
// with the layout.
 
BImage wxImg0, wxImg1, wxImg2, wxImg3, wxImg4, wxImg5;
 
void setup() {
  size(1280,1024);
  background(0);
  wxImg0 = loadImage("http://weather.unisys.com/satellite/sat_vis_us.gif");
  wxImg1 = loadImage("http://weather.unisys.com/satellite/sat_ir_us.gif");
  wxImg2 = loadImage("http://weather.unisys.com/satellite/sat_ir_enh_us.gif");
  wxImg3 = loadImage("http://weather.unisys.com/satellite/sat_wv_us.gif");
  wxImg4 = loadImage("http://weather.unisys.com/surface/sfc_map.gif");
  wxImg5 = loadImage("http://weather.unisys.com/radar/rad_us.gif");
}
 
void loop() {
  image(wxImg0, 5, 7, 320, 256);
  image(wxImg1, 5, 266, 320, 256);
  image(wxImg2, 5, 525, 320,256);
  image(wxImg3, 5, 784, 320, 256);
  image(wxImg4, 333, 7, 620, 45;
  image(wxImg5, 333, 468, 620, 45;
}
 
« Last Edit: Aug 22nd, 2003, 7:16am by twitch »  

http://mw.merseine.nu/~twitch/newmw/
slight


Re: first code
« Reply #19 on: Sep 8th, 2003, 8:51pm »

Hi, this is my first post, with a link to my first (and 2nd) p5 code. I started with the idea of a displacement map / voxel engine sort of thing, and by not knowing exactly what I was doing, stumbled across an output that is simple to make but has a nice aesthetic.  
 
http://www.evilbastard.org/slight/p5/
 
Andy M.

WWW
Re: first code.
« Reply #20 on: Sep 13th, 2003, 8:06am »

My first project and description: http://happiland.2y.net/~andy/archives/000050.php
 
It was inspired by a much more sophisticated Truchet tiler created by another user, JohnByrne.
 
Mythmon


Re: first code
« Reply #21 on: Feb 16th, 2004, 2:36am »

my first (and only) sketch.
basically, it starts with 1 "pixel" thats 512 pixels wide/tall. then everytime you press a button on your keyboard it halves the hieght/width there by quatrupaling the resolution and redraws it, when you click the square size gets set back to 512
 
Code:

int resolution = 512;
 
void setup() {  
  size(512,512);
  drawer (resolution);
}
 
void keyPressed()
{
  if (resolution>=2)
  {
    resolution/=2;
  }
  drawer (resolution);
}
 
void mousePressed()
{
    resolution = 512;
    drawer(resolution);
}
 
void drawer (int rez)
{
  int shade;
  for (int i = 1; i <= 512; i+=rez)
  {
    for (int j = 1; j <= 512; j+=rez)
    {
 //shade=int(random(0xFFFFFF));
 shade=int(random(255));
 shade=(shade<<16)+(shade<<8)+shade;
 for (int k = 0; k<(rez); k++)
 {
   for (int l = 0; l<(rez); l++)
   {
     set(i+k,j+l,shade);
   }  
 }
    }
  }
}  
void loop() {}
 
eicasm


Re: first code
« Reply #22 on: Apr 4th, 2004, 8:48am »

horribly coded but here it is:
 
 
 
 
 
 
//
 
void setup() {
  size(600,400);
  background(255);
  noStroke();
  ellipseMode(CENTER_DIAMETER);
}
 
 
 
void loop() {
 float cr = random(255);
 float cg = random(255);
 float cb = random(255);
 float a = random(30);
 color c = color(cr, cg, cb, a);
 fill(c);
 
 float r = random(120);
 float x = random(600);
 float y = random(400);
 ellipse(x, y, r, r);
 
    //  delay(int(r*2));
}  
 
void mousePressed(){  
    fill(255);
    rect(0,0,600,400);
}  
 
Pages: 1 2 

« Previous topic | Next topic »