浏览代码

added textureFromCDB

Nicolas Cannasse 11 月之前
父节点
当前提交
45a4fe2130
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      hrt/impl/Gradient.hx

+ 12 - 0
hrt/impl/Gradient.hx

@@ -180,6 +180,18 @@ class Gradient {
         return hash;
     }
 
+    public static function textureFromCDB( g : cdb.Types.Gradient, size : Int ) {
+        if( g == null ) return null;
+        var d : GradientData = {
+            stops : [for( i in 0...g.data.colors.length ) { position : g.data.positions[i], color : g.data.colors[i] }],
+            resolution : size,
+            isVertical : false,
+            interpolation: Linear,
+            colorMode: 0,
+        };
+        return textureFromData(d);
+    }
+
     public static function textureFromData(data : GradientData) : h3d.mat.Texture {
 
         var hash = getDataHash(data);