Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
jj.cabreralopez
jj.cabreralopez's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Having issues with the key function
[3 Replies]
10-Mar-2013 11:23 PM
Forum:
Programming Questions
I started working on a project. It was inspired by someone else's work. I used part of the code and planned on integrating more to it and change it around. The code so far looks like this:
//
http://www.openprocessing.org/sketch/60094
PImage image;
//////////////////////////
void setup ()
{
size (900, 650);
smooth();
image = loadImage("view.png");
noStroke();
}
//////////////////////////
void draw () {
background(image);
noCursor();
noStroke();
background(0, 0, 0);
for ( int x =0; x <= width; x+=9) {
for (int y=0; y <= height; y+=9) {
float diameter = 130-dist(mouseX, mouseY, x, y);
if (diameter > 0) {
fill(image.pixels[(x + image.width*y)]);
ellipse(x, y, diameter/7, diameter/7);
}
}
}
}
//////////////////////////
void keyPressed () {
if (key == UP){
}
if (key == DOWN){
}
You get an image with a floating circle that you can move around with your mouse. When you hover around
can see an image behind it. I want to change the size and shape of the circle by manipulating certain
values using the arrow keys. Here's an example:
for ( int x =0; x <= width; x+=9) {
for (int y=0; y <= height; y+=9)
if I change the 9 value to a 3 or to 6, the circle becomes more or less pixelated. Is there a
way that I can use the arrow keys to change that?
This is what I tried.
int aa = 3;
for ( int x =0; x <= width; x+=aa) {
for (int y=0; y <= height; y+=aa)
if (key == UP){
aa++;}
else {
aa = aa;
}
hoping this all makes sense...or that It is possible for me to be able to make the idea work.
«Prev
Next »
Moderate user : jj.cabreralopez
Forum