Skip to content

Commit

Permalink
Use CommentIconDrawingController for drawing NoteAnnotation
Browse files Browse the repository at this point in the history
  • Loading branch information
mvasilak committed Feb 19, 2024
1 parent 081d826 commit 57b8b78
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 59 deletions.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions Zotero/Controllers/CommentIconDrawingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ struct CommentIconDrawingController {
let origin: CGPoint = CGPoint(x: boundingBox.minX - (size.width / 2), y: boundingBox.maxY - (size.height / 2))
draw(context: context, origin: origin, size: size, color: color, alpha: 0.5)
}

static func drawNoteAnnotation(context: CGContext, boundingBox: CGRect, color: UIColor) {
draw(context: context, origin: boundingBox.origin, size: boundingBox.size, color: color, alpha: 1)
}
}
2 changes: 0 additions & 2 deletions Zotero/Extensions/Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ internal enum Asset {
}
internal enum Images {
internal enum Annotations {
internal static let annotationNoteColored = ImageAsset(name: "Annotations/annotation-note-colored")
internal static let annotationNote = ImageAsset(name: "Annotations/annotation-note")
internal static let areaLarge = ImageAsset(name: "Annotations/area.large")
internal static let areaMedium = ImageAsset(name: "Annotations/area.medium")
internal static let eraserLarge = ImageAsset(name: "Annotations/eraser.large")
Expand Down
13 changes: 2 additions & 11 deletions Zotero/Scenes/Detail/PDF/Models/NoteAnnotation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,8 @@ final class NoteAnnotation: PSPDFKit.NoteAnnotation {
}

override func drawImage(in context: CGContext, boundingBox: CGRect, options: RenderOptions?) {
let outlineImage = Asset.Images.Annotations.annotationNote.image
let colorizedImage = Asset.Images.Annotations.annotationNoteColored.image

guard let colorizedCgImage = colorizedImage.cgImage, let outlineCgImage = outlineImage.cgImage, let color = self.color else { return }

context.clip(to: boundingBox, mask: colorizedCgImage)
color.setFill()
context.fill(boundingBox)

context.resetClip()
context.draw(outlineCgImage, in: boundingBox)
guard let color else { return }
CommentIconDrawingController.drawNoteAnnotation(context: context, boundingBox: boundingBox, color: color)
}

override class var supportsSecureCoding: Bool {
Expand Down

0 comments on commit 57b8b78

Please sign in to comment.