 
 	# for CoreGraphics on iOS, the origin is the top-left corner.
 	IOS_fixCoords = ( coordArr ) ->
-		coordArr[0] = round2 coordArr[0] + org[0]
-		coordArr[1] = round2 doc.height - (org[1] + coordArr[1])
+		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]
-		coordArr[1] = round2 coordArr[1] + org[1]
+		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]
-		coordArr[1] = round2 doc.height - (org[1] + coordArr[1])
+		coordArr[0] = round2 (coordArr[0] + org[0])*@scaleX
+		coordArr[1] = round2 (doc.height - (org[1] + coordArr[1]))*@scaleY
 		coordArr.join ","
 
 	checkLinear = ( currPoint, prevPoint ) ->

		indent:     ""

		constructor: ( options ) ->

			switch options.type
				when 'SVG'

# note: \" in double quoted strings (i.e. escaped double quotes) cause
# script execution to fail completely, probably due to them not being
# escaped properly when stringifying the main function.
CGDraw = ( options ) ->
	app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS
	pWin = new Window "palette"
