Skip to content

Commit 1068368

Browse files
committed
Size: add some documentation comments (NFC)
Add some documentation comments and region markers to Size.
1 parent 179daa8 commit 1068368

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

Sources/SwiftWin32/CG/Size.swift

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
11
// Copyright © 2019 Saleem Abdulrasool <[email protected]>
22
// SPDX-License-Identifier: BSD-3-Clause
33

4+
/// A structure that contains width and height values.
45
public struct Size {
5-
public static let zero: Size = Size(width: 0, height: 0)
6+
// MARK - Geometric Properties
67

7-
public var height: Double
8+
/// A width value.
89
public var width: Double
910

10-
public init(width: Float, height: Float) {
11-
self.init(width: Double(width), height: Double(height))
11+
/// A height value.
12+
public var height: Double
13+
14+
// MARK - Special Values
15+
16+
/// The size whose width and height are both zero.
17+
public static var zero: Size {
18+
Size(width: 0, height: 0)
1219
}
1320

21+
/// Creates a size with zero width and height.
22+
public init() {
23+
self = .zero
24+
}
25+
26+
// MARK - Transforming Sizes
27+
28+
/// Returns the height and width resulting from a transformation of an
29+
/// existing height and width.
30+
func applying(_ transform: AffineTransform) -> Size {
31+
return Size(width: transform.a * self.width + transform.c * self.height,
32+
height: transform.b * self.width + transform.d * self.height)
33+
}
34+
35+
// MARK - Initializers
36+
37+
/// Creates a size with dimensions specified as floating-point values.
1438
public init(width: Double, height: Double) {
1539
self.height = height
1640
self.width = width
@@ -19,11 +43,6 @@ public struct Size {
1943
public init(width: Int, height: Int) {
2044
self.init(width: Double(width), height: Double(height))
2145
}
22-
23-
func applying(_ transform: AffineTransform) -> Size {
24-
return Size(width: transform.a * self.width + transform.c * self.height,
25-
height: transform.b * self.width + transform.d * self.height)
26-
}
2746
}
2847

2948
extension Size: Equatable {

0 commit comments

Comments
 (0)