Permalink
Browse files

Improved number formatting

  • Loading branch information...
1 parent 96ea082 commit 576e0e577e71bf6833ebcaff7ec574bfb75bb572 @claus committed Jun 8, 2012
Showing with 16 additions and 4 deletions.
  1. +16 −4 src/com/codeazur/as3swf/exporters/AS3ShapeExporter.as
@@ -1,6 +1,8 @@
package com.codeazur.as3swf.exporters
{
import com.codeazur.as3swf.SWF;
+ import com.codeazur.as3swf.exporters.core.DefaultShapeExporter;
+ import com.codeazur.as3swf.utils.NumberUtils;
import com.codeazur.utils.StringUtils;
import flash.display.CapsStyle;
@@ -9,7 +11,6 @@
import flash.display.LineScaleMode;
import flash.display.SpreadMethod;
import flash.geom.Matrix;
- import com.codeazur.as3swf.exporters.core.DefaultShapeExporter;
public class AS3ShapeExporter extends DefaultShapeExporter
{
@@ -162,15 +163,26 @@
}
override public function moveTo(x:Number, y:Number):void {
- _actionScript += StringUtils.printf("graphics.moveTo(%f, %f);\r", x, y);
+ _actionScript += StringUtils.printf("graphics.moveTo(%s, %s);\r",
+ NumberUtils.roundPixels400(x),
+ NumberUtils.roundPixels400(y)
+ );
}
override public function lineTo(x:Number, y:Number):void {
- _actionScript += StringUtils.printf("graphics.lineTo(%f, %f);\r", x, y);
+ _actionScript += StringUtils.printf("graphics.lineTo(%s, %s);\r",
+ NumberUtils.roundPixels400(x),
+ NumberUtils.roundPixels400(y)
+ );
}
override public function curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number):void {
- _actionScript += StringUtils.printf("graphics.curveTo(%f, %f, %f, %f);\r", controlX, controlY, anchorX, anchorY);
+ _actionScript += StringUtils.printf("graphics.curveTo(%s, %s, %s, %s);\r",
+ NumberUtils.roundPixels400(controlX),
+ NumberUtils.roundPixels400(controlY),
+ NumberUtils.roundPixels400(anchorX),
+ NumberUtils.roundPixels400(anchorY)
+ );
}
}
}

0 comments on commit 576e0e5

Please sign in to comment.