[Drawkit] Styling line end caps

Brad Larson larson at sonoplot.com
Mon Jun 23 20:13:32 PDT 2008


Good point.  I guess it was the callthrough on the convenience  
constructor to DKStroke that confused me in the first place, and I  
thought that others might be saved that confusion by abstracting away  
the whole thing.  I probably am overestimating the importance of those  
properties.

On Jun 23, 2008, at 7:57 PM, Graham Cox wrote:

> Hi Brad,
>
> I guess you could have a convenience constructor for almost  
> everything. The problem is where do you draw the line? I tend to  
> provide convenience constructors for the most obvious usage of an  
> object, (usually intended to get you started, or to accomplish a  
> common chore) but not for every single feature. In this case *my*  
> view is that caps and join styles are a relatively minor property,  
> or perhaps one that comes into play only once you've scratched the  
> surface and want to go a bit deeper. YMMV!
>
> You can of course very easily add these types of convenience  
> constructors using a category.
>
> cheers, Graham
>
>
> On 24 Jun 2008, at 8:03 am, Brad Larson wrote:
>
>> While this works just fine, there are convenience constructors for  
>> creating a DKStyle with a certain fill and line width.  Maybe  
>> adding cap and join properties onto another DKStyle convenience  
>> constructor might make the process more intuitive.  Something like
>>
>> + (DKStyle*)		styleWithFillColour:(NSColor*) fc strokeColour: 
>> (NSColor*) sc strokeWidth:(float) sw strokeCapStyle: 
>> (NSLineCapStyle) cs strokeJoinStyle:(NSLineJoinStyle) js
>> {
>> 	if( fc == nil && sc == nil )
>> 		[NSException raise:NSInvalidArgumentException format:@"bad  
>> argument to [DKStyle styleWithFillColour:strokeColour:] - both  
>> colours are nil"];
>> 	
>> 	DKStyle* style = [[DKStyle alloc] init];
>> 	
>> 	if ( fc )
>> 	{
>> 		DKFill* fill = [DKFill fillWithColour:fc];
>> 		[style addRenderer:fill];
>> 	}
>> 	
>> 	if ( sc )
>> 	{
>> 		DKStroke* stroke = [DKStroke strokeWithWidth:sw colour:sc];
>> 		[stroke setLineCapStyle:cs];
>> 		[stroke setLineJoinStyle:js];
>> 		[style addRenderer:stroke];
>> 	}
>> 	
>> 	return [style autorelease];
>> }
>>
>> might do the trick.  Anyway, just a suggestion.
>
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net

______________________
Brad Larson
SonoPlot, Inc.
3030 Laura Lane, Suite 120
Middleton, WI 53562





More information about the Drawkit mailing list