This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// window-demo | |
// | |
// Created by Asia Fu on 2024/10/20. | |
// | |
import SwiftUI | |
struct WindowAccessor: NSViewRepresentable { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NSView { | |
override func mouseDown(with event: NSEvent) { | |
guard event.clickCount <= 2 else { return } | |
let location = view.convert(event.locationInWindow, from: nil) | |
let eventMask: NSEvent.EventTypeMask = [.leftMouseUp, .leftMouseDragged] | |
let timeout = NSEvent.foreverDuration | |
var dragInitiated = false | |
view.window?.trackEvents(matching: eventMask, timeout: timeout, mode: .eventTracking, handler: { (event, stop) in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct SearchView: NSViewRepresentable { | |
typealias NSViewType = NSSearchField | |
func makeNSView(context: Context) -> NSSearchField { | |
return NSSearchField() | |
} | |
func updateNSView(_ nsView: NSSearchField, context: Context) { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
size(800, 800); | |
background(255); | |
noFill(); | |
translate(width * 0.5, height * 0.5); // center of the curve. | |
hilbert_curve(6, width); | |
} | |
void hilbert_curve(int n, float size) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- full page template --> | |
<!-- created for single-page personal website --> | |
<html> | |
<head> | |
<meta charset='utf8'> | |
<style> | |
body { |