FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Discussion
   General Processing Discussion
(Moderators: fry, REAS)
   composite or reference datatypes? / color datatype
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: composite or reference datatypes? / color datatype  (Read 1016 times)
lunetta

7200475272004752 WWW Email
composite or reference datatypes? / color datatype
« on: Mar 15th, 2005, 7:00pm »

*BEWARE* Boring questions ahead
 
Processing documentation uses the term composite datatype;
Java documentation uses the term reference datatype;
Can I use both as synonyms?
 
Why color is considered a primitive datatype in Processing?
 
 
Thanks for any idea... I'm writing about those...
« Last Edit: Mar 15th, 2005, 7:01pm by lunetta »  
fry


WWW
Re: composite or reference datatypes? / color data
« Reply #1 on: Mar 15th, 2005, 7:35pm »

composite datatype? reference datatype? hm, in what context? or do you have a link?
 
color is simply a synonym for int in processing. it's used to refer to the packed int method of storing colors in ARGB format (see info elsewhere on the board). the idea is that it's a little weird to say:
int black = #000000;
where this might make a little more sense:
color black = #000000;
 
in future versions of processing (2.0), we'd like to actually make it less of a synonym, and give it more of its own abilities. that way fill(color c) would be different than fill(int gray), and not cause the current confusion that exists in very rare cases. (fret not, it would work mostly the same, it would upgrade to int the same way a byte or short will auto-convert to an int).
 
the idea would be that it being its own type would mean that smarter math could be introduced too, where:
color c = #f08080;
c *= 0.5;
would actually make the color darker, or affect its alpha, or whatever.
 
Ricard


Re: composite or reference datatypes? / color data
« Reply #2 on: Mar 15th, 2005, 11:22pm »

Would it be interesting to have the colorspace as part of the color datatype.  I think it would make more sense.
 
ricard
 
Ricard


Re: composite or reference datatypes? / color data
« Reply #3 on: Mar 15th, 2005, 11:24pm »

Just thought of why it wouldn't be interesting.  Anything bigger than a 32bit int is not good, right?.
 
sorry for that
ricard
 
fry


WWW
Re: composite or reference datatypes? / color data
« Reply #4 on: Mar 16th, 2005, 3:32am »

the reason it's just an ARGB int is because that's what everything in processing (and java for the most part) use for pixel data. so the idea is to be able to just set pixels[i] = xxx; and have that be identical to the color datatype.
 
color space would be another thing since it would require conversion. that would probably rather be done with a full class, or a different sort of concept. java can do higher than 32 bit ints, a 64 bit long is the thing. but you'd waste a lot of time converting a long down to a pixel value.
 
lunetta

7200475272004752 WWW Email
Re: composite or reference datatypes? / color data
« Reply #5 on: Mar 16th, 2005, 5:33pm »

hi Fry
 
Just got your response, thanks.
 
So, I got the term "composite data" describing object, array and string in the processing reference; and the term "reference" describing the same in the java nuts and bolts - http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html
 
I was wondering if there's any conceptual difference from both...
 
and I understood the color thing.. I though that the color was an object with A R G B properties, my confusion.
 
thanks again...
« Last Edit: Mar 16th, 2005, 5:35pm by lunetta »  
fry


WWW
Re: composite or reference datatypes? / color data
« Reply #6 on: Mar 16th, 2005, 8:33pm »

ah, ok.. so i don't know if i've ever actually heard of the term "composite" datatype. but now i've looked it up (and feel like a real computer scientist). basically it refers to anything where a series of smaller types make up a larger whole. so an array of ints is a composite datatype (composited of a bunch of ints) or a class is a composite type (composited of maybe a few ints, a string, etc).
 
a reference data type is slightly different than a composite one, or rather, the terms are used to mean different things, however in java i think they're going to refer to the same things (classes, arrays, etc).
 
a reference type is anything that is "passed by reference", meaning that you're sending around a pointer to the actual data, and the receiving function can manipulate the data directly. so for instance:
 
void poo(float x) {  
  // if i mess with x here, it won't affect the  
  // variable that was passed in elsewhere in the program
  // 'float' is a primitive datatype, which is not
  // passed by reference.
}
 
void poo(FancyObject fob) {
  // if i mess with 'fob', it will be messed with
  // everywhere else in the program, because 'fob'
  // has been passed "by reference" (it's a reference
  // data type like any other class)
}
 
void poo(int time[]) {
  // int[] is a composite type, but arrays are also  
  // passed by reference, meaning that if i mess with
  // the elements inside time[] they'll change  
  // elsewhere in the program too
}
 
lunetta

7200475272004752 WWW Email
Re: composite or reference datatypes? / color data
« Reply #7 on: Mar 16th, 2005, 10:33pm »

great, thanks for the response - and sorry for the useless topic...
 
Pages: 1 

« Previous topic | Next topic »