0

「drawPath」を使用してスプライトを描画します。

次に、次を使用してこのスプライトにフィルターを適用します。

var myBlur:BlurFilter = new BlurFilter();
myBlur.blurX = 10;
myBlur.blurY = 10;
_alphaMask.filters = [myBlur];

次に、スプ​​ライトの一部を「切り取って」別のスプライトのマスクとして使用する必要があります。

問題は、スプライトを切り取るときに、切り取った「エッジ」がぼやけないようにする必要があることです。

ただし、「cut」スプライトには「BlurFilter」が適用されているため、エッジがぼやけています。

写真の問題は次のとおりです。

写真の問題 http://s11.postimage.org/820by8y29/Prblm_Mask2.png

私は2つの問題があるそれを解決する方法を考えました:

フィルタを適用したスプライトから BitmapData を新しいスプライトに描画し、新しいスプライトで「scrollRect」を使用します。

このアプローチには 2 つの問題があります。

  1. パフォーマンス ヒット
  2. それを機能させることはできません...

ビットマップデータをコピーせずにこのニーズを解決する方法を教えてもらえますか??

アップデート

私が使用するコードスニペットは次のとおりです。

private var _alphaMask:Sprite;

private createMask():void
{
    _alphaMask = new Sprite();
    _alphaMask.visible = true;

    // Clear the mask
    _alphaMask.graphics.clear();

    // Create the mask vertices (the 'drawPath' coordinates)
    var maskPoints:Vector.<Number> = new Vector.<Number>(5);
    maskPoints.push(100);   maskPoints.push(100);
    maskPoints.push(200);   maskPoints.push(200);
    maskPoints.push(230);   maskPoints.push(310);
    maskPoints.push(140);   maskPoints.push(170);
    maskPoints.push(130);   maskPoints.push(190);

    // Create the 'drawPath' commands
    var commands:Vector.<int> = new Vector.<int>(commandLen);
    commands.push(1);
    commands.push(2);
    commands.push(2);
    commands.push(2);
    commands.push(2);

    // Draw the vertices on the mask
    _alphaMask.graphics.beginFill(0x0000FF);
    _alphaMask.graphics.drawPath(commands, clonedMaskPoints);
    _alphaMask.graphics.endFill();

        // Add the Blur filter to the mask
    var myBlur:BlurFilter   = new BlurFilter();
    myBlur.blurX            = myBlur.blurY = 10;
    _alphaMask.filters      = [myBlur];



    // Now I need to 'Cut Out' a section of the mask (and use it for something else...)
    // This section cuts out the part of the mask I need, but it 'reapplies' the blur filter on the entire cut mask
    var scrollRect_x:Number         = 100;
    var scrollRect_y:Number         = 100;
    var scrollRect_width:Number     = 300;
    var scrollRect_height:Number    = 200
    _alphaMask.scrollRect = new Rectangle(scrollRect_x, scrollRect_y, scrollRect_width, scrollRect_height);
}

そして、これは私が問題を回避しようとしたものです(成功せずに):

var alphaBitmapData:BitmapData = new BitmapData(_alphaMask.width, _alphaMask.height);
alphaBitmapData.draw(_alphaMask);
_alphaMask.graphics.clear();
_alphaMask.graphics.beginBitmapFill(alphaBitmapData);
_alphaMask.graphics.endFill();
4

0 に答える 0