Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (29 sloc) 1.02 KB
//
// DemoView.swift
// SwiftRebound
//
// Created by Andrew Hunter on 15/07/2016.
//
//
import Foundation
import SwiftRebound
///
/// Click/drag to draw a circle. A green box will follow the mouse when the button is not down.
///
class DemoView : ReactiveView {
override func drawReactive() {
if leftMouseDown.value {
// Draw an oval centered on the current position
let clickPos = mousePosition.value;
let ovalRect = NSInsetRect(NSRect(origin: clickPos, size: NSSize(width: 0, height: 0)), -64, -64);
NSColor.blueColor().set();
NSBezierPath.init(ovalInRect: ovalRect).fill();
} else if mouseOver.value {
// Draw an square centered on the current position
let clickPos = mousePosition.value;
let square = NSInsetRect(NSRect(origin: clickPos, size: NSSize(width: 0, height: 0)), -16, -16);
NSColor.greenColor().set();
NSRectFill(square);
}
}
}