 		set(newval) { mLineWidth = newval }
 	}
 
-	public func setLineWidth(width wid: CGFloat) {
-		mLineWidth = wid
+	public func addDown(point pt: CGPoint, in area: CGSize) {
+		switch mCurrentType {
+		case .path:
+			let newpath = CNVectorPath(lineWidth: mLineWidth)
+			newpath.add(point: convert(point: pt, in: area))
+			mGraphics.append(.path(newpath))
+		case .rect:
+			let newrect = CNVectorRect(lineWidth: mLineWidth)
+			newrect.originPoint = convert(point: pt, in: area)
+			newrect.endPoint    = newrect.originPoint
+			mGraphics.append(.rect(newrect))
+		}
 	}
 
-	private func addPoint(point pt: CGPoint, in area: CGSize){
+	public func addDrag(point pt: CGPoint, in area: CGSize){
+		switch mCurrentType {
+		case .path:
+			addPath(point: pt, in: area)
+		case .rect:
+			addRect(point: pt, in: area)
+		}
+	}
+
+	public func addUp(point pt: CGPoint, in area: CGSize){
+		switch mCurrentType {
+		case .path:
+			addPath(point: pt, in: area)
+		case .rect:
+			addRect(point: pt, in: area)
+		}
+	}
+
+	private func addPath(point pt: CGPoint, in area: CGSize){
 		if let gr = mGraphics.last {
 			switch gr {
 			case .path(let path):
 				path.add(point: convert(point: pt, in: area))
+			case .rect(_):
+				CNLog(logLevel: .error, message: "Unexpected object", atFunction: #function, inFile: #file)
+			}
+		} else {
+			CNLog(logLevel: .error, message: "Can not happen", atFunction: #function, inFile: #file)
+		}
+	}
+
+	private func addRect(point pt: CGPoint, in area: CGSize){
+		if let gr = mGraphics.last {
+			switch gr {
+			case .path(_):
+				CNLog(logLevel: .error, message: "Unexpected object", atFunction: #function, inFile: #file)
+			case .rect(let rect):
+				rect.endPoint = convert(point: pt, in: area)
 			}
 		} else {
 			CNLog(logLevel: .error, message: "Can not happen", atFunction: #function, inFile: #file)

		mPoints.append(pt)
	}

	public func points(inRect rect: CGRect) -> Array<CGPoint> {
		let origin = rect.origin
		let size   = rect.size
		var result: Array<CGPoint> = []
		for pt in mPoints {
			let x = origin.x + (size.width  * pt.x)
			let y = origin.y + (size.height * pt.y)
			let p = CGPoint(x: x, y: y)
			result.append(p)
		}
		return result
	}
}

public enum CNVectorGraphics
{
	case path(CNVectorPath)
}

public class CNVecroGraphicsGenerator
{
	private var mGraphics:	Array<CNVectorGraphics>
	private var mLineWidth:	CGFloat
	public init(){
		mGraphics	= []
		mLineWidth	= 1.0
	}

	public var contents: Array<CNVectorGraphics> { get { return mGraphics }}

	public func addDown(point pt: CGPoint, in area: CGSize) {
		let newpath = CNVectorPath(lineWidth: mLineWidth)
		newpath.add(point: convert(point: pt, in: area))
		mGraphics.append(.path(newpath))
	}

	public func addDrag(point pt: CGPoint, in area: CGSize){
		addPoint(point: pt, in: area)
	}

	public func addUp(point pt: CGPoint, in area: CGSize){
		addPoint(point: pt, in: area)
	}

	public var lineWidth: CGFloat {

import UIKit
#endif
import Foundation

private func normalizePoint(source src: CGPoint, in rect: CGRect) -> CGPoint {
	let origin = rect.origin
	let size   = rect.size
	let x = origin.x + (size.width  * src.x)
	let y = origin.y + (size.height * src.y)
	return CGPoint(x: x, y: y)
}

public class CNVectorPath
{
