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 › boolean color sampling
Page Index Toggle Pages: 1
boolean color sampling (Read 445 times)
boolean color sampling
Apr 13th, 2007, 8:02pm
 
Hello. I'm trying to make a part of my program gather information about the color of certain pixels, and then run an if-then statement to build from that pixel if it matches the background color. My current code is this:

 color probe0 = get(ax, ay);
 if (probe0 = (bg)) {

and Processing tells me "Semantic Error: The type of this expression, "float", is not "boolean"."

I'm very new to Processing and coding in general. Any advice would be most appreciated.
Re: boolean color sampling
Reply #1 - Apr 13th, 2007, 9:03pm
 
You need two "="s. "=" means "set to", "==" means "compare to"

So in a test you need to do "if(thing1 == thing2" not "if(thing1 = thing2)"
Re: boolean color sampling
Reply #2 - Apr 13th, 2007, 9:05pm
 
=
is to assign a value ("set")
==
is to compare values ("equals")

should be:

if (probe0 == bg) { ...

F

( ha, john was faster ... )
Page Index Toggle Pages: 1