Line Width Not doing anything


#1

Doing the challenge and it’s 'challenging’
No response to setLineWidth no matter what I set, it gives me just one pixel.

here is a code fragment. from drawRect:

[bezpath setLineWidth:[Oval mythickness]];
[[Oval mycolor] set];
NSRect TmpRec = [Oval myrect];
bezierPathWithOvalInRect:TmpRec];
bezpath = [NSBezierPath bezierPathWithOvalInRect:TmpRec];
[bezpath stroke];

and I see the width is actually set to 3 or 6 depending on Random()

thanks.
Ian

ps. works with a scribble path… tho … wha???


#2

[quote=“IanDMah”]Doing the challenge and it’s 'challenging’
No response to setLineWidth no matter what I set, it gives me just one pixel.

here is a code fragment. from drawRect:

[bezpath setLineWidth:[Oval mythickness]];
[[Oval mycolor] set];
NSRect TmpRec = [Oval myrect];
bezierPathWithOvalInRect:TmpRec];
bezpath = [NSBezierPath bezierPathWithOvalInRect:TmpRec];
[bezpath stroke];

and I see the width is actually set to 3 or 6 depending on Random()

thanks.
Ian

ps. works with a scribble path… tho … wha???[/quote]

Yeah that challenge is a tough one, honestly I stopped after I was able to draw multiple ovals… :frowning:

But let’s get back to your problem, your code looks a little bit strange though

bezierPathWithOvalInRect:TmpRec]; // ?!

Anway, according to the Xcode documentation, bezierPathWithOvalInRect -> “Creates and returns a new NSBezierPath object initialized with an oval path inscribed in the specified rectangle.” So I guess your old bezpath and thus your lineWidth is overwritten, so try calling bezierPathWithOvalInRect first

PS: I don’t like this drawing stuff… I have a feeling we’re drawing the background and all the ovals each and every time (even if I just move the mouse a bit while holding LMB), this is so… unnecessary and wasteful IMHO and I really hope there’s a better way to do this


#3

Yeah Drawing stuff is a pain !!! Smashed my head against the table for two weeks!!!

Thanks for the help worked like a charm.
Ian