Веб блог и не только | Знания недостаточно, необходимо применение

Июн/11

4

Растеризация мувиков с помощью as3

Выкладываю функцию которая помогает при растеризации векторной графики. Особенность в том что учитиваются смещения и скейл.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Help Rasterizing
static private function getBitmap(originClip:DisplayObject):BitmapData
{
	if (originClip.width > 0 && originClip.height > 0) {
		var m:Matrix = new Matrix();
		var r:Rectangle = originClip.getRect(originClip);
		r = normlizeRect(r);
		m.translate(-r.x, -r.y);
		m.scale(originClip.scaleX, originClip.scaleY);
		var tmpBD:BitmapData = new BitmapData(r.width, r.height, true, 0x000000);
		tmpBD.draw(originClip, m, null, null, null, true);
		return tmpBD;
	} else return null;
}
// 
static private function normlizeRect(rLoc:Rectangle):Rectangle {
	rLoc.x = Math.ceil(rLoc.x); rLoc.y = Math.ceil(rLoc.y);
	rLoc.width = Math.ceil(rLoc.width); rLoc.height = Math.ceil(rLoc.height);
	return rLoc;
}

RSS Feed

Комментариев нет.

Оставте комментарий!

<< Хороший пример Verlet integration

Изометрия в as3 – рендер с помощью copypixels >>

Поиск

Theme Design by devolux.org