Sfoglia il codice sorgente

fixed drawTo + filters

ncannasse 10 anni fa
parent
commit
05c25f29f1
4 ha cambiato i file con 8 aggiunte e 7 eliminazioni
  1. 3 3
      h2d/CachedBitmap.hx
  2. 1 1
      h2d/Console.hx
  3. 1 1
      h2d/Sprite.hx
  4. 3 2
      samples/draw/Draw.hx

+ 3 - 3
h2d/CachedBitmap.hx

@@ -39,9 +39,9 @@ class CachedBitmap extends Drawable {
 		return h;
 	}
 
-	public function getTile() {
+	public function getTile( ?ctx : RenderContext ) {
 		if( tile == null ) {
-			var scene = getScene();
+			var scene = ctx == null ? getScene() : ctx.scene;
 			if( scene == null ) return null;
 			var tw = width < 0 ? scene.width : width;
 			var th = height < 0 ? scene.height : height;
@@ -67,7 +67,7 @@ class CachedBitmap extends Drawable {
 		var scene = ctx.scene;
 		if( tile != null && ((width < 0 && scene.width != tile.width) || (height < 0 && scene.height != tile.height)) )
 			clean();
-		var tile = getTile();
+		var tile = getTile(ctx);
 		if( !freezed || !renderDone ) {
 			var oldA = matA, oldB = matB, oldC = matC, oldD = matD, oldX = absX, oldY = absY;
 

+ 1 - 1
h2d/Console.hx

@@ -297,7 +297,7 @@ class Console extends h2d.Sprite {
 	}
 
 	override function sync(ctx:h2d.RenderContext) {
-		var scene = getScene();
+		var scene = ctx.scene;
 		if( scene != null ) {
 			x = 0;
 			y = scene.height - height;

+ 1 - 1
h2d/Sprite.hx

@@ -426,7 +426,7 @@ class Sprite {
 		add(bounds.xMax, bounds.yMax);
 
 		// clip with our scene
-		var scene = getScene();
+		var scene = ctx.scene;
 		if( view.xMin < 0 ) view.xMin = 0;
 		if( view.yMin < 0 ) view.yMin = 0;
 		if( view.xMax > scene.width ) view.xMax = scene.width;

+ 3 - 2
samples/draw/Draw.hx

@@ -25,7 +25,7 @@ class Draw extends hxd.App {
 		g.lineStyle();
 
 		g.beginTileFill(-32,-32,tile);
-		g.drawPie(0, 0, 32, Math.PI / 3, Math.PI);
+		//g.drawPie(0, 0, 32, Math.PI / 3, Math.PI);
 		g.endFill();
 
 		g.beginTileFill(100, -64, 2, 2, tile);
@@ -78,9 +78,10 @@ class Draw extends hxd.App {
 
 	function redraw(t:h3d.mat.Texture) {
 		var g = new h2d.Graphics();
-		g.beginFill(0xFF8040, 0.1);
+		g.beginFill(0xFF8040, 0.5);
 		for( i in 0...10 )
 			g.drawCircle(Math.random() * 256, Math.random() * 256, (0.1 + Math.random()) * 10);
+		g.filters = [new h2d.filter.Blur(2,2,10)];
 		g.drawTo(t);
 
 		var pix = t.capturePixels();