advertisement

Article:
  Introduction to Cocoa Graphics, Part 2
Subject:   tool for fluted ends of fonts, serifs (?)
Date:   2001-11-21 12:29:22
From:   psheldon
Response to: first sample code and story

- (void)drawRect:(NSRect)rect {


//define things centrally and in stages to more easily experiment
/*
remark :
Below, I play with making the radius too short to join to the imaginary guide line. An extension line is drawn to the arc to the imaginary control line.
I wish I could figure the postscript context story, as Next Step probably did a postscript port into their interface and only too well understood that stuff to be able to explain it to us newbies.
Maybe a story about the drafting tools for hot metal type from some sad obsolete soul who can no longer use his once expensive equipment in the age of desktop publishing. The fellow I'm thinking of, his initials BB, geez I'd be scared to bring it up, but Donald Knuth might be completely inaccessible, especially at thanksgiving.
;-)
Maybe safer was someone familiar, not with hot metal, but rather with a font drawing program, friend woman artist.
I tried babbling to her. Out of the blue flew into my mind serifed fonts.
She wasn't hot to it and couldn't respond. I thought to pass the ball to the thread.
I have, however, since had a clear "vision" that this is correct, such a tool is used for the serif.
Zoom up a pdf file and look at a bunch of characters and find examples! Aw heck, consider the letter R with fluted feet, this tool could draw pieces of that.
The arguments of the method were (at first glance) otrociously named, but you can only cram so much into a short space and once you get the feeling of the tool, the words from and to make more sense and don't overload you with pronunciation, spelling or reading and "sort of get out of the way".
;-)
*/

//p1 is my "base left", p2 my "base right"

float x1=0;
float y1=100;

// float x2=80;
// float x2=100;
// float x2=120;
// float x2=150;
// float x2=180;
float x2=10000;
float y2=100;

float xcenter=40;
float ycenter=160;

//note compiler forgave me forgettingt decimal point for float
//float radius=20;// way down from 60 so won't hit, makes straight line then arc to imaginary line
//float radius=30;// progressing up and past 60
//float radius=40;
//float radius=50;
//float radius=55;
//float radius=60;
float radius=120;

//lone point distinguished by not having little rect around it, the end of a NSBezierpath to append to :
NSPoint p1 = NSMakePoint(x1, y1);

//Will make little rects around the end points of the imaginary line :
NSPoint p2 = NSMakePoint(x2, y2);
NSPoint center = NSMakePoint(xcenter, ycenter);
//NSMakeRect(x,y,w,h)
NSRect p2Rect = NSMakeRect(x2-1.0, y2-1.0, 2, 2);
NSRect centerRect = NSMakeRect(xcenter-1.0, ycenter-1.0, 2, 2);

//Objects that when stroked will draw the rects
NSBezierPath * p2Path;
NSBezierPath * centerPath;

//path to augment with arc and arc
NSBezierPath * wall;
NSBezierPath * barrier;
//I added
NSBezierPath * base;


//Want to isolate what does what and couldn't color strokes differently.
//These objects evidentally don't get the color.
[[NSColor blackColor] set];
p2Path = [NSBezierPath bezierPathWithRect:p2Rect];
[p2Path stroke];


centerPath = [NSBezierPath bezierPathWithOvalInRect:centerRect];
[centerPath stroke];


// Constructing the path
//rather constructing a path amongst featuring displaying paths with the method in question
wall = [NSBezierPath bezierPath];
//no path to append to since
//this moves pen with penup from last point of rect around center to start pt p1
[wall moveToPoint:p1];
//center is not center of circle and I go to p2(point on right and marked)
//seems to confirm tangent, but not tangent at point p2, goes beyond.
//how does method determine length of arc?
[wall appendBezierPathWithArcFromPoint:center toPoint:p2 radius:radius];
[wall stroke];


barrier = [NSBezierPath bezierPath];
[barrier moveToPoint:center];
[barrier lineToPoint:p2];
[barrier stroke];

//my additional line
base = [NSBezierPath bezierPath];
[base moveToPoint:p1];
[base lineToPoint:p2];
[base stroke];


}