2016-01-15 41 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);