2013-02-19 45 views
0

我想要开发热图,现在最初我将不得不绘制强度蒙版,并且由于我使用了GWT,所以我随机生成了一些坐标并将我的圆圈(需要渐变)放置在这些位置,所以输出成为彼此重叠的圆圈。如果我从Dylan Vester看强度掩模,它会变得非常光滑我怎样绘制我的热图?另外如何实现类似于Dylan Vester的输出?问题还在于如果我画圆圈,那么如何在两个或更多个圆的交点处确定强度,他们是如何实现的?这里是我的代码如何为热图创建强度遮罩?

// creating the object for the heat points 
     Heat_Point x = new Heat_Point(); 

    // Variables for random locations 
     int Min = 1,Max = 300; 
     int randomx,randomy; 

    // Generating set of random values 
     for(int i = 0 ; i < 100 ; i++) { 

      // Generating random x and y coordinates 
       randomx = Min + (int)(Math.random() * ((Max - Min) + 1)); 
       randomy = Min + (int)(Math.random() * ((Max - Min) + 1)); 

      // Drawing the heat points at generated locations 
       x.Draw_Heatpoint(c1, randomx, randomy); 


     } 

,这里是我如何策划我的热点是Heat_Point类

Context con1 = c1.getContext2d(); // c1 is my canvas 
CanvasGradient x1; 
x1 = ((Context2d) con1).createRadialGradient(x,y,10,x,y,20); 
x1.addColorStop(0,"black"); 
x1.addColorStop(1,"white"); 
((Context2d) con1).beginPath(); 
((Context2d) con1).setFillStyle(x1); 
((Context2d) con1).arc(x,y,20, 0, Math.PI * 2.0, true); 
((Context2d) con1).fill(); 
((Context2d) con1).closePath();` 

这里我应该添加一些图片,但我没有足够的声誉: D:P

回答

0

我快速看了一下HeatmapJS(http://www.patrick-wied.at/static/heatmapjs/),似乎他使用了径向渐变(就像你上面所说的那样),他还使用了不透明度和一种称为“多重混合”的滤色器来消除强度热图中的颜色。

他的代码相当令人印象深刻。它是开源的,所以你可能想看看它!