Jan´s Technic Thread!

Jan Henrik

Member
Joined
Oct 16, 2013
Messages
492
Reaction score
811
Hi, im realy interrested in technic/electronics....
I don´t know if there are other people on the Forum interrested in technic, so this thread is for that people (no matter if there are some or not :D )

In this thread verybody can post things about elektronics/ideas/problems/ 3D printing :)
 

Jan Henrik

Member
Joined
Oct 16, 2013
Messages
492
Reaction score
811
Code:
PImage img;	   // The source image
int cellsize = 2; // Dimensions of each cell in the grid
int cols, rows;   // Number of columns and rows in our system
int a = 0;
 
int mode = 1;
void setup() {
  size(640, 360, P3D);
  img  = loadImage("test.jpg"); // Load the image
  cols = width/cellsize;			 // Calculate # of columns
  rows = height/cellsize;			// Calculate # of rows
 
}
 
void draw() {
  a++;
  a++;
  a++;
 
 
 
 
  println(a);
  background(0);
  loadPixels();
  // Begin loop for columns
  for ( int i = 0; i < cols;i++) {
	// Begin loop for rows
	for ( int j = 0; j < rows;j++) {
	  int x = i*cellsize + cellsize/2; // x position
	  int y = j*cellsize + cellsize/2; // y position
	  int loc = x + y*width;		   // Pixel array location
	  //color c = img.pixels[loc];	   // Grab the color
	  float r = red (img.pixels[loc]);
	  float g = green (img.pixels[loc]);
	  float b = blue (img.pixels[loc]);
	 
	  float c = ( r + g + b ) / 3;
	 
	  // Calculate a z position as a function of mouseX and pixel brightness
	  float z = (a/(float)width) * brightness(img.pixels[loc]) - 100.0;
	  // Translate to the location, set fill and stroke, and draw the rect
	  pushMatrix();
	  translate(x,y,z);
	  fill(c);
	  noStroke();
	  rectMode(CENTER);
	  rect(0,0,cellsize,cellsize);
	  popMatrix();
	  //x++;
	}

adv. coding \o/
 

Jan Henrik

Member
Joined
Oct 16, 2013
Messages
492
Reaction score
811
Top