是否有任何方法可以使用dat.gui(http://code.google.com/p/dat-gui/)获得用于修改RGBA颜色的alpha通道的颜色选择器?

目前,我只能使用颜色选择器更改RGB值-即使颜色选择器接受一个alpha值。

示例(也可用http://jsfiddle.net/mortennobel/PT3g2/1/):

var ColorObject = function() {
   this.color = [ 0, 128, 255, 0.3 ]; // RGB with alpha
    this.showAlert = function(){
        alert("Color is "+this.color);
    }
};

var colorObject = new ColorObject();
var gui = new dat.GUI();

gui.addColor(colorObject, 'color');
gui.add(colorObject, 'showAlert');

最佳答案

我不确定是否有任何简单的方法来扩展现有库。我刚刚对库本身进行了更改。您可以在这里尝试:http://jsbin.com/anewaz/2

修改后的源代码也位于我的github上:https://github.com/mariozski/datGUIwithAlpha/blob/master/dat.gui.js

希望对您有所帮助:-)

z

10-07 19:10
查看更多