Processing中的顏色漸變


今早打開電腦,發現群里昨晚的留言,是關於如何在Processing中使顏色漸變的,我總結了一下,無非是以下3種:

1、用HSB色系

colorMode(HSB,360,255,100);
fill(x,255,100);
x++;

2、用lerpColor()

color a = color(255, 0, 0);
color b = color(0, 255, 0);
color c = lerpColor(a, b, map(mouseX, 0, width, 0, 1));
fill(c);
rect(0, 0, width, height);

3、位運算 bit operation

int a = (argb >> 24) & 0xFF;
int r = (argb >> 16) & 0xFF; // Faster way of getting red(argb)
int g = (argb >> 8) & 0xFF; // Faster way of getting green(argb)
int b = argb & 0xFF; // Faster way of getting blue(argb)
fill(r, g, b, a);
rect(30, 20, 55, 55);

總的來說,Processing中做顏色漸變還是比較好做的,大家可以根據作品需要自行選用以上3種中的任意一種。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM