Processing bug?

You could also just change the code in the OP to -

PGraphics v;

void setup() {
  size(300, 300, P2D);
  v = createGraphics(260, 200, JAVA2D);
  updateBuffer();
}

void draw() {
  background(200, 200, 255);
  image(v, 20, 20);
}

void updateBuffer() {
  v.beginDraw();
  v.background(255);
  colorMode(HSB, 360, 100, 100);
  int c = color(300, 100, 100); //NO  'unexpected token:.' runtime error?
  colorMode(RGB, 255, 255, 255);
  v.fill(c);
  v.noStroke();
  v.ellipse(130, 100, 130, 100);
  v.endDraw();
}

I’m not saying it’s ideal, but it’s not a requirement to be able to use color with an offscreen graphics (unless you’re getting into threading)

@neilcsmith you have taken my words out of context so giving them a different meaning and then contradict them. Wow

I said the pre-processor hid the OO syntax for newbies, I call that simplification! The decision to use color as an alias for int was again aimed at early sketchers / graphic designers, personally I think it was a huge error of judgement. Fancy having a data type with the same name as a method, its just wrong.

Whatever the rights and wrongs of the pre-processor the problem is, it takes valid Processing code (according to API) and converting it to invalid Java code, and I would like it fixed.

1 Like

It is a requirement that an instance of PGraphics can call the method color it is in the documented API and in the source code. It is just the pre-processor makes a mess of it.

I was already aware of the code fix you posted and I agree it will do the job but is ineligant and shouldn’t be necessary. I HATE writing code like that.

1 Like

Sorry! But then you took mine out of context too then! :wink: But that comes to some ambiguity as to what syntax and structure are in programming languages. Hiding the OOP stuff isn’t what I was criticising in the first place.

Up to you! It’s not much different to any other “global” mathematical function in Processing in my mind - it’s not a property of the underlying PGraphics.

I just noticed something, in the preferences.txt you can change:

preproc.color_datatype=true

to

preproc.color_datatype=false

It will brake all examples using color as a datatype, but for me that is worth it.

5 Likes

Nice one, shame its not false by default.

1 Like