簡體   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