SHARE
TWEET

BytesOutput

RblSb Jul 26th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Packer {
  2.  
  3.     public static function pack(data:Array<FastFloat>):haxe.io.Bytes {
  4.         var i = 0;
  5.         inline function get() return data[i++];
  6.         final out = new haxe.io.BytesOutput();
  7.         while (i < data.length) {
  8.             final type:RecorderData = cast get();
  9.             out.writeInt8(cast type);
  10.             switch (type) {
  11.                 case FrameBegin:
  12.                 case Begin:
  13.                     out.writeInt32(cast get());
  14.                 case SetColor:
  15.                     out.writeInt32(cast get());
  16.                 case DrawImage:
  17.                     out.writeInt8(cast get());
  18.                     out.writeFloat(get());
  19.                     out.writeFloat(get());
  20.                 case DrawScaledSubImage:
  21.                     out.writeInt8(cast get());
  22.                     out.writeFloat(get());
  23.                     out.writeFloat(get());
  24.                     out.writeFloat(get());
  25.                     out.writeFloat(get());
  26.                     out.writeFloat(get());
  27.                     out.writeFloat(get());
  28.                     out.writeFloat(get());
  29.                     out.writeFloat(get());
  30.                 case End:
  31.                 case FrameEnd:
  32.             }
  33.         }
  34.         return out.getBytes();
  35.     }
  36.  
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top