2016-01-15 119 views
1

畫我實現了一個小客廳的功能到應用中與CreateJS像這樣:CreateJs阿爾法

var currentPosition = this.posOnStage(event); 

    var drawing = container.getChildByName('drawing'); 
    drawing.graphics.ss(this.brushSize, "round").s(this.brushColor); 
    drawing.graphics.mt(this._lastMousePosition.x, this._lastMousePosition.y); 
    drawing.graphics.lt(currentPosition.x, currentPosition.y); 
    drawing.alpha = this.brushAlpha; 
    container.updateCache(this.enableErasing ? "destination-out" : "source-over"); 
    drawing.graphics.clear(); 

    this._lastMousePosition = this.posOnStage(event); 

正如你所看到的,此圖的Alpha值可以改變。可悲的是,你可以畫出一個你曾經畫過的點,所以當你多次畫一個點時,阿爾法效果就會消失。任何想法如何解決這個問題?

謝謝:)

編輯: enter image description here

我試着像gskinner和蘭尼7提議,但沒有奏效。我附上了一張圖片,以便您看到問題所在。

+0

您繪製在100%的一切,只是改變了整體的不透明度。如果您改變顏色的不透明度,那麼它會產生迭代效果。你用什麼刷子顏色?如果你使用rgba值「rgba(255,125,25,0.5)」,它應該給你你想要的效果。 – Lanny

回答

2

正如Lanny所建議的,將alpha應用於實際筆畫,而不是Shape。您可以使用Graphics方法來解決這個問題。

例如: // set the brush color to red with the current brush alpha: this.brushColor = createjs.Graphics.getRGB(255, 0, 0, this.brushAlpha);