We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › point(i,j) doesn't work
Page Index Toggle Pages: 1
point(i,j) doesn't work (Read 520 times)
point(i,j) doesn't work
Jan 29th, 2006, 8:19am
 
I'm just learning Processing and trying to make a color picker that changes between H,S,B modes.

I have two examples here, the first uses point(i,j) and works. In the second example point(i,j) doesn't work... but... line(i,j,127,127) works...

Could someone please help me?

NOTE: the second example uses the MyGUI class.

/*works*/
void setup(){
 size(128,128);
 noStroke();
 colorMode(HSB, 255,255,255);
}

void draw(){
}

void mousePressed(){
 for(int i=0; i<128; i++) {
   for(int j=0; j<128; j++) {
     stroke(mouseX*2, i*2, j*2);
     point(i, j);
   }
 }
}

/* end works */

/*doesn't work*/

import mkv.MyGUI.*;

MyGUI gui;
MyGUICheckBox chkH;
MyGUICheckBox chkS;
MyGUICheckBox chkB;
char hsbVAR;

void setup(){
 size(151,128);
 framerate(24);
 background(133);
 smooth();    
 noStroke();
 gui = new MyGUI(this);
 chkH = new MyGUICheckBox(this,140,height/2-20,10,10);
 chkS = new MyGUICheckBox(this,140,height/2,10,10);
 chkB = new MyGUICheckBox(this,140,height/2+20,10,10);
 gui.add(chkH);
 gui.add(chkS);
 gui.add(chkB);
 colorMode(HSB,255,255,255);  
}

void draw(){
}

void actionPerformed(ActionEvent e){
 checkHSB(e);
}

void checkHSB(ActionEvent e){
 if(e.getSource() == chkH){
   chkS.checked(false);
   chkB.checked(false);
   hsbVAR = 'H';
 }
 else if(e.getSource() == chkS){
   chkH.checked(false);
   chkB.checked(false);
   hsbVAR = 'S';
 }
 else if(e.getSource() == chkB){
   chkH.checked(false);
   chkS.checked(false);
   hsbVAR = 'B';
 }
 drawColor(hsbVAR);
}

//----------------------

void drawColor(char e){
 switch(e){
   case 'H':
     for(int i=0; i<128; i++) {
       for(int j=0; j<128; j++) {
         stroke(255,i*2,j*2);
         point(i,j);
         //line(i,j,i,j);
         //line(i,j,127,127);
       }
     }
   break;
   case 'S':
     for(int i=0; i<128; i++) {
       for(int j=0; j<128; j++) {
         stroke(i*2,255,j*2);
         point(i,j);
         //line(i,j,i,j);
         //line(i,j,127,127);
       }
     }
   break;
   case 'B':
     for(int i=0; i<128; i++) {
       for(int j=0; j<128; j++) {
         stroke(i*2,j*2,255);
         point(i,j);
         //line(i,j,i,j);
         //line(i,j,127,127);
       }
     }
   break;
 }
}

/* end doesn't work */
Re: point(i,j) doesn't work
Reply #1 - Apr 2nd, 2006, 12:47am
 
I tested the second example, and yes - like you said, point fails to draw anything to the scene, where as line succeeds. Very odd.

I'm not sure how point works, not enough to help you out, but I might suggest that you could access the individual pixels directly instead of using point.

e.g. using set(x, y, color);

---testing---
Yes, that works ten times better/faster.

e.g.:
Code:

import mkv.MyGUI.*;

MyGUI gui;
MyGUICheckBox chkH;
MyGUICheckBox chkS;
MyGUICheckBox chkB;
char hsbVAR;

void setup(){
size(151,128);
framerate(24);
background(133);
smooth();
noStroke();
gui = new MyGUI(this);
chkH = new MyGUICheckBox(this,140,height/2-20,10,10);
chkS = new MyGUICheckBox(this,140,height/2,10,10);
chkB = new MyGUICheckBox(this,140,height/2+20,10,10);
gui.add(chkH);
gui.add(chkS);
gui.add(chkB);
colorMode(HSB,255,255,255);
}

void draw(){
}

void actionPerformed(ActionEvent e){
checkHSB(e);
}

void checkHSB(ActionEvent e){
if(e.getSource() == chkH){
chkS.checked(false);
chkB.checked(false);
hsbVAR = 'H';
}
else if(e.getSource() == chkS){
chkH.checked(false);
chkB.checked(false);
hsbVAR = 'S';
}
else if(e.getSource() == chkB){
chkH.checked(false);
chkS.checked(false);
hsbVAR = 'B';
}
drawColor(hsbVAR);
}

//----------------------

void drawColor(char e){
switch(e){
case 'H':
for(int i=0; i<128; i++) {
for(int j=0; j<128; j++) {
set(i,j, color(255,i*2,j*2));
}
}
break;
case 'S':
for(int i=0; i<128; i++) {
for(int j=0; j<128; j++) {
set(i,j, color(i*2,255,j*2));
}
}
break;
case 'B':
for(int i=0; i<128; i++) {
for(int j=0; j<128; j++) {
set(i,j, color(i*2,j*2,255));
}
}
break;
}
}


(So maybe MyGUI -is- having an effect on point, but I don't know what.)

PS: Interesting emulation of MyGUI radio buttons (as yet unimplemented, http://mkv25.net/MyGUI/ )
Re: point(i,j) doesn't work
Reply #2 - Apr 2nd, 2006, 8:41pm
 
issues with point()
http://dev.processing.org/bugs/show_bug.cgi?id=121
http://dev.processing.org/bugs/show_bug.cgi?id=269
Page Index Toggle Pages: 1