 		currentSelectionX = touchPoint.x
 		currentSelectionY = touchPoint.y
 		
+		let offset = (direction == .Horizontal ? self.frame.size.height : self.frame.size.width)
+		let halfOffset = offset * 0.5
+		if currentSelectionX < halfOffset {
+			currentSelectionX = halfOffset
+		}
+		else if currentSelectionX >= self.frame.size.width - halfOffset {
+			currentSelectionX = self.frame.size.width - halfOffset
+		}
+		if currentSelectionY < halfOffset {
+			currentSelectionY = halfOffset
+		}
+		else if currentSelectionY >= self.frame.size.height - halfOffset {
+			currentSelectionY = self.frame.size.height - halfOffset
+		}
+		
+		let percent = (direction == .Horizontal ? CGFloat((currentSelectionX - halfOffset) / (self.frame.size.width - offset))
+			: CGFloat((currentSelectionY - halfOffset) / (self.frame.size.height - offset)))
+		value = Int(percent * 20)
+		
 		if delegate != nil {
 			// to do
-			delegate.valueChanged(0)
+			delegate.valueChanged(value)
 		}
 		setNeedsDisplay()
 	}

	// Updating
	
	func update() {
		image = generateHUEImage(self.frame.size)
	}
	

	
	var delegate: SwiftThicknessPickerDelegate!
	var direction: PickerDirection = .Horizontal
	var value: Int = 0
	
	// Additional public properties
	
