Advertisement
ianharrigan

Untitled

Jan 18th, 2016
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 2.96 KB | None | 0 0
  1.         var sx = Std.int(screenX) + 1;
  2.         var sy = Std.int(screenY);
  3.         var cx = Std.int(surfaceWidth) - 1;
  4.         var cy = Std.int(surfaceHeight) - 1;
  5.  
  6.         var borderSize:Int = 0;
  7.         if (_style.borderSize != null) {
  8.             borderSize = Std.int(_style.borderSize);
  9.         }
  10.        
  11.         //borderSize = 3;
  12.        
  13.         //g.color = 0xFF000000;
  14.        
  15.         if (borderSize > 0) {
  16.             g.color = _style.borderColor | 0xFF000000;
  17.             //g.color = 0xFF000000;
  18.             for (i in 0...borderSize) {
  19.                 g.drawRect(sx, sy, cx, cy);
  20.                 sx++;
  21.                 sy++;
  22.                 cx-=2;
  23.                 cy-=2;
  24.             }
  25.             //g.drawRect(x, y, cx, cy, borderSize);
  26.             g.color = Color.White;
  27.         }
  28.        
  29.        
  30.         if (_style.backgroundColor != null) {
  31.             sx--;
  32.             //sy--;
  33.             cx++;
  34.             cy++;
  35.            
  36.             if (_style.backgroundColorEnd != null && _style.backgroundColor != _style.backgroundColorEnd) {
  37.                 sy-=borderSize;
  38.                
  39.                 var gradientType:String = "vertical";
  40.                 if (_style.backgroundGradientStyle != null) {
  41.                     gradientType = _style.backgroundGradientStyle;
  42.                 }
  43.                
  44.                 /*
  45.                 gradientType = "horizontal";
  46.                 _style.backgroundColor = 0xFFFF0000;
  47.                 _style.backgroundColorEnd = 0xFF00FF00;
  48.                 */
  49.                
  50.                 var arr:Array<Int> = null;
  51.                 var n:Int = cast borderSize;
  52.                 var n:Int = 0;// cast borderSize;
  53.                 if (gradientType == "vertical") {
  54.                     arr = ColorUtil.buildColorArray(_style.backgroundColor, _style.backgroundColorEnd, Std.int(cy));
  55.                     for (c in arr) {
  56.                         g.color = c | 0xFF000000;
  57.                         g.drawLine(sx, sy + n + 1, sx + cx, sy + n + 1);
  58.                         //g.fillRect(sx, sy + n, cx, 1);
  59.                         g.color = Color.White;
  60.                         n++;
  61.                     }
  62.                     //g.color = Color.White;
  63.                 } else if (gradientType == "horizontal") {
  64.                     arr = ColorUtil.buildColorArray(_style.backgroundColor, _style.backgroundColorEnd, Std.int(cx));
  65.                     for (c in arr) {
  66.                         g.color = c | 0xFF000000;
  67.                         //g.fillRect(sx + n, sy, 1, cy);
  68.                         g.drawLine(sx + n + 1, sy + 1, sx + n + 1, sy + cy + 1);
  69.                         g.color = Color.White;
  70.                         //g.
  71.                         n++;
  72.                     }
  73.                     //g.color = Color.White;
  74.                 }
  75.                
  76.                 g.color = Color.White;
  77.             } else {
  78.                 g.color = _style.backgroundColor | 0xFF000000;
  79.                 g.fillRect(sx, sy, cx, cy);
  80.                 g.color = Color.White;
  81.             }
  82.            
  83.         }
  84.        
  85.         for (c in __children) {
  86.             c.renderTo(g);
  87.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement