Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f137f89bf | ||
|
|
b998ea210e | ||
|
|
86826f7ecc |
@@ -25,11 +25,14 @@ No network calls, no API keys — everything runs locally.
|
|||||||
## Install with Homebrew
|
## Install with Homebrew
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew tap TZGyn/tap
|
brew tap TZGyn/tap https://gitea.tzgyn.dev/TZGyn/homebrew-tap.git
|
||||||
brew trust TZGyn/tap # Homebrew 6+ requires trusting third-party taps
|
brew trust TZGyn/tap
|
||||||
brew install --cask kapture
|
brew install --cask kapture
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The tap is hosted on Gitea, so the full URL is required. Homebrew may print
|
||||||
|
an "Unsupported tap" warning — it's harmless.
|
||||||
|
|
||||||
Releases are published as zips on GitHub Releases; `release.sh` packages a
|
Releases are published as zips on GitHub Releases; `release.sh` packages a
|
||||||
new one (`./release.sh 1.0.1 && git tag v1.0.1 && git push origin v1.0.1`).
|
new one (`./release.sh 1.0.1 && git tag v1.0.1 && git push origin v1.0.1`).
|
||||||
The cask lives in the [TZGyn/homebrew-tap](https://github.com/TZGyn/homebrew-tap)
|
The cask lives in the [TZGyn/homebrew-tap](https://github.com/TZGyn/homebrew-tap)
|
||||||
|
|||||||
@@ -97,24 +97,19 @@ final class OverlayView: NSView {
|
|||||||
|
|
||||||
private func windowFrame(at point: NSPoint) -> NSRect? {
|
private func windowFrame(at point: NSPoint) -> NSRect? {
|
||||||
guard let window = window else { return nil }
|
guard let window = window else { return nil }
|
||||||
let screenPoint = window.convertToScreen(NSRect(origin: point, size: .zero))
|
// convertToScreen gives AppKit-global coordinates; convert tracked
|
||||||
// CGWindowList bounds use a TOP-LEFT origin; convert the cursor point.
|
// CG frames to the same space and pick the frontmost containing it.
|
||||||
guard let mainScreen = NSScreen.screens.first else { return nil }
|
let screenPoint = window.convertToScreen(NSRect(origin: point, size: .zero)).origin
|
||||||
let topLeftPoint = NSPoint(
|
|
||||||
x: screenPoint.origin.x,
|
|
||||||
y: mainScreen.frame.height - screenPoint.origin.y
|
|
||||||
)
|
|
||||||
// Pick the frontmost (list order) window containing the point
|
|
||||||
for (_, frame) in trackedWindows {
|
for (_, frame) in trackedWindows {
|
||||||
if frame.contains(topLeftPoint) {
|
if Self.cgToAppKit(rect: frame).contains(screenPoint) {
|
||||||
return frame
|
return frame
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a CGWindowList (top-left origin) frame into AppKit screen
|
/// Convert a CGWindowList (top-left origin, CG global space) frame into
|
||||||
/// coordinates (bottom-left origin) for capture.
|
/// AppKit screen coordinates (bottom-left origin) for capture.
|
||||||
private static func cgToAppKit(rect: NSRect) -> NSRect {
|
private static func cgToAppKit(rect: NSRect) -> NSRect {
|
||||||
guard let mainScreen = NSScreen.screens.first else { return rect }
|
guard let mainScreen = NSScreen.screens.first else { return rect }
|
||||||
let y = mainScreen.frame.height - rect.origin.y - rect.height
|
let y = mainScreen.frame.height - rect.origin.y - rect.height
|
||||||
@@ -189,12 +184,13 @@ final class OverlayView: NSView {
|
|||||||
|
|
||||||
// Highlight the hovered window (rounded, like the real window corners)
|
// Highlight the hovered window (rounded, like the real window corners)
|
||||||
if let frame = hoveredWindowFrame {
|
if let frame = hoveredWindowFrame {
|
||||||
// Convert CGWindowList (top-left) frame to view (bottom-left) space
|
// Convert the CG frame to AppKit-global, then to this view's space.
|
||||||
guard let window = window, let mainScreen = NSScreen.screens.first else { return }
|
guard let window = window else { return }
|
||||||
let screenFrame = window.convertToScreen(NSRect(origin: .zero, size: bounds.size))
|
let screenFrame = window.convertToScreen(NSRect(origin: .zero, size: bounds.size))
|
||||||
|
let appKitFrame = Self.cgToAppKit(rect: frame)
|
||||||
let viewFrame = NSRect(
|
let viewFrame = NSRect(
|
||||||
x: frame.origin.x - screenFrame.origin.x,
|
x: appKitFrame.origin.x - screenFrame.origin.x,
|
||||||
y: mainScreen.frame.height - frame.origin.y - frame.height - screenFrame.origin.y,
|
y: appKitFrame.origin.y - screenFrame.origin.y,
|
||||||
width: frame.width,
|
width: frame.width,
|
||||||
height: frame.height
|
height: frame.height
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ final class CaptureModel: ObservableObject {
|
|||||||
@Published var redoStack: [Stroke] = []
|
@Published var redoStack: [Stroke] = []
|
||||||
/// Whether the pen is active (drag draws instead of selecting)
|
/// Whether the pen is active (drag draws instead of selecting)
|
||||||
@Published var isDrawing = false
|
@Published var isDrawing = false
|
||||||
|
/// Whether drawing redacts (black bar) instead of pen strokes
|
||||||
|
@Published var isRedacting = false
|
||||||
/// Current drawing color
|
/// Current drawing color
|
||||||
@Published var drawColor: NSColor = .systemRed
|
@Published var drawColor: NSColor = .systemRed
|
||||||
/// Stroke thickness in points (image space)
|
/// Stroke thickness in points (image space)
|
||||||
@@ -105,6 +107,7 @@ final class CaptureModel: ObservableObject {
|
|||||||
let points: [CGPoint]
|
let points: [CGPoint]
|
||||||
let width: CGFloat
|
let width: CGFloat
|
||||||
let color: NSColor
|
let color: NSColor
|
||||||
|
var isRedaction: Bool = false
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CaptureMode {
|
enum CaptureMode {
|
||||||
@@ -159,6 +162,20 @@ final class CaptureModel: ObservableObject {
|
|||||||
ctx.setLineJoin(.round)
|
ctx.setLineJoin(.round)
|
||||||
for stroke in strokes {
|
for stroke in strokes {
|
||||||
guard stroke.points.count > 1 else { continue }
|
guard stroke.points.count > 1 else { continue }
|
||||||
|
if stroke.isRedaction {
|
||||||
|
// Redaction bar: filled black rect covering the stroke bounds,
|
||||||
|
// padded so it fully covers text.
|
||||||
|
let xs = stroke.points.map { $0.x }
|
||||||
|
let ys = stroke.points.map { $0.y }
|
||||||
|
let bar = NSRect(
|
||||||
|
x: xs.min()! - 2,
|
||||||
|
y: ys.min()! - 2,
|
||||||
|
width: (xs.max()! - xs.min()!) + 4,
|
||||||
|
height: max(stroke.width, ys.max()! - ys.min()!) + 4
|
||||||
|
)
|
||||||
|
NSColor.black.setFill()
|
||||||
|
NSBezierPath(rect: bar).fill()
|
||||||
|
} else {
|
||||||
stroke.color.setStroke()
|
stroke.color.setStroke()
|
||||||
ctx.setLineWidth(stroke.width)
|
ctx.setLineWidth(stroke.width)
|
||||||
ctx.beginPath()
|
ctx.beginPath()
|
||||||
@@ -168,6 +185,7 @@ final class CaptureModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
ctx.strokePath()
|
ctx.strokePath()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ctx.restoreGState()
|
ctx.restoreGState()
|
||||||
NSGraphicsContext.restoreGraphicsState()
|
NSGraphicsContext.restoreGraphicsState()
|
||||||
return rep.cgImage ?? image
|
return rep.cgImage ?? image
|
||||||
@@ -175,7 +193,13 @@ final class CaptureModel: ObservableObject {
|
|||||||
|
|
||||||
func addStroke(_ points: [CGPoint]) {
|
func addStroke(_ points: [CGPoint]) {
|
||||||
guard points.count > 1 else { return }
|
guard points.count > 1 else { return }
|
||||||
|
if isRedacting {
|
||||||
|
// Redaction: a filled black bar from start to end, as thick as the
|
||||||
|
// current stroke width (drawn as a rect for clean edges).
|
||||||
|
strokes.append(Stroke(points: points, width: max(strokeWidth, 12), color: .black, isRedaction: true))
|
||||||
|
} else {
|
||||||
strokes.append(Stroke(points: points, width: strokeWidth, color: drawColor))
|
strokes.append(Stroke(points: points, width: strokeWidth, color: drawColor))
|
||||||
|
}
|
||||||
redoStack = []
|
redoStack = []
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,12 +375,17 @@ struct ResultView: View {
|
|||||||
// Draw toolbar (only when drawing)
|
// Draw toolbar (only when drawing)
|
||||||
if model.isDrawing {
|
if model.isDrawing {
|
||||||
HStack(spacing: 14) {
|
HStack(spacing: 14) {
|
||||||
Label("Draw", systemImage: "pencil.tip")
|
Picker("", selection: $model.isRedacting) {
|
||||||
.font(.caption)
|
Label("Pen", systemImage: "pencil.tip").tag(false)
|
||||||
.foregroundStyle(.secondary)
|
Label("Redact", systemImage: "rectangle.fill").tag(true)
|
||||||
|
}
|
||||||
|
.pickerStyle(.segmented)
|
||||||
|
.fixedSize()
|
||||||
|
.help("Pen draws strokes; Redact covers text with a black bar")
|
||||||
|
|
||||||
Divider().frame(height: 18)
|
Divider().frame(height: 18)
|
||||||
|
|
||||||
|
if !model.isRedacting {
|
||||||
HStack(spacing: 6) {
|
HStack(spacing: 6) {
|
||||||
Image(systemName: "circle.fill").font(.system(size: 4))
|
Image(systemName: "circle.fill").font(.system(size: 4))
|
||||||
Image(systemName: "circle.fill").font(.system(size: 7))
|
Image(systemName: "circle.fill").font(.system(size: 7))
|
||||||
@@ -376,6 +405,7 @@ struct ResultView: View {
|
|||||||
.labelsHidden()
|
.labelsHidden()
|
||||||
.frame(width: 28)
|
.frame(width: 28)
|
||||||
.help("Drawing color")
|
.help("Drawing color")
|
||||||
|
}
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
@@ -515,6 +545,17 @@ struct ScreenshotPane: View {
|
|||||||
Canvas { context, _ in
|
Canvas { context, _ in
|
||||||
for stroke in model.strokes {
|
for stroke in model.strokes {
|
||||||
guard stroke.points.count > 1 else { continue }
|
guard stroke.points.count > 1 else { continue }
|
||||||
|
if stroke.isRedaction {
|
||||||
|
let xs = stroke.points.map { $0.x }
|
||||||
|
let ys = stroke.points.map { $0.y }
|
||||||
|
let bar = CGRect(
|
||||||
|
x: origin.x + (xs.min()! - 2) * scale,
|
||||||
|
y: origin.y + (ys.min()! - 2) * scale,
|
||||||
|
width: ((xs.max()! - xs.min()!) + 4) * scale,
|
||||||
|
height: (max(stroke.width, ys.max()! - ys.min()!) + 4) * scale
|
||||||
|
)
|
||||||
|
context.fill(Path(bar), with: .color(.black))
|
||||||
|
} else {
|
||||||
var path = Path()
|
var path = Path()
|
||||||
path.move(to: CGPoint(x: origin.x + stroke.points[0].x * scale, y: origin.y + stroke.points[0].y * scale))
|
path.move(to: CGPoint(x: origin.x + stroke.points[0].x * scale, y: origin.y + stroke.points[0].y * scale))
|
||||||
for point in stroke.points.dropFirst() {
|
for point in stroke.points.dropFirst() {
|
||||||
@@ -523,6 +564,7 @@ struct ScreenshotPane: View {
|
|||||||
context.stroke(path, with: .color(Color(nsColor: stroke.color)), lineWidth: stroke.width)
|
context.stroke(path, with: .color(Color(nsColor: stroke.color)), lineWidth: stroke.width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.allowsHitTesting(false)
|
.allowsHitTesting(false)
|
||||||
|
|
||||||
// In-progress stroke
|
// In-progress stroke
|
||||||
|
|||||||
+2
-2
@@ -108,9 +108,9 @@ cat > "$APP/Contents/Info.plist" <<'PLIST'
|
|||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>Icon</string>
|
<string>Icon</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.5.0</string>
|
<string>1.5.1</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>50</string>
|
<string>51</string>
|
||||||
<key>LSUIElement</key>
|
<key>LSUIElement</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user