代码改变世界

actionscript中常用的基本公式(2)

2011-01-08 12:34  AlexLee85  阅读(183)  评论(0编辑  收藏  举报

 

转换为十进制: 

trace(hexValue);

 

十进制转换为十六进制:

 trace(decimalValue.toString(16));

 

颜色合成: 

color24 = red << 16 | green << 8 | blue; 

color32 = alpha << 24 | red << 16 | green << 8 | blue;

 

颜色提取: 

red = color24 >> 16; 

green = color24 >> 8 & 0xFF; 

blue = color24 & 0xFF; 

 

alpha = color32 >> 24; 

red = color32 >> 16 & 0xFF; 

green = color32 >> 8 & 0xFF; 

blue = color232 & 0xFF;

 

过控制点的曲线: 

// xt, yt is the point you want to draw through 

// x0, y0 and x2, y2 are the end points of the curve 

x1 = xt * 2 – (x0 + x2) / 2; 

y1 = yt * 2 – (y0 + y2) / 2; 

moveTo(x0, y0); curveTo(x1, y1, x2, y2);

 

两点之间的中点

x = (x1+x2) / 2;

y = (y1+y2) / 2;