繁体   English   中英

我可以获取Caman.js过滤器列表吗?

[英]Can I get the list of Caman.js filters?

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

例如:

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”,.........])

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

我不确定我会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> 

我使用下面的代码实现了@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> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM