Permalink
Browse files

draws only changed glyphs

  • Loading branch information...
1 parent edfd100 commit 63d0f79957e65d663d6fd5f242c12325f8147cb0 @headchant committed Feb 16, 2012
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/com/headchant/asciipanel/AsciiPanel.as
@@ -96,15 +96,23 @@ package com.headchant.asciipanel {
public function paint():void{
for (var i:int = 0; i < widthInCharacters; i++) {
for (var j : int = 0; j < heightInCharacters; j++) {
-
+ if (chars[i][j] == oldchars[i][j])
+ continue;
+
var bitmapdata : BitmapData = (glyphs[chars[i][j]] as BitmapData);
bitmapdata.threshold(bitmapdata, bitmapdata.rect, new Point(0,0), ">", 0xFF000000, foregroundColor[i][j]);
bitmapdata.threshold(bitmapdata, bitmapdata.rect, new Point(0,0), "==", 0xFF000000, backgroundColor[i][j]);
screen.copyPixels(bitmapdata, new Rectangle(0,0,charWidth,charHeight), new Point(i*charWidth, j*charHeight));
}
}
- //screenBitmap = new Bitmap(screen);
-
+ oldchars = copyChars(chars);
+ }
+
+ public function copyChars(itemToCopy):Array{
+ var newArray:Array = new Array();
+ for(var i:int = 0; i < (itemToCopy as Array).length; i++)
+ newArray[i] = (itemToCopy[i] as Array).slice();
+ return newArray;
}
public static function rgbaColor(r:int, g:int, b:int, a:int = 255):uint{

0 comments on commit 63d0f79

Please sign in to comment.