简体   繁体   English

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

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

Is there any way to return the list of all the built-in filters within the library. 有什么方法可以返回库中所有内置过滤器的列表。

For example: 例如:

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

     caman_Default_List= this.getAllFilters();
});

For now I'm using this and it works okay: 现在,我正在使用它,它可以正常工作:

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();
});

But I was wondering if there is a way to get the values of the filters without delcaring them customly. 但是我想知道是否有一种方法来获取过滤器的值而无需定制它们。 (eg. list = [ "vintage", "lomo", ......... ]) (例如list = [“ vintage”,“ lomo”,.........])

I was looking through their docs, but could not find anything helpful for the data you are trying to get. 我正在查看他们的文档,但找不到对您尝试获取的数据有帮助的信息。 I took a look at their code and came up with the below for you. 我看了看他们的代码,并为您提出了以下内容。

I am not sure I would 100% trust the code, because the order of properties might change, but at least it gives you what you wanted. 我不确定我会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> 

I used the code below to achieve what I wanted as @AndrewLohr stated: 我使用下面的代码实现了@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