/** * ParticleString * * Pixels in an image are represented as particles with the traer.physics system. * When you click the image the particles are attracted to form a shape made by a string * written in the screen. * * Author: Jorge Cardoso * http://jorgecardoso.org * * 2 July 2005 */ import traer.physics.*; int imgWidth = 108; int imgHeight = 50; int particleWidth = 108; int particleHeight = 50; ParticleSystem physics; Particle particle[][]; Particle fixed[][]; Particle letter[][]; int letterX[]; int letterY[]; PFont fonte; PGraphics3 pg; int count = 0; float widthParticleRatio; float heightParticleRatio; float widthScreenRatio; float heightScreenRatio; PImage img; void setup() { size(108*4, 50*4); widthScreenRatio = width/imgWidth; heightScreenRatio = height/imgHeight; widthParticleRatio = imgWidth/particleWidth; heightParticleRatio = imgHeight/particleHeight; println("widthScreenRatio: " + widthScreenRatio); println("heightScreenRatio: " + heightScreenRatio); println("widthParticleRatio: " + widthParticleRatio); println("heightParticleRatio: " + heightParticleRatio); fonte = loadFont("ArialMT-16.vlw"); pg = new PGraphics3(particleWidth, particleHeight); img = loadImage("olhos.png"); physics = new ParticleSystem(0, 0.1 ); particle = new Particle[particleHeight][particleWidth]; fixed = new Particle[particleHeight][particleWidth]; letterX = new int[particleHeight*particleWidth]; letterY = new int[particleHeight*particleWidth]; for(int i=0; i 1) { letterX[index] = j; letterY[index] = i; index++; } } } int ran; int ratio = particleWidth*particleHeight/index; int c = 0; for(int i=0; i