@@ -40,7 +40,7 @@ + (NSImage*)imageWithGlyphName:(NSString*)glyphName
40
40
41
41
+ (void )checkmarkOnPath : (NSBezierPath *)path
42
42
x : (CGFloat )x {
43
- [path setLineWidth: 7 ] ;
43
+ [path setLineWidth: 8 ] ;
44
44
[path moveToPoint: NSMakePoint (x,42 )] ;
45
45
[path lineToPoint: NSMakePoint (x+17 ,21 )] ;
46
46
[path curveToPoint: NSMakePoint (x+49 , 79 )
@@ -354,68 +354,25 @@ + (void)drawStyle:(SSYVectorImageStyle)style
354
354
355
355
break ;
356
356
case SSYVectorImageStyleTag:;
357
- #define LINE_WIDTH 3.0
358
- #define LEFT_MARGIN 9
359
- #define TAG_WIDTH 67
360
- #define TAG_HEIGHT 42
361
- #define HOLE_FOR_STRING_RADIUS 6
362
- #define HOLE_OFFSET 5
363
- #define STRING_INSET 2
364
- #define TAG_ROTATION 30
357
+ #define LINE_WIDTH 7.0
358
+ #define TAG_HEIGHT 54
359
+ #define TAG_INSET 22
360
+ #define TAG_HOLE_RADIUS 4
365
361
CGFloat bottomMargin = (100.0 -TAG_HEIGHT)/2 ;
366
- NSRect tagRect = NSMakeRect (LEFT_MARGIN, bottomMargin, TAG_WIDTH, TAG_HEIGHT) ;
367
-
368
- path = [NSBezierPath bezierPathWithRect: tagRect] ;
369
-
370
- [path setLineWidth: LINE_WIDTH] ;
371
-
372
- /* Punch a round hole near the left side of the tag body
373
- This is done by with a separate bezier path which we first
374
- *reverse* and then *append* to the bookmark bezier path. */
375
- NSBezierPath * stringHolePath = [NSBezierPath bezierPath ] ;
376
- NSRect stringHoleRect = NSMakeRect (
377
- (LEFT_MARGIN + HOLE_OFFSET),
378
- (50.0 - HOLE_FOR_STRING_RADIUS),
379
- 2 *HOLE_FOR_STRING_RADIUS,
380
- 2 *HOLE_FOR_STRING_RADIUS
381
- ) ;
382
- [stringHolePath appendBezierPathWithOvalInRect: stringHoleRect] ;
383
- stringHolePath = [stringHolePath bezierPathByReversingPath ] ;
384
- [path appendBezierPath: stringHolePath] ;
385
-
386
- NSBezierPath * stringPath = [NSBezierPath bezierPath ] ;
387
- NSPoint stringStart = NSMakePoint (LEFT_MARGIN + HOLE_OFFSET + STRING_INSET, (50.0 )) ;
388
- [stringPath moveToPoint: stringStart] ;
389
- [stringPath relativeCurveToPoint: NSMakePoint (-30 , -30 )
390
- controlPoint1: NSMakePoint (-15 , 5 )
391
- controlPoint2: NSMakePoint (-25 ,-15 )] ;
392
- [stringPath setLineWidth: LINE_WIDTH] ;
393
- [stringPath setLineCapStyle: NSRoundLineCapStyle ] ;
394
-
395
- // Now move the origin to the center of the eye and rotate it
396
- NSAffineTransform * centerRotateTransform = [NSAffineTransform transform ] ;
397
- [centerRotateTransform translateXBy: (50.0 )
398
- yBy: (50.0 )];
399
- [centerRotateTransform rotateByDegrees: TAG_ROTATION];
400
- [centerRotateTransform translateXBy: -(50.0 )
401
- yBy: -(50.0 )];
402
- [centerRotateTransform translateXBy: 7
403
- yBy: 0 ];
404
- [centerRotateTransform concat ];
405
-
406
- [[NSColor whiteColor ] set ] ;
407
- [path fill ] ;
408
-
362
+ [path setLineWidth: 4.0 ] ;
363
+ [path moveToPoint: NSMakePoint (0 , 50 )] ;
364
+ [path lineToPoint: NSMakePoint (TAG_INSET, bottomMargin)] ;
365
+ [path lineToPoint: NSMakePoint (100 , bottomMargin)] ;
366
+ [path lineToPoint: NSMakePoint (100 , 100 - bottomMargin)] ;
367
+ [path lineToPoint: NSMakePoint (TAG_INSET, 100 - bottomMargin)] ;
368
+ [path closePath ] ;
369
+ [path appendBezierPathWithArcWithCenter: NSMakePoint (TAG_INSET, 50 )
370
+ radius: TAG_HOLE_RADIUS
371
+ startAngle: 0.0
372
+ endAngle: 360.0 ] ;
409
373
[[NSColor blackColor ] set ] ;
410
374
[path stroke ] ;
411
375
412
- [[NSColor blackColor ] set ] ;
413
- [stringPath stroke ] ;
414
-
415
- // Clean up the coordinate system - although not technically necessary because we're all done
416
- [centerRotateTransform invert ] ;
417
- [centerRotateTransform concat ] ;
418
-
419
376
break ;
420
377
case SSYVectorImageStyleCheck1:;
421
378
[self checkmarkOnPath: path
@@ -562,9 +519,80 @@ + (NSImage*)imageStyle:(SSYVectorImageStyle)style
562
519
[image release ] ;
563
520
}
564
521
522
+ [rotatedImage setTemplate: YES ] ;
523
+
565
524
return rotatedImage ;
566
525
}
567
526
568
527
569
528
@end
570
529
530
+ #if 0
531
+ /* The following code, which shows how to draw a fancy tag that is filled except
532
+ for an unfilled hole, and rotated 30 degrees, is no longer used, but I'm
533
+ keeping it as sample code in case the fashion designers at Apple someday
534
+ decide that flat is out and fancy is in.
535
+ */
536
+ #define LINE_WIDTH 3.0
537
+ #define LEFT_MARGIN 9
538
+ #define TAG_WIDTH 67
539
+ #define TAG_HEIGHT 42
540
+ #define HOLE_FOR_STRING_RADIUS 6
541
+ #define HOLE_OFFSET 5
542
+ #define STRING_INSET 2
543
+ #define TAG_ROTATION 30
544
+ CGFloat bottomMargin = (100.0-TAG_HEIGHT)/2 ;
545
+ NSRect tagRect = NSMakeRect(LEFT_MARGIN, bottomMargin, TAG_WIDTH, TAG_HEIGHT) ;
546
+
547
+ path = [NSBezierPath bezierPathWithRect:tagRect] ;
548
+
549
+ [path setLineWidth:LINE_WIDTH] ;
550
+
551
+ /* Punch a round hole near the left side of the tag body
552
+ This is done by with a separate bezier path which we first
553
+ *reverse* and then *append* to the bookmark bezier path. */
554
+ NSBezierPath* stringHolePath = [NSBezierPath bezierPath] ;
555
+ NSRect stringHoleRect = NSMakeRect(
556
+ (LEFT_MARGIN + HOLE_OFFSET),
557
+ (50.0 - HOLE_FOR_STRING_RADIUS),
558
+ 2*HOLE_FOR_STRING_RADIUS,
559
+ 2*HOLE_FOR_STRING_RADIUS
560
+ ) ;
561
+ [stringHolePath appendBezierPathWithOvalInRect:stringHoleRect] ;
562
+ stringHolePath = [stringHolePath bezierPathByReversingPath] ;
563
+ [path appendBezierPath:stringHolePath] ;
564
+
565
+ NSBezierPath* stringPath = [NSBezierPath bezierPath] ;
566
+ NSPoint stringStart = NSMakePoint(LEFT_MARGIN + HOLE_OFFSET + STRING_INSET, (50.0)) ;
567
+ [stringPath moveToPoint:stringStart] ;
568
+ [stringPath relativeCurveToPoint:NSMakePoint(-30, -30)
569
+ controlPoint1:NSMakePoint(-15, 5)
570
+ controlPoint2:NSMakePoint(-25,-15)] ;
571
+ [stringPath setLineWidth:LINE_WIDTH] ;
572
+ [stringPath setLineCapStyle:NSRoundLineCapStyle] ;
573
+
574
+ // Now move the origin to the center of the eye and rotate it
575
+ NSAffineTransform* centerRotateTransform = [NSAffineTransform transform] ;
576
+ [centerRotateTransform translateXBy:(50.0)
577
+ yBy:(50.0)];
578
+ [centerRotateTransform rotateByDegrees:TAG_ROTATION];
579
+ [centerRotateTransform translateXBy:-(50.0)
580
+ yBy:-(50.0)];
581
+ [centerRotateTransform translateXBy:7
582
+ yBy:0];
583
+ [centerRotateTransform concat];
584
+
585
+ [[NSColor whiteColor] set] ;
586
+ [path fill] ;
587
+
588
+ [[NSColor blackColor] set] ;
589
+ [path stroke] ;
590
+
591
+ [[NSColor blackColor] set] ;
592
+ [stringPath stroke] ;
593
+
594
+ // Clean up the coordinate system - although not technically necessary because we're all done
595
+ [centerRotateTransform invert] ;
596
+ [centerRotateTransform concat] ;
597
+
598
+ #endif
0 commit comments