base stuff done

This commit is contained in:
Nihaal Sharma committed 2026-10-14 08:58:26 +01:00
1 parent 42173d056c
commit 93a02f9a48
9 files changed
+147 -22

No files matched your search

+4 -3
View File
@@ -11,9 +11,10 @@ import Cocoa
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
let window = NSWindow(contentRect: NSScreen.main!.frame, styleMask: .borderless, backing: .buffered, defer: false)
window.backgroundColor = .init(srgbRed: 1, green: 1, blue: 1, alpha: 0.1)
window.orderFront(nil)
// let window = NSWindow(contentRect: NSScreen.main!.frame, styleMask: .borderless, backing: .buffered, defer: false)
// window.backgroundColor = .init(srgbRed: 1, green: 1, blue: 1, alpha: 0.1)
// window.orderFront(nil)
let x = GooseWindow()
}
func applicationWillTerminate(_ aNotification: Notification) {
+21
View File
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "body.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

+58
View File
@@ -0,0 +1,58 @@
//
// Goose.swift
// DesktopDuck
//
// Created by neon443 on 06/10/2026.
//
import Foundation
import Cocoa
class Goose: NSViewController {
var state: GooseState
var gooseView: NSView
init() {
self.state = .idle
self.gooseView = NSView(frame: .zero)
super.init(nibName: nil, bundle: nil)
self.view.frame = NSScreen.main!.frame
setup()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setup() {
gooseView.frame = NSRect(x: 100, y: 100, width: 25, height: 25)
self.view.addSubview(gooseView)
let bodyView = NSImageView(image: NSImage(named: "body")!)
gooseView.addSubview(bodyView)
bodyView.translatesAutoresizingMaskIntoConstraints = false
bodyView.rotate(byDegrees: 50)
NSLayoutConstraint.activate([
bodyView.widthAnchor.constraint(equalToConstant: 50),
bodyView.heightAnchor.constraint(equalToConstant: 50)
])
let neckView = NSImageView(image: NSImage(named: "body")!)
gooseView.addSubview(neckView)
neckView.translatesAutoresizingMaskIntoConstraints = false
neckView.rotate(byDegrees: 90)
NSLayoutConstraint.activate([
neckView.widthAnchor.constraint(equalToConstant: 25),
neckView.heightAnchor.constraint(equalToConstant: 25)
])
}
}
enum GooseState {
case idle
case wander
case draggingMessage
case draggingMouse
case running
case aggro
}
+8
View File
@@ -0,0 +1,8 @@
//
// GooseView.swift
// DesktopDuck
//
// Created by neon443 on 06/10/2026.
//
import Foundation
+6 -7
View File
@@ -10,13 +10,14 @@ import Cocoa
class GooseWindow {
private var window: NSWindow
private var duck: NSImageView
private var goose: Goose
private var angle: CGFloat = 90
var shown: Bool = false
private var x = 1
private var time: Timer?
init() {
goose = Goose()
self.window = NSWindow(
contentRect: CGRect(x: 0, y: 0, width: NSScreen.main!.frame.width, height: NSScreen.main!.frame.width),
styleMask: .borderless,
@@ -28,14 +29,12 @@ class GooseWindow {
window.level = NSWindow.Level.screenSaver + 1
window.ignoresMouseEvents = true
window.hasShadow = false
window.collectionBehavior = NSWindow.CollectionBehavior.canJoinAllApplications.union(.stationary)
duck = .init(image: NSImage(named: "pond")!)
window.contentView?.addSubview(duck)
duck.frame.origin.x = NSScreen.main!.frame.width/2
duck.frame.origin.y = NSScreen.main!.frame.height/2
window.collectionBehavior = NSWindow.CollectionBehavior.canJoinAllApplications.union(.stationary).union(.canJoinAllSpaces)
showHide()
// window.contentView?.addSubview(NSTextField(labelWithString: "hi"))
window.contentView?.addSubview(goose.view)
}
func showHide() {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.