[improve] PartView shadow
This commit is contained in:
@@ -72,8 +72,9 @@ class GameUtil {
|
||||
height = normilizeSize(height);
|
||||
var offsetX = 500;
|
||||
var offsetY = 200;
|
||||
var imageSize = 1024;
|
||||
var s = width / height;
|
||||
var imageRect = new Rectangle(offsetX, offsetY, 1024, 1024 / s);
|
||||
var imageRect = new Rectangle(offsetX, offsetY, imageSize, imageSize / s);
|
||||
var tableRect = new Rectangle(0, 0, imageRect.width + offsetX * 2, imageRect.height + offsetY * 2);
|
||||
return {
|
||||
image:image,
|
||||
|
||||
@@ -31,7 +31,9 @@ class PartView extends Sprite {
|
||||
|
||||
public function new(id:Int, image:BitmapData, size:Point) {
|
||||
super();
|
||||
#if !android
|
||||
filters = RenderUtil.buildFilters();
|
||||
#end
|
||||
this.id = id;
|
||||
this.size = size;
|
||||
if (image != null) {
|
||||
@@ -51,7 +53,7 @@ class PartView extends Sprite {
|
||||
}
|
||||
|
||||
public static function factory(id:Int, image:BitmapData, size:Point):PartView {
|
||||
return new BitmapPartView(id, image, size);
|
||||
return new SpritePartView(id, image, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package ru.m.puzzlez.render;
|
||||
|
||||
import flash.geom.Point;
|
||||
import ru.m.puzzlez.render.mask.IPartMaskBuilder.DrawPath;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.Shape;
|
||||
import flash.filters.BitmapFilter;
|
||||
@@ -39,13 +41,16 @@ class RenderUtil {
|
||||
var canvas:Shape = new Shape();
|
||||
canvas.cacheAsBitmap = true;
|
||||
canvas.mask = mask;
|
||||
canvas.graphics.beginBitmapFill(source, null, false, true);
|
||||
canvas.graphics.drawRect(0, 0, source.width, source.height);
|
||||
canvas.graphics.endFill();
|
||||
var image = new BitmapData(Std.int(mask.rect.width), Std.int(mask.rect.height), true, 0x00000000);
|
||||
var matrix = new Matrix();
|
||||
matrix.translate(-mask.rect.x, -mask.rect.y);
|
||||
image.draw(canvas, matrix, null, null, null, true);
|
||||
canvas.graphics.beginBitmapFill(source, matrix, false, true);
|
||||
canvas.graphics.drawRect(0, 0, mask.rect.width, mask.rect.height);
|
||||
canvas.graphics.endFill();
|
||||
var image = new BitmapData(Std.int(mask.rect.width), Std.int(mask.rect.height), true, 0x00000000);
|
||||
image.draw(canvas, null, null, null, null, true);
|
||||
/*for (filter in buildFilters()) {
|
||||
image.applyFilter(image, image.rect, image.rect.topLeft, filter);
|
||||
}*/
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,22 +3,28 @@ package ru.m.puzzlez.render.mask;
|
||||
import flash.display.Shape;
|
||||
import flash.geom.Rectangle;
|
||||
import ru.m.puzzlez.core.Part;
|
||||
import ru.m.puzzlez.render.mask.IPartMaskBuilder;
|
||||
|
||||
class PartMask extends Shape {
|
||||
|
||||
public var rect(default, null):Rectangle;
|
||||
|
||||
private static var builder:IPartMaskBuilder = new ClassicMaskBuilder();
|
||||
|
||||
public function new(rect:Rectangle, bounds:Bounds) {
|
||||
super();
|
||||
graphics.beginFill(0xff00ff, 1);
|
||||
var path = new ClassicMaskBuilder().build(rect, bounds);
|
||||
graphics.drawPath(path.commands, path.data);
|
||||
graphics.endFill();
|
||||
this.rect = rect.clone();
|
||||
var offset = rect.width / 4 + rect.width * 0.05;
|
||||
this.rect.x -= offset;
|
||||
this.rect.y -= offset;
|
||||
this.rect.width += offset * 2;
|
||||
this.rect.height += offset * 2;
|
||||
var drawRect = rect.clone();
|
||||
drawRect.x = offset;
|
||||
drawRect.y = offset;
|
||||
var drawPath = builder.build(drawRect, bounds);
|
||||
graphics.beginFill(0xff00ff, 1);
|
||||
graphics.drawPath(drawPath.commands, drawPath.data);
|
||||
graphics.endFill();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user