feat: add more pens in newly created memo object

This commit is contained in:
dscyrescotti
2024-05-19 21:43:06 +07:00
parent 3b0d93477e
commit 20ed32b186
2 changed files with 9 additions and 5 deletions

View File

@@ -221,7 +221,7 @@ struct PenDock: View {
)
Picker("", selection: selection) {
ForEach(pen.style.thicknessSteps, id: \.self) { step in
let size = ((step - minimum) * (end - start) / (maximum - minimum)) + start - (1 / step)
let size = ((step - minimum) * (end - start) / (maximum - minimum)) + start - (0.5 / step)
Circle()
.fill(.black)
.frame(width: size, height: size)

View File

@@ -76,8 +76,12 @@ struct MemosView: View {
let eraserPenObject = PenObject.createObject(\.viewContext, penStyle: .eraser)
eraserPenObject.orderIndex = 0
let markerPenObject = PenObject.createObject(\.viewContext, penStyle: .marker)
markerPenObject.orderIndex = 1
let markerPenObjects = [Color.red, Color.blue, Color.yellow, Color.black].enumerated().map { (index, color) in
let penObject = PenObject.createObject(\.viewContext, penStyle: .marker)
penObject.orderIndex = Int16(index) + 1
penObject.color = color.components
return penObject
}
let graphicContextObject = GraphicContextObject(\.viewContext)
graphicContextObject.strokes = []
@@ -89,10 +93,10 @@ struct MemosView: View {
canvasObject.graphicContext = graphicContextObject
toolObject.memo = memoObject
toolObject.pens = [eraserPenObject, markerPenObject]
toolObject.pens = .init(array: [eraserPenObject] + markerPenObjects)
eraserPenObject.tool = toolObject
markerPenObject.tool = toolObject
markerPenObjects.forEach { $0.tool = toolObject }
graphicContextObject.canvas = canvasObject