-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGraphicBox.swift
64 lines (61 loc) · 1.89 KB
/
GraphicBox.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// GraphicBox.swift
//
//
// Created by chen on 2023/11/11.
//
import Foundation
/// The ^GB command is used to draw boxes and lines as part of a label format.
/// Boxes and lines are used to highlight important information, divide labels into distinct areas,
/// or to improve the appearance of a label.
/// The same format command is used for drawing either boxes or lines.
///
/// # Graphic Box
public struct GraphicBox: ZPLCommandConvertible {
/// Box width (in dots)
///
/// Values: value of `lineWidth` to 32000
///
/// Default: value used for thickness (t) or 1
public var width: Int
/// Box height (in dots)
///
/// Values: value of `lineWidth` to 32000
///
/// Default: value used for thickness (t) or 1
public var height: Int
/// Border thickness (in dots)
///
/// Values: 1 to 32000
///
/// Default: 1
public var lineWidth: Int
/// Line color
///
/// Default: `.black`
public var lineColor: FieldColor
/// Degree of corner-rounding
///
/// Values: 0 (no rounding) to 8 (heaviest rounding)
///
/// Default: 0
public var rounding: Int
public var command: String {
"^GB\(width),\(height),\(lineWidth),\(lineColor.rawValue),\(rounding)"
}
/// Graphic Box.
///
/// - Parameters:
/// - width: Box width (in dots). Value of `lineWidth` to 32000
/// - height: Box height (in dots). Value of `lineWidth` to 32000
/// - lineWidth: Border thickness (in dots).
/// - lineColor: Line color.
/// - rounding: Degree of corner-rounding. 0 (no rounding) to 8 (heaviest rounding)
public init(width: Int, height: Int, lineWidth: Int = 1, lineColor: FieldColor = .black, rounding: Int = 0) {
self.width = width
self.height = height
self.lineWidth = lineWidth
self.lineColor = lineColor
self.rounding = rounding
}
}