0

有什么方法可以返回库中所有内置过滤器的列表。

例如:

var caman_Default_List = [];
Caman('myCanvas', function(){

     caman_Default_List= this.getAllFilters();
});

现在我正在使用它,它工作正常:

var filters =  
[   
   "vintage", "lomo", "clarity", "sinCity", "sunrise", 
   "crossProcess", "orangePeel", "love", "grungy", "jarques", "pinhole", 
   "oldBoot", "glowingSun", "hazyDays", "herMajesty", "nostalgia", 
   "hemingway", "concentrate"
];

myList.push(filters[   some filters   ]);

Caman("#myCanvas", function(){

     this[myList[index]]().render();
});

但我想知道是否有一种方法可以获取过滤器的值,而无需自定义它们。(例如,list = [ "vintage", "lomo", ......... ])

4

2 回答 2

1

我正在查看他们的文档,但找不到任何对您尝试获取的数据有帮助的东西。我查看了他们的代码,并为您提供了以下内容。

我不确定我是否会 100% 信任代码,因为属性的顺序可能会改变,但至少它会给你想要的东西。

console.log(Object.keys(Caman.prototype).slice(75, 93))
<script src="https://cdnjs.cloudflare.com/ajax/libs/camanjs/4.1.2/caman.full.min.js"></script>

于 2019-01-24T19:22:09.750 回答
0

正如@AndrewLohr 所说,我使用下面的代码来实现我想要的:

    //Declare lists to store filter names
    var list4,list5,list6,list7 = [];

    //Get Caman Filters (Samples : "vintage", "clarity", ... )
    list4 = (Object.keys(Caman.prototype).slice(75, 93));
    list5 = list4.toString().toUpperCase(); //To upper Case as string value (use as Label Button Name)

    //Get Caman Filters (Customs : "brightness", "saturation")
    list6 = Object.keys(Caman.prototype).slice(45, 55);
    //Add some more elements in the list
    list6.push("clip", "stuckBlur", "exposure", "noise", "sharpen");

    list7 = list6.toString().toUpperCase(); //To upper Case as string value (use as Slider Name)


    //Print lists 
    console.log(list4);console.log(list5);console.log(list6);console.log(list7);
<script src="https://cdnjs.cloudflare.com/ajax/libs/camanjs/4.1.2/caman.full.min.js"></script>

于 2019-01-25T14:11:57.897 回答