Skip to content

Commit 50d0a0a

Browse files
committed
rfac: Change global constant zeroPoint into a static property on Point and adjust everywhere where it was being used.
1 parent 3966140 commit 50d0a0a

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

Sources/AGGRenderer/AGGRenderer/AGGRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import SwiftPlot
44

55
public class AGGRenderer: Renderer{
66

7-
public var offset = zeroPoint
7+
public var offset: Point = .zero
88
public var imageSize: Size {
99
willSet {
1010
delete_plot(agg_object);

Sources/QuartzRenderer/QuartzRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class QuartzRenderer: Renderer {
1919
/// Whether or not this context was given to us. If `true`, we should never re-make `context`
2020
let isExternalContext: Bool
2121
var fontPath = ""
22-
public var offset = zeroPoint
22+
public var offset: Point = .zero
2323

2424
public var fontSmoothing: Bool = false {
2525
didSet { context.setShouldSmoothFonts(fontSmoothing) }

Sources/SVGRenderer/SVGRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class SVGRenderer: Renderer{
2424
static let gridHatch: String = #"<defs><pattern id="gridHatch" width="10" height="10" patternUnits="userSpaceOnUse"><line x1="0" y1="5" x2="10" y2="5" style="stroke:black; stroke-width:1" /><line x1="5" y1="0" x2="5" y2="10" style="stroke:black; stroke-width:1" /></pattern></defs>"#
2525
static let crossHatch: String = #"<defs><pattern id="crossHatch" width="10" height="10" patternUnits="userSpaceOnUse"><line x1="0" y1="0" x2="10" y2="10" style="stroke:black; stroke-width:1" /><line x1="0" y1="10" x2="10" y2="0" style="stroke:black; stroke-width:1" /></pattern></defs>"#
2626

27-
public var offset = zeroPoint
27+
public var offset: Point = .zero
2828
public var imageSize: Size
2929

3030
var hatchingIncluded = Array(repeating: false,

Sources/SwiftPlot/BarChart.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public class BarGraph<T:LosslessStringConvertible,U:FloatConvertible>: Plot {
1818
var stackSeries = [Series<T,U>]()
1919
var scaleY: Float = 1
2020
var scaleX: Float = 1
21-
var barWidth : Int = 0
22-
var origin = zeroPoint
21+
var barWidth: Int = 0
22+
var origin: Point = .zero
2323

2424
public init(enableGrid: Bool = false){
2525
self.enableGrid = enableGrid
@@ -123,7 +123,7 @@ extension BarGraph: HasGraphLayout {
123123
}
124124

125125
if (minimumY >= U(0)) {
126-
origin = zeroPoint
126+
origin = .zero
127127
minimumY = U(0)
128128
}
129129
else{
@@ -208,7 +208,7 @@ extension BarGraph: HasGraphLayout {
208208
}
209209

210210
if minimumX >= U(0) {
211-
origin = zeroPoint
211+
origin = .zero
212212
minimumX = U(0)
213213
}
214214
else{

Sources/SwiftPlot/GraphLayout.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public struct GraphLayout {
9090
/// Calculates the region of the plot which is used for displaying the plot's data (inside all of the chrome).
9191
func calcBorder(sizes: Results.Sizes, renderer: Renderer) -> Rect {
9292
var borderRect = Rect(
93-
origin: zeroPoint,
93+
origin: .zero,
9494
size: self.plotSize
9595
)
9696
if let xLabel = sizes.xLabelSize {
@@ -179,7 +179,7 @@ public struct GraphLayout {
179179
// Drawing.
180180

181181
func drawBackground(results: Results, renderer: Renderer) {
182-
renderer.drawSolidRect(Rect(origin: zeroPoint, size: plotSize), fillColor: backgroundColor, hatchPattern: .none)
182+
renderer.drawSolidRect(Rect(origin: .zero, size: plotSize), fillColor: backgroundColor, hatchPattern: .none)
183183
if let plotBackgroundColor = plotBackgroundColor {
184184
renderer.drawSolidRect(results.plotBorderRect, fillColor: plotBackgroundColor, hatchPattern: .none)
185185
}

Sources/SwiftPlot/Histogram.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Histogram<T:FloatConvertible>: Plot {
1616
var scaleX: Float = 1
1717
var barWidth: Float = 0
1818
var xMargin: Float = 5
19-
var origin = zeroPoint
19+
var origin: Point = .zero
2020

2121
public init(isNormalized: Bool = false,
2222
enableGrid: Bool = false){

Sources/SwiftPlot/Pair.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ public struct Pair<T,U> {
1010
}
1111

1212
public typealias Point = Pair<Float,Float>
13-
public let zeroPoint = Point(0.0, 0.0)
13+
14+
extension Point {
15+
public static let zero = Point(0.0, 0.0)
16+
}
1417

1518
public func + (lhs: Point, rhs: Point) -> Point {
1619
return Point(lhs.x + rhs.x, lhs.y + rhs.y)
@@ -42,7 +45,7 @@ public struct Rect {
4245
}
4346
extension Rect {
4447

45-
public static let empty = Rect(origin: zeroPoint, size: .zero)
48+
public static let empty = Rect(origin: .zero, size: .zero)
4649

4750
public var normalized: Rect {
4851
let normalizedOrigin = Point(origin.x + (size.width < 0 ? size.width : 0),

0 commit comments

Comments
 (0)