Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: ac7a5accbf
...
compare: 8ca165923e
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
2  etc/haxelib.xml
@@ -1,7 +1,7 @@
<project name="transition9" url="https://github.com/dionjwa/transition9" license="BSD">
<user name="dionjwa"/>
<description>A collection of tools.</description>
- <version name="0.8">Minor update.</version>
+ <version name="0.8.2">Minor update.</version>
<depends name="polygonal" />
<tag v="nodejs"/>
<tag v="asynchronous"/>
View
36 src/org/transition9/util/BitmapUtil.hx
@@ -1,8 +1,5 @@
package org.transition9.util;
-import com.pblabs.components.scene2D.ImageType;
-import com.pblabs.components.scene2D.ImageData;
-
import de.polygonal.core.math.Mathematics;
import de.polygonal.motor.geom.primitive.AABB2;
@@ -21,7 +18,8 @@ class BitmapUtil
}
#if (flash || cpp ||spaceport)
- public static function createBitmapData (d :flash.display.DisplayObject, ?scale :Float = 1.0, ?center :flash.geom.Point) :flash.display.BitmapData
+ public static function createBitmapData (d :flash.display.DisplayObject, ?scale :Float = 1.0,
+ ?center :flash.geom.Point, ?drawnBounds :flash.geom.Rectangle, ?colorBounds :Bool = false, ?mask :UInt = 0xFF000000, ?color :UInt = 0x00000000, ?findColor :Bool = false) :flash.display.BitmapData
{
#if (flash || spaceport)
var bounds = d.getBounds(d);
@@ -33,6 +31,13 @@ class BitmapUtil
return null;
}
+ if (drawnBounds != null) {
+ drawnBounds.x = Math.floor(bounds.x);
+ drawnBounds.y = Math.floor(bounds.y);
+ drawnBounds.width = Mathematics.ceil(bounds.width * scale);
+ drawnBounds.height = Mathematics.ceil(bounds.height * scale);
+ }
+
if (center == null) {
center = new flash.geom.Point();
}
@@ -40,13 +45,32 @@ class BitmapUtil
center.y = Mathematics.ceil(-bounds.y * scale);
#if flash
- var bd = new flash.display.BitmapData(Mathematics.ceil(bounds.width * scale), Mathematics.ceil(bounds.height * scale), true, ColorUtil.toARGB(0xffffff, 0));
- #else
var bd = new flash.display.BitmapData(Mathematics.ceil(bounds.width * scale), Mathematics.ceil(bounds.height * scale), true, 0xffffff);
+ #else
+ var bd = new flash.display.BitmapData(Mathematics.ceil(bounds.width * scale), Mathematics.ceil(bounds.height * scale), true, 0xffffff));
#end
bd.draw(d, new flash.geom.Matrix(scale, 0, 0, scale, center.x, center.y), null, null, null, false);
+ if (colorBounds) {
+ bounds = bd.getColorBoundsRect(mask, color, findColor);
+ trace("bounds=" +bounds);
+ bounds.x = Math.floor(bounds.x);
+ bounds.y = Math.floor(bounds.y);
+ bounds.width = Math.ceil(bounds.width);
+ bounds.height = Math.ceil(bounds.height);
+ var drawnbd = new flash.display.BitmapData(Mathematics.ceil(bounds.width), Mathematics.ceil(bounds.height), true, ColorUtil.toARGB(0xffffff, 0));
+ drawnbd.copyPixels(bd, bounds, new flash.geom.Point(0, 0));
+ bd = drawnbd;
+
+ if (drawnBounds != null) {
+ drawnBounds.x += bounds.x;
+ drawnBounds.y += bounds.y;
+ drawnBounds.width = bounds.width;
+ drawnBounds.height = bounds.height;
+ }
+ }
+
#if (graphics_debug && !spaceport)
var shape = new flash.display.Shape();
var g = shape.graphics;
View
16 src/org/transition9/util/ImageData.hx
@@ -0,0 +1,16 @@
+package org.transition9.util;
+
+#if (flash || cpp || neko || jeash)
+ typedef ImageData = flash.display.BitmapData;
+#elseif js
+ typedef ImageData = Canvas;
+ // /** Defined in HTML5 */
+ // typedef ImageData = {
+ // /** The width of the image in pixels; this is a read only unsigned long. */
+ // var width : Float;
+ // /** The height of the image in pixels; this is a read only unsigned long. */
+ // var height : Float;
+ // /** A CanvasPixelArray object containing the image data. */
+ // var data : CanvasPixelArray;
+ // }
+#end
View
8 src/org/transition9/util/ImageType.hx
@@ -0,0 +1,8 @@
+package org.transition9.util;
+
+
+#if (flash || cpp || neko || jeash)
+ typedef ImageType = flash.display.Bitmap;
+#elseif js
+ typedef ImageType = Image;
+#end

No commit comments for this range

Something went wrong with that request. Please try again.