tags:

views:

32

answers:

1

I am new to iPhone application development and currently working on a simple paint application for iPhone. I use GLPaint source code to start with. I tried to change the brush size using the following ways.

I created a UIViewController class and linked it to GLPaint.PaintingView and added different buttons to indicate different brush size.

  1. Tried to dynamically pass images with different images. But initWithCoder was called only when the paint view loads and so the brush image @"Particle.png" is not getting changed

  2. Tried extracting the logic in initWithCoder to another method that takes in brush string as parameter. So that I could call the extracted method while selecting a brush button. Since the brush buttons are in another View/Viewcontroller, the change in image is not applied.

Is there any method to change the brush size just like "(void)setBrushColorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue" that changes color?

Any help will be very much useful. Thank you.

A: 

Did you try changing kBrushSize - which is used in call to glPointSize() in -initWithCoder: ?

westsider
I changed the value of kBrushSize before compiling the code and it works as expected. Is it possible to change it dynamically?
blacky
Thank you for pointing it out. I changed the value of kBrushSize before compiling the code and it works as expected. Is it possible to change it dynamically? I think I will have to define a global variable that should be able to change dynamically before initWithCoder: is called. Please correct me and give some pointers for doing so. Thanks.
blacky
In the GLPaint example, glPointSize() is called in -initWithCoder: because the point size will never change. If you wanted to change point size at runtime, you could call glPointSize() within -renderLineFromPoint:toPoint: *before* call to glDrawArrays(). At least, I think that that should work.
westsider
Hey westsider! thanks a lot for your help.. it worked like a charm!
blacky