顏色由左至右 為 Red, Green, blue 分為由三個變數來紀錄 使用 位元位移運算子 移到該顏色的位至
nRed = nR << 16;
nGreen = nG << 8;
nBlue = nB;
nR = Math.cos(nRadians) * 127 + 128 << 16;
nG = Math.cos(nRadians + 2 * Math.PI / 3) * 127 + 128 << 8;
nB = Math.cos(nRadians + 4 * Math.PI / 3) * 127 + 128;
nColor = nR | nG | nB;
再使用 邏輯運算子 or 將三個顏色合為一個變數
接下來再用 nRadians 來控顏色的變化
資料來源
http://www.boostworthy.com/blog/?p=200
沒有留言:
張貼留言