1 /*
2     PPGeometry.h
3 
4     Copyright 2013-2018,2020 Josh Freeman
5     http://www.twilightedge.com
6 
7     This file is part of PikoPixel for Mac OS X and GNUstep.
8     PikoPixel is a graphical application for drawing & editing pixel-art images.
9 
10     PikoPixel is free software: you can redistribute it and/or modify it under
11     the terms of the GNU Affero General Public License as published by the
12     Free Software Foundation, either version 3 of the License, or (at your
13     option) any later version approved for PikoPixel by its copyright holder (or
14     an authorized proxy).
15 
16     PikoPixel is distributed in the hope that it will be useful, but WITHOUT ANY
17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18     FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19     details.
20 
21     You should have received a copy of the GNU Affero General Public License
22     along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #import <Foundation/Foundation.h>
26 
27 
28 NSPoint PPGeometry_CenterOfRect(NSRect rect);
29 NSRect PPGeometry_OriginRectOfSize(NSSize frameSize);
30 NSRect PPGeometry_CenterRectInRect(NSRect rectToBeCentered, NSRect centerRect);
31 NSRect PPGeometry_PixelBoundsCoveredByRect(NSRect rect);
32 NSRect PPGeometry_PixelBoundsWithCornerPoints(NSPoint corner1, NSPoint corner2);
33 NSRect PPGeometry_PixelBoundsWithCenterAndCornerPoint(NSPoint center, NSPoint corner);
34 NSRect PPGeometry_PixelCenteredRect(NSRect rect);
35 NSRect PPGeometry_RectScaledByFactor(NSRect rect, float scalingFactor);
36 bool PPGeometry_RectCoversMultiplePoints(NSRect rect);
37 bool PPGeometry_RectIsSquare(NSRect rect);
38 NSPoint PPGeometry_PointClippedToIntegerValues(NSPoint point);
39 NSPoint PPGeometry_PointClippedToRect(NSPoint point, NSRect rect);
40 NSPoint PPGeometry_PointSum(NSPoint point1, NSPoint point2);
41 NSPoint PPGeometry_PointDifference(NSPoint point1, NSPoint point2);
42 float PPGeometry_DistanceBetweenPoints(NSPoint point1, NSPoint point2);
43 unsigned PPGeometry_IntegerDistanceBetweenPoints(NSPoint point1, NSPoint point2);
44 NSPoint PPGeometry_PixelCenteredPoint(NSPoint point);
45 bool PPGeometry_PointTouchesEdgePixelOfRect(NSPoint point, NSRect rect);
46 NSSize PPGeometry_SizeClippedToIntegerValues(NSSize size);
47 NSSize PPGeometry_SizeClampedToMinMaxValues(NSSize size, float minValue, float maxValue);
48 NSSize PPGeometry_SizeSum(NSSize size1, NSSize size2);
49 NSSize PPGeometry_SizeDifference(NSSize size1, NSSize size2);
50 NSSize PPGeometry_SizeScaledByFactorAndRoundedToIntegerValues(NSSize size, float scalingFactor);
51 bool PPGeometry_IsZeroSize(NSSize size);
52 bool PPGeometry_SizeExceedsDimension(NSSize size, float dimension);
53 NSPoint PPGeometry_OriginPointForCenteringRectAtPoint(NSRect rect, NSPoint centerPoint);
54 NSPoint PPGeometry_OriginPointForCenteringSizeInSize(NSSize centeringSize, NSSize centerSize);
55 NSRect PPGeometry_ScaledBoundsForFrameOfSizeToFitFrameOfSize(NSSize sourceSize,
56                                                             NSSize destinationSize);
57 float PPGeometry_ScalingFactorOfSourceRectToDestinationRect(NSRect sourceRect,
58                                                             NSRect destinationRect);
59 NSPoint PPGeometry_OriginPointForConfiningRectInsideRect(NSRect rect, NSRect confinementBounds);
60 NSPoint PPGeometry_FarthestPointOnDiagonal(NSPoint originPoint, NSPoint point);
61 NSPoint PPGeometry_NearestPointOnOneSixteenthSlope(NSPoint originPoint, NSPoint point);
62 NSPoint PPGeometry_OffsetPointToNextNearestVertexOnGridWithSpacingSize(NSPoint point,
63                                                                         NSSize spacingSize);
64 NSRect PPGeometry_GridBoundsCoveredByRectOnCanvasOfSizeWithGridOfSpacingSize(NSRect rect,
65                                                                             NSSize canvasSize,
66                                                                             NSSize spacingSize);
67