 		indent:     ""
 
 		constructor: ( options ) ->
+			width = +options.width
+			height = +options.height
+
+			if width and height
+				@scaleX = width/doc.width
+				@scaleY = height/doc.height
+			else if width and not height
+				@scaleY = @scaleX = width/doc.width
+			else if height and not width
+				@scaleX = @scaleY = height/doc.height
+			else
+				@scaleY = @scaleX = 1
 
 			switch options.type
 				when 'SVG'

		initClosureSwift: ->
			@result.push """
				{ #{@context}, #{@bounds} in
				\tlet verticalRatio: CGFloat = #{@bounds}.size.height/#{doc.height}
				\tlet horizontalRatio: CGFloat = #{@bounds}.size.width/#{doc.width}
				\tlet scale: CGFloat = verticalRatio < horizontalRatio ? verticalRatio : horizontalRatio
				\tCGContextTranslateCTM(#{@context}, (#{@bounds}.size.width-#{doc.width}*scale)*0.5, (#{@bounds}.size.height-#{doc.height}*scale)*0.5)
				\tCGContextScaleCTM(#{@context}, scale, scale)
			"""

		initClosureObjC: ->
			@result.push """
				^(CGContextRef #{@context}, CGRect #{@bounds}) {
				\tconst CGFloat verticalRatio   = #{@bounds}.size.height/#{doc.height};
				\tconst CGFloat horizontalRatio = #{@bounds}.size.width/#{doc.width};
				\tconst CGFloat scale = verticalRatio < horizontalRatio ? verticalRatio : horizontalRatio;
				\tCGContextTranslateCTM(#{@context}, (#{@bounds}.size.width-#{doc.width}*scale)*0.5, (#{@bounds}.size.height-#{doc.height}*scale)*0.5);
				\tCGContextScaleCTM(#{@context}, scale, scale);
			"""



	# for CoreGraphics on iOS, the origin is the top-left corner.
	IOS_fixCoords = ( coordArr ) ->
		coordArr[0] = round2 (coordArr[0] + org[0])*@scaleX
		coordArr[1] = round2 (doc.height - (org[1] + coordArr[1]))*@scaleY
		coordArr.join " "

	# for CoreGraphics on mac, the origin is the bottom-left corner.
	Mac_fixCoords = ( coordArr ) ->
		coordArr[0] = round2 (coordArr[0] + org[0])*@scaleX
		coordArr[1] = round2 (coordArr[1] + org[1])*@scaleY
		coordArr.join ", "

	SVG_fixCoords = ( coordArr ) ->
		coordArr[0] = round2 (coordArr[0] + org[0])*@scaleX
		coordArr[1] = round2 (doc.height - (org[1] + coordArr[1]))*@scaleY
		coordArr.join ","

	checkLinear = ( currPoint, prevPoint ) ->
