 import AppKit
 
 public class JSSwitch: NSControl {
-	public override var wantsUpdateLayer: Bool {
-		return true
-	}
-	public override var intrinsicContentSize: NSSize {
-		return CGSize(width: 52, height: 32)
-	}
-
+	// MARK: - Properties
 	private var pressed = false
-	private let baseHeight: CGFloat = 62
 	private let backgroundLayer = CALayer()
 	private let knobContainer = CALayer()
 	private let knobLayer = CALayer()
 	private let knobShadows = (smallStroke: CALayer(), smallShadow: CALayer(), mediumShadow: CALayer(), bigShadow: CALayer())
 
-	public var tintColor = NSColor(deviceRed: 104/255, green: 218/255, blue: 113/255, alpha: 1.0) {
+	// MARK: Computed
+	public override var wantsUpdateLayer: Bool { return true }
+	public override var intrinsicContentSize: NSSize {
+		return CGSize(width: 52, height: 32)
+	}
+
+	private var scaleFactor: CGFloat {
+		return ceil(frame.size.height / 62) // Hardcoded base height
+	}
+
+	public var tintColor = NSColor(deviceRed: 76/255, green: 217/255, blue: 100/255, alpha: 1.0) {
 		didSet { needsDisplay = true }
 	}
 	public var on = false {

	}

	// MARK: - Helpers
	private func knobFrameForState(on on: Bool, pressed: Bool) -> CGRect {
		let borderWidth = 3.0 * ceil(backgroundLayer.bounds.height / baseHeight)
		var origin: CGPoint
		var size: CGSize {
			if pressed {
				return CGSize(
					width: ceil(backgroundLayer.bounds.width * 0.69) - (2 * borderWidth),
					height: backgroundLayer.bounds.height - (2 * borderWidth)
				)
			}
			return CGSize(width: backgroundLayer.bounds.height - (2 * borderWidth), height: backgroundLayer.bounds.height - (2 * borderWidth))
		}

		if on {
			origin = CGPoint(x: backgroundLayer.bounds.width - size.width - borderWidth, y: borderWidth)
		} else {
			origin = CGPoint(x: borderWidth, y: borderWidth)
		}

	private func setupLayers() {
		wantsLayer = true
		layer?.masksToBounds = false
		layerContentsRedrawPolicy = .onSetNeedsDisplay

		// Background
		setupBackgroundLayer()
