3D创意 C++

颜色、透明度

参考代码:

//透明度测试,利用透明度,可以方便的进行复杂建模,从而看到内部结构,透明物体一样可以打印!


function main () {
  var o = [];
  for (var i = 7; i >= 0; i--) { // reverse order for seeing through all cylinders (see http://www.opengl.org/wiki/Transparency_Sorting)
    // hsl to rgb, creating rainbow [r,g,b]
    o.push(
      cylinder({r: 3, h: 20}).setColor(
        hsl2rgb(i / 8, 1, 0.5).concat(1 / 8 + i / 8) // and add to alpha to make it [r,g,b,a]
      ).translate([(i - 3) * 7.5, 0, 0])
    );
  }
  o.push(color('red', cube(5)).translate([-4, -10, 0]));
  o.push(color('red', 0.5, cube(5)).translate([4, -10, 0]));
  return o;
}


其中,o.push 是将对象推入数组;

color('red',0.5,cube(5));  就是透明度;

而setColor 里的, 数组: [r,g,b,a] 分别代表:红,绿,蓝,透明度,值都是 0-1 之间;


下一节

码圣代码编程

打字练习

3D创意C++

进入比赛

创客中心

关于傲亚

傲亚CMS

傲亚物联网

我要合作

创客平台

南昌市红谷滩区名门世家2期8号楼608
aoyakefu
TEL:18720086320
kefu@1wwz.com

扫码关注公众号

扫码添加创始人

企业微信服务商