Skip to content

Instantly share code, notes, and snippets.

@itoz
Created September 13, 2011 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itoz/1213008 to your computer and use it in GitHub Desktop.
Save itoz/1213008 to your computer and use it in GitHub Desktop.
透明画像
/**
*============================================================
* copyright(c) 2011 www.itoz.jp
* @author itoz
*============================================================
*/
package jp.itoz.display
{
import flash.display.Sprite;
import flash.display.Shape;
/**
* 背景透過を表す格子状Viewクラス
*/
public class TranceparentGrid extends Sprite
{
private var _bgColor : int = 0xffffff;
private var _squareColor : int = 0xefefef;
public function TranceparentGrid()
{
}
public function draw(sizeW : int, sizeH : int, span : int=10) : void
{
this.graphics.clear();
this.graphics.beginFill(_bgColor);
this.graphics.drawRect(0, 0, sizeW, sizeH);
this.graphics.endFill();
this.graphics.beginFill(_squareColor);
var pretd : Number = (sizeW) / span;
var pretr : Number = (sizeH) / span;
var td : int = ( pretd == int(pretd) ) ? pretd : int(pretd + 1);
var tr : int = ( pretr == int(pretr) ) ? pretr : int(pretr + 1);
for (var i : int = 0; i < tr; i++) {
for (var j : int = 0; j < td; j++) {
if (i % 2 == 0) {
if (j % 2 == 0) {
this.graphics.drawRect(j * span, i * span, span, span);
}
}
else {
if (j % 2 == 1) {
this.graphics.drawRect(j * span, i * span, span, span);
}
}
}
}
this.graphics.endFill();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment