RblSb

BytesOutput

Jul 26th, 2019
581
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×