<commit_before>import nme.display.BitmapData;
import nme.display.Bitmap;
import nme.display.Sprite;
import nme.geom.Rectangle;
import nme.utils.ByteArray;
import nme.Assets;
import nme.Memory;

class Sample extends Sprite
{
   var mDisplay:Bitmap;
   var mBitmap:BitmapData;

   function new()
   {
      super();

      mBitmap = Assets.getBitmapData("image1.jpg");

      mDisplay = new Bitmap(mBitmap);
      addChild(mDisplay);

      stage.addEventListener(flash.events.Event.ENTER_FRAME, updateBitmap);
   }

   static var pass = 0;
   static var demo = 1;
   function updateBitmap(_)
   {
      if (demo==0)
      {
         gameOfLifeInts();
      }
      else
         cycleColours();

      pass++;
      #if (neko || cppia)
      if (pass==40)
      #else
      if (pass==500)
      #end
      {
         pass = 0;
         demo = 1-demo;
         if (demo==0)
            mBitmap = Assets.getBitmapData("image2.png");
         else
            mBitmap = Assets.getBitmapData("image1.jpg");
         mDisplay.bitmapData = mBitmap;
      }
   }

   function cycleColours()
   {
      var w = mBitmap.width;
      var h = mBitmap.height;
      var r = new Rectangle(0,0,w,h);

      var pixels = mBitmap.getPixels(r);

      Memory.select(pixels);
      var idx = 0;
      for(p in 0...w*h)
      {
         idx++; // Skip alpha

         Memory.setByte( idx, Memory.getByte( idx ) + 8 ); idx++;
         Memory.setByte( idx, Memory.getByte( idx ) + 8 ); idx++;
         Memory.setByte( idx, Memory.getByte( idx ) + 8 ); idx++;
      }
      pixels.position = 0;<commit_msg>Scale output of sample.  Keep previous data in cache<commit_after>import nme.display.BitmapData;
import nme.display.Bitmap;
import nme.display.Sprite;
import nme.geom.Rectangle;
import nme.utils.ByteArray;
import nme.Assets;
import nme.Memory;

class Sample extends Sprite
{
   var mDisplay:Bitmap;
   var mBitmap:BitmapData;
   var cachedPixels:nme.utils.ByteArray;

   function new()
   {
      super();

      mBitmap = Assets.getBitmapData("image1.jpg");

      mDisplay = new Bitmap(mBitmap);
      addChild(mDisplay);

      stage.addEventListener(flash.events.Event.ENTER_FRAME, updateBitmap);
      stage.addEventListener(flash.events.Event.RESIZE, function(_) updateScale);
      updateScale();
   }

   function updateScale()
   {
     if (stage!=null)
     {
        var sx = stage.stageWidth / mBitmap.width;
        var sy = stage.stageHeight / mBitmap.height;
        mDisplay.scaleX = mDisplay.scaleY= Math.min(sx,sy);
     }
   }

   static var pass = 0;
   static var demo = 1;
   function updateBitmap(_)
   {
      if (demo==0)
      {
         gameOfLifeInts();
      }
      else
         cycleColours();

      pass++;
      #if (neko || cppia)
      if (pass==40)
      #else
      if (pass==500)
      #end
      {
         pass = 0;
         demo = 1-demo;
         if (demo==0)
            mBitmap = Assets.getBitmapData("image2.png");
         else
            mBitmap = Assets.getBitmapData("image1.jpg");
         mDisplay.bitmapData = mBitmap;
         cachedPixels = null;
         updateScale();
      }

   }

   function cycleColours()
   {
      var w = mBitmap.width;
      var h = mBitmap.height;
      var r = new Rectangle(0,0,w,h);

      if (cachedPixels==null)
        cachedPixels = mBitmap.getPixels(r);
      var pixels = cachedPixels;

      Memory.select(pixels);
      var idx = 0;
      for(p in 0...w*h)
      {
         idx++; // Skip alpha

         Memory.setByte( idx, Memory.getByte( idx ) + 8 ); idx++;
         Memory.setByte( idx, Memory.getByte( idx ) + 8 ); idx++;
         Memory.setByte( idx, Memory.getByte( idx ) + 8 ); idx++;
      }
      pixels.position = 0;
{'fraction_non_alphanumeric': 0.1256742179072276, 'fraction_numerical': 0.011866235167206042, 'mean_word_length': 2.06023102310231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6690102', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1200, 'n_words': 267}