# CutBox.app

## Coverage Report

#### Created: 2024-03-12 03:40

    .../Source/Extensions/NSImage+tint.swift

    Line

    Count

    Source (jump to first uncovered line)

    1

    //

    2

    //  NSImage+tint.swift

    3

    //  CutBox

    4

    //

    5

    //  Created by Jason Milkins on 10/5/18.

    6

    //  Copyright © 2018-2023 ocodo. All rights reserved.

    7

    //

    8

    9

    import Cocoa

    10

    11

    extension NSImage {

    12

    405

        func tint(color: NSColor, fill: NSCompositingOperation = .sourceAtop) -> NSImage {

    13

    405

            guard !self.isTemplate

    14

    405

                else { return self }

    15

    404

    16

    404

            guard let image = self.copy() as? NSImage

    17

    404

                else { return self }

    18

    404

    19

    404

            image.lockFocus()

    20

    404

            color.set()

    21

    404

    22

    404

            let imageRect = NSRect(origin: NSPoint.zero, size: image.size)

    23

    404

            imageRect.fill(using: fill)

    24

    404

    25

    404

            image.unlockFocus()

    26

    404

            image.isTemplate = false

    27

    404

    28

    404

            return image

    29

    404

        }

    30

    }