using any processing classes in custom class

hi everybody,

i use a custom class, we will call it At first it worked. Then i added a color variable. And it doesn't work any more. The problem seems to be, that my doesn't know the type "color". So, how can i fix this? I don't know what i have to import or what to do.



  • edited September 2014

    Processing uses a pre-processor that gathers all ".pde" tabs and wraps them up as 1 class which extends PApplet.
    Also, it is responsible for converting some Processing's "syntax sugar" to proper Java!
    1 of them is primitive datatype color. Which is merely int w/ a more descriptive name! O:-)

    However, if we make ".java" tabs, Processing's pre-processor won't touch it!
    And we'll have to use "true & raw" Java syntax. And we'll have to convert any parts which aren't proper Java!

    Another alternative is simply leave your class in a ".pde" tab. But also declare it as public static.
    That'll act as any other top-class inside ".java" files, but still under Processing's pre-processor's oversight! *-:)

    For further information on the subject, take a look at this recent discussion below:

  • edited September 2014

    Unfortunately using coloras an alias for int was probably not the best thing for Processing to do because it forces the programmer to use a pde tab. Since you have reached the point of creating your own classes I suggest that in future you use int instead of color to store colour information.

  • thank you, GoToLoop, it worked! all of your solutions :-) and i made progress in understand processing. quark, you are right, color is not the most reasonable thing to use, ...but it's sooo damned simple and comfortable to use, and i am so damned lazy. I am ashamed and i promise to improve!

  • I guess color datatype was invented b/c Processing is a multi-language framework API.
    In "Java Mode", color is int. But for other modes it can be something else!
    Therefore, color keeps a descriptive color identity regardless the chosen mode!

Sign In or Register to comment.