Revision: 14638
http://sourceforge.net/p/skim-app/code/14638
Author: hofman
Date: 2024-11-04 20:37:23 +0000 (Mon, 04 Nov 2024)
Log Message:
-----------
Draw fallback icons using bezier paths instead of curves so they scale
asymetrically
Modified Paths:
--------------
trunk/SkimNotes/SKNPDFAnnotationNote.m
Modified: trunk/SkimNotes/SKNPDFAnnotationNote.m
===================================================================
--- trunk/SkimNotes/SKNPDFAnnotationNote.m 2024-11-04 15:45:27 UTC (rev
14637)
+++ trunk/SkimNotes/SKNPDFAnnotationNote.m 2024-11-04 20:37:23 UTC (rev
14638)
@@ -291,15 +291,21 @@
#if !defined(PDFKIT_PLATFORM_IOS) && (!defined(MAC_OS_X_VERSION_10_15) ||
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15)
+#define KAPPA 0.55228474983
+#define KAPPA2 0.26521648984
+
static inline void drawIconComment(CGContextRef context, NSRect bounds) {
bounds = NSInsetRect(bounds, 0.5, 0.5);
CGFloat x = NSMinX(bounds), y = NSMinY(bounds), w = NSWidth(bounds), h =
NSHeight(bounds);
- CGFloat r = 0.1 * fmin(w, h);
CGContextMoveToPoint(context, x + 0.3 * w, y + 0.3 * h - 0.5);
- CGContextAddArcToPoint(context, x, y + 0.3 * h - 0.5, x, y + h, r);
- CGContextAddArcToPoint(context, x, y + h, x + w, y + h, r);
- CGContextAddArcToPoint(context, x + w, y + h, x + w, y, r);
- CGContextAddArcToPoint(context, x + w, y + 0.3 * h - 0.5, x, y + 0.35 * h,
r);
+ CGContextAddLineToPoint(context, x + 0.1 * w, y + 0.3 * h - 0.5);
+ CGContextAddCurveToPoint(context, x + (0.1 - 0.1 * KAPPA) * w, y + 0.3 * h
- 0.5, x, y + (0.4 - 0.1 * KAPPA) * h - 0.5, x, y + 0.4 * h - 0.5);
+ CGContextAddLineToPoint(context, x, y + 0.9 * h);
+ CGContextAddCurveToPoint(context, x, y + (0.9 + 0.1 * KAPPA) * h, x + (0.1
- 0.1 * KAPPA) * w, y + h, x + 0.1 * w, y + h);
+ CGContextAddLineToPoint(context, x + 0.9 * w, y + h);
+ CGContextAddCurveToPoint(context, x + (0.9 + 0.1 * KAPPA) * w, y + h, x +
w, y + (0.9 + 0.1 * KAPPA) * h, x + w, y + 0.9 * h);
+ CGContextAddLineToPoint(context, x + w, y + 0.4 * h - 0.5);
+ CGContextAddCurveToPoint(context, x + w, y + (0.4 - 0.1 * KAPPA) * h -
0.5, x + (0.9 + 0.1 * KAPPA) * w, y + 0.3 * h - 0.5, x + 0.9 * w, y + 0.3 * h -
0.5);
CGContextAddLineToPoint(context, x + 0.5 * w, y + 0.3 * h - 0.5);
CGContextAddLineToPoint(context, x + 0.25 * w, y);
CGContextClosePath(context);
@@ -318,7 +324,6 @@
static inline void drawIconKey(CGContextRef context, NSRect bounds) {
bounds = NSInsetRect(bounds, 0.5, 0.5);
CGFloat x = NSMinX(bounds), y = NSMinY(bounds), w = NSWidth(bounds), h =
NSHeight(bounds);
- CGFloat r = 0.1 * fmin(w, h);
CGPoint points[9] = {{x + 0.55 * w, y + 0.65 * h},
{x + w, y + 0.15 * h},
{x + w, y},
@@ -329,11 +334,14 @@
{x + 0.4 * w, y + 0.3 * h},
{x + 0.4 * w, y + 0.45 * h}};
CGContextAddLines(context, points, 9);
- CGContextAddArcToPoint(context, x, y + 0.45 * h, x, y + h, r);
- CGContextAddArcToPoint(context, x, y + h, x + w, y + h, 2.0 * r);
- CGContextAddArcToPoint(context, x + 0.55 * w, y + h, x + 0.55 * w, y, r);
+ CGContextAddLineToPoint(context, x + 0.1 * w, y + 0.45 * h);
+ CGContextAddCurveToPoint(context, x + (0.1 - 0.1 * KAPPA) * w, y + 0.45 *
h, x, y + (0.55 - 0.1 * KAPPA) * h, x, y + 0.55 * h);
+ CGContextAddLineToPoint(context, x, y + 0.8 * h);
+ CGContextAddCurveToPoint(context, x, y + (0.8 + 0.2 * KAPPA) * h, x + (0.2
- 0.2 * KAPPA) * w, y + h, x + 0.2 * w, y + h);
+ CGContextAddLineToPoint(context, x + 0.45 * w, y + h);
+ CGContextAddCurveToPoint(context, x + (0.45 + 0.1 * KAPPA) * w, y + h, x +
0.55 * w, y + (0.9 + 0.1 * KAPPA) * h, x + 0.55 * w, y + 0.9 * h);
CGContextClosePath(context);
- CGContextAddEllipseInRect(context, CGRectMake(x + 1.0 * r, y + h - 3.0 *
r, 2.0 * r, 2.0 * r));
+ CGContextAddEllipseInRect(context, CGRectMake(x + 0.1 * w, y + h - 0.3 *
h, 0.2 * w, 0.2 * h));
CGContextDrawPath(context, kCGPathEOFillStroke);
}
@@ -365,16 +373,21 @@
static inline void drawIconHelp(CGContextRef context, NSRect bounds) {
bounds = NSInsetRect(bounds, 0.5, 0.5);
- if (NSWidth(bounds) < NSHeight(bounds))
- bounds = NSInsetRect(bounds, 0.0, 0.5 * (NSWidth(bounds) -
NSHeight(bounds)));
- else if (NSHeight(bounds) < NSWidth(bounds))
- bounds = NSInsetRect(bounds, 0.5 * (NSHeight(bounds) -
NSWidth(bounds)), 0.0);
CGFloat x = NSMinX(bounds), y = NSMinY(bounds), w = NSWidth(bounds), h =
NSHeight(bounds);
- CGContextSetLineWidth(context, 0.1 * w);
- CGContextAddArc(context, x + 0.5 * w, y + 0.65 * h, 0.175 * w, M_PI,
-M_PI_4, 1);
- CGContextAddArc(context, x + 0.675 * w, y + (0.825 - 0.35 * M_SQRT2) * h,
0.175 * w, 3.0 * M_PI_4, M_PI, 0);
- CGContextReplacePathWithStrokedPath(context);
- CGContextSetLineWidth(context, 1.0);
+ CGContextSetLineJoin(context, kCGLineJoinRound);
+ CGContextMoveToPoint(context, x + 0.275 * w, y + 0.65 * h);
+ CGContextAddCurveToPoint(context, x + 0.275 * w, y + (0.65 + 0.225 *
KAPPA) * h, x + (0.5 - 0.225 * KAPPA) * w, y + 0.875 * h, x + 0.5 * w, y +
0.875 * h);
+ CGContextAddCurveToPoint(context, x + (0.5 + 0.225 * KAPPA) * w, y + 0.875
* h, x + 0.725 * w, y + (0.65 + 0.225 * KAPPA) * h, x + 0.725 * w, y + 0.65 *
h);
+ CGContextAddCurveToPoint(context, x + 0.725 * w, y + (0.65 - 0.225 *
KAPPA2) * h, x + (0.5 + 0.225 * M_SQRT1_2 + 0.225 * M_SQRT1_2 * KAPPA2) * w, y
+ (0.65 - 0.225 * M_SQRT1_2 + 0.225 * M_SQRT1_2 * KAPPA2) * h, x + (0.5 + 0.225
* M_SQRT1_2) * w, y + (0.65 - 0.225 * M_SQRT1_2) * h);
+ CGContextAddLineToPoint(context, x + (0.675 - 0.125 * M_SQRT1_2) * w, y +
(0.825 - 0.575 * M_SQRT1_2) * h);
+ CGContextAddCurveToPoint(context, x + (0.675 - 0.125 * M_SQRT1_2 - 0.125 *
M_SQRT1_2 * KAPPA2) * w, y + (0.825 - 0.575 * M_SQRT1_2 - 0.125 * M_SQRT1_2 *
KAPPA2) * h, x + 0.55 * w, y + (0.825 - 0.7 * M_SQRT1_2 + 0.125 * KAPPA2) * h,
x + 0.55 * w, y + (0.825 - 0.7 * M_SQRT1_2) * h);
+ CGContextAddLineToPoint(context, x + 0.45 * w, y + (0.825 - 0.7 *
M_SQRT1_2) * h);
+ CGContextAddCurveToPoint(context, x + 0.45 * w, y + (0.825 - 0.7 *
M_SQRT1_2 + 0.225 * KAPPA2) * h, x + (0.675 - 0.225 * M_SQRT1_2 - 0.225 *
M_SQRT1_2 * KAPPA2) * w, y + (0.825 - 0.475 * M_SQRT1_2 - 0.225 * M_SQRT1_2 *
KAPPA2) * h, x + (0.675 - 0.225 * M_SQRT1_2) * w, y + (0.825 - 0.475 *
M_SQRT1_2) * h);
+ CGContextAddLineToPoint(context, x + (0.5 + 0.125 * M_SQRT1_2) * w, y +
(0.65 - 0.125 * M_SQRT1_2) * h);
+ CGContextAddCurveToPoint(context,x + (0.5 + 0.125 * M_SQRT1_2 + 0.125 *
M_SQRT1_2 * KAPPA2) * w, y + (0.65 - 0.125 * M_SQRT1_2 + 0.125 * M_SQRT1_2 *
KAPPA2) * h, x + 0.625 * w, y + (0.65 - 0.125 * KAPPA2) * h, x + 0.625 * w, y +
0.65 * h);
+ CGContextAddCurveToPoint(context, x + 0.625 * w, y + (0.65 + 0.125 *
KAPPA) * h, x + (0.5 + 0.125 * KAPPA) * w, y + 0.775 * h, x + 0.5 * w, y +
0.775 * h);
+ CGContextAddCurveToPoint(context, x + (0.5 - 0.125 * KAPPA) * w, y + 0.775
* h, x + 0.375 * w, y + (0.65 + 0.125 * KAPPA) * h, x + 0.375 * w, y + 0.65 *
h);
+ CGContextClosePath(context);
CGContextAddEllipseInRect(context, CGRectMake(x + 0.425 * w, y + 0.1 * h,
0.15 * w, 0.15 * h));
CGContextAddEllipseInRect(context, NSRectToCGRect(bounds));
CGContextClosePath(context);
@@ -384,7 +397,6 @@
static inline void drawIconNewParagraph(CGContextRef context, NSRect bounds) {
bounds = NSInsetRect(bounds, 0.075 * NSWidth(bounds) + 0.5, 0.5);
CGFloat x = NSMinX(bounds), y = NSMinY(bounds), w = NSWidth(bounds), h =
NSHeight(bounds);
- CGFloat r = fmin(0.3 * w, 0.1 * h);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGPoint points1[3] = {{x + 0.1 * w, y + 0.5 * h},
{x + 0.5 * w, y + h},
@@ -399,8 +411,9 @@
CGContextAddLines(context, points2, 4);
CGContextMoveToPoint(context, x + 0.6 * w, y - 0.5);
CGContextAddLineToPoint(context, x + 0.6 * w, y + 0.4 * h);
- CGContextAddArcToPoint(context, x + 0.9 * w, y + 0.4 * h, x + 0.9 * w, y +
0.2 * h, r);
- CGContextAddArcToPoint(context, x + 0.9 * w, y + 0.2 * h, x + 0.6 * w, y +
0.2 * h, r);
+ CGContextAddLineToPoint(context, x + 0.8 * w, y + 0.4 * h);
+ CGContextAddCurveToPoint(context, x + (0.8 + 0.1 * KAPPA) * w, y + 0.4 *
h, x + 0.9 * w, y + (0.3 + 0.1 * KAPPA) * h, x + 0.9 * w, y + 0.3 * h);
+ CGContextAddCurveToPoint(context, x + 0.9 * w, y + (0.3 - 0.1 * KAPPA) *
h, x + (0.8 + 0.1 * KAPPA) * w, y + 0.2 * h, x + 0.8 * w, y + 0.2 * h);
CGContextAddLineToPoint(context, x + 0.6 * w, y + 0.2 * h);
CGContextStrokePath(context);
}
@@ -408,7 +421,6 @@
static inline void drawIconParagraph(CGContextRef context, NSRect bounds) {
bounds = NSInsetRect(bounds, 0.075 * NSWidth(bounds) + 0.5, 0.5);
CGFloat x = NSMinX(bounds), y = NSMinY(bounds), w = NSWidth(bounds), h =
NSHeight(bounds);
- CGFloat r = fmin(0.4 * w, 0.25 * h);
CGPoint points[8] = {{x + 0.9 * w, y + h},
{x + 0.9 * w, y},
{x + 0.76 * w, y},
@@ -418,8 +430,9 @@
{x + 0.5 * w, y},
{x + 0.5 * w, y + 0.5 * h}};
CGContextAddLines(context, points, 8);
- CGContextAddArcToPoint(context, x + 0.1 * w, y + 0.5 * h, x + 0.1 * w, y +
h, r);
- CGContextAddArcToPoint(context, x + 0.1 * w, y + h, x + 0.9 * w, y + h, r);
+ CGContextAddLineToPoint(context, x + 0.35 * w, y + 0.5 * h);
+ CGContextAddCurveToPoint(context, x + (0.35 - 0.25 * KAPPA) * w, y + 0.5 *
h, x + 0.1 * w, y + (0.75 - 0.25 * KAPPA) * h, x + 0.1 * w, y + 0.75 * h);
+ CGContextAddCurveToPoint(context, x + 0.1 * w, y + (0.75 + 0.25 * KAPPA) *
h, x + (0.35 - 0.25 * KAPPA) * w, y + h, x + 0.35 * w, y + h);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFillStroke);
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit