Zhuogu

av383695代码弹幕

Nov 27th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //This code segment is extracted from av383695, ALL RIGHTS reserved by original author.
  2. //URL: http://www.bilibili.tv/video/av383695/
  3.  
  4. //PART I: Life Bar I - 生命条1
  5. function drawContainer(x, y, settings) {
  6.     var pscale = settings.pscale;
  7.     var lifeTime = settings.lifeTime;
  8.     var bar_width = settings.bar_width;
  9.     var bar_height = settings.bar_height;
  10.     var state;
  11.     var blood_graphics;
  12.     var container = $.createCanvas({
  13.         x: x,
  14.         y: y,
  15.         lifeTime: lifeTime
  16.     });
  17.     var g = $.createShape({
  18.         x: 85 * pscale,
  19.         y: 0,
  20.         parent: container,
  21.         lifeTime: lifeTime
  22.     });
  23.     g.graphics.beginFill(0xFFFFFF, 0.6);
  24.     g.graphics.moveTo(0, 0);
  25.     g.graphics.lineTo(pscale * (170 + bar_width + 30), 0);
  26.     g.graphics.lineTo(pscale * (170 + bar_width + 30 - 20), pscale * (bar_height + 25));
  27.     g.graphics.lineTo(pscale * (125 + bar_width * 0.55 + 20 + 13), pscale * (bar_height + 25));
  28.     g.graphics.curveTo(pscale * (125 + bar_width * 0.55 + 20), pscale * (bar_height + 30), pscale * (125 + bar_width * 0.55 + 20), pscale * (bar_height + 30 + 13));
  29.     g.graphics.lineTo(pscale * (125 + bar_width * 0.55 + 20), pscale * (bar_height + 50));
  30.     g.graphics.lineTo(0, pscale * (bar_height + 50));
  31.     g.graphics.lineTo(0, -3);
  32.  
  33.     /** 血条文字状态区 **/
  34.     g.graphics.drawRoundRect(pscale * (125 + bar_width * 0.55 + 25), pscale * (bar_height + 28), pscale * 210, pscale * 60, 10, 10);
  35.  
  36.     state = $.createComment(settings.max_blood + " / " + settings.max_blood, {
  37.         x: pscale * (85 + 125 + bar_width * 0.55 + 25) + 3,
  38.         y: pscale * (bar_height + 28) + 35 / 2 * pscale - 5,
  39.         parent: container,
  40.         lifeTime: lifeTime
  41.     });
  42.     state.filters = null;
  43.     state.font = "Berlin Sans FB";
  44.     state.bold = false;
  45.     state.fontsize = 35 * pscale;
  46.  
  47.     var clv = $.createComment(settings.owner, {
  48.         x: 85 * pscale + 3,
  49.         y: 25 * pscale,
  50.         parent: container,
  51.         lifeTime: lifeTime
  52.     });
  53.     clv.filters = null;
  54.     clv.font = "Berlin Sans FB";
  55.     clv.bold = false;
  56.     clv.fontsize = 28 * pscale;
  57.  
  58.     var g = $.createShape({
  59.         x: 210 * pscale,
  60.         y: 25 * pscale,
  61.         parent: container,
  62.         lifeTime: lifeTime
  63.     });
  64.     g.graphics.lineStyle(4, 0xB6C33F, 0.4, false, "vertical", "none", "miter", 4);
  65.     g.graphics.moveTo(-3, -3);
  66.     g.graphics.lineTo(pscale * bar_width + pscale * 10, -3);
  67.     g.graphics.lineTo(pscale * (bar_width - 10) + pscale * 10, pscale * bar_height * 0.55 + 2);
  68.     g.graphics.lineTo(pscale * bar_width * 0.55 + 2, pscale * bar_height * 0.55 + 2);
  69.     g.graphics.lineTo(pscale * bar_width * 0.55 - 10 + 2, pscale * bar_height + 3);
  70.     g.graphics.lineTo(-3, pscale * bar_height + 3);
  71.     g.graphics.lineTo(-3, -3);
  72.  
  73.     g.graphics.lineStyle(2, 0xD4E43C, 0.8, false, "vertical", "none", "miter", 2);
  74.     g.graphics.moveTo(-3, -3);
  75.     g.graphics.lineTo(pscale * bar_width + pscale * 10, -3);
  76.     g.graphics.lineTo(pscale * (bar_width - 10) + pscale * 10, pscale * bar_height * 0.55 + 2);
  77.     g.graphics.lineTo(pscale * bar_width * 0.55 + 2, pscale * bar_height * 0.55 + 2);
  78.     g.graphics.lineTo(pscale * bar_width * 0.55 - 10 + 2, pscale * bar_height + 3);
  79.     g.graphics.lineTo(-3, pscale * bar_height + 3);
  80.     g.graphics.lineTo(-3, -3);
  81.  
  82.     var g = $.createShape({
  83.         x: 210 * pscale,
  84.         y: 25 * pscale,
  85.         parent: container,
  86.         lifeTime: lifeTime
  87.     });
  88.     blood_graphics = g.graphics;
  89.  
  90.     settings.container = container;
  91.     settings.state = state;
  92.     settings.blood_graphics = blood_graphics;
  93.     return settings;
  94. }
  95.  
  96. function drawBlood(ctx, bar_blood) { /** 血条 **/
  97.     var pscale = ctx.pscale;
  98.     var bar_width = ctx.bar_width;
  99.     var bar_height = ctx.bar_height;
  100.     ctx.current_blood = bar_blood;
  101.     ctx.state.text = Math.floor(ctx.max_blood * bar_blood) + " / " + ctx.max_blood;
  102.     ctx.state.fontsize = 35 * pscale;
  103.     var alphas = [1, 0.95];
  104.     var ratios = [0x00, 0xFF];
  105.     var matr = $.createMatrix();
  106.     matr.createGradientBox(pscale * 30, pscale * 30, Math.PI * 0.5, 0, 0);
  107.  
  108.     var colors = [0x669726, 0x7FB23B];
  109.     if(bar_blood <= 0.2) {
  110.         colors = [0xA4003F, 0xBD1B54];
  111.     }
  112.     ctx.blood_graphics.clear();
  113.     ctx.blood_graphics.beginGradientFill("linear", colors, alphas, ratios, matr, "pad");
  114.     ctx.blood_graphics.moveTo(0, 0);
  115.     ctx.blood_graphics.lineTo(pscale * bar_blood * bar_width, 0);
  116.     ctx.blood_graphics.lineTo(pscale * bar_blood * bar_width - 10 < 0 ? 0 : pscale * bar_blood * bar_width - 10, pscale * (bar_blood > 0.55 ? 0.55 : 1) * bar_height);
  117.     if(bar_blood > 0.55) {
  118.         ctx.blood_graphics.lineTo(pscale * bar_width * 0.55, pscale * 0.55 * bar_height);
  119.         ctx.blood_graphics.lineTo(pscale * bar_width * 0.55 - 10, pscale * bar_height);
  120.     }
  121.     ctx.blood_graphics.lineTo(0, pscale * bar_height);
  122.     ctx.blood_graphics.lineTo(0, 0);
  123.     ctx.blood_graphics.endFill();
  124. }
  125.  
  126. function setToBlood(ctx, new_blood) {
  127.     var plus_opt = 1;
  128.     if(new_blood < ctx.current_blood) plus_opt = 0;
  129.     var tmp_blood = ctx.current_blood;
  130.     Utils.interval(function() {
  131.         if(plus_opt) {
  132.             tmp_blood += 0.01;
  133.         } else {
  134.             tmp_blood -= 0.01;
  135.         }
  136.         if(tmp_blood < 0) {
  137.             drawBlood(ctx, 0);
  138.             return false;
  139.         }
  140.         if(tmp_blood > 1) return false;
  141.         drawBlood(ctx, tmp_blood);
  142.     }, 20, Math.abs(new_blood - ctx.current_blood) / 0.01);
  143. }
  144.  
  145. var ctx = drawContainer(10, 5, {
  146.     pscale: 0.5,
  147.     bar_width: 630,
  148.     bar_height: 40,
  149.     max_blood: 900,
  150.     current_blood: 900,
  151.     owner: "Kirito",
  152.     lifeTime: 14
  153. });
  154. drawBlood(ctx, ctx.current_blood / ctx.max_blood);
  155.  
  156. var colors = [0x2a2929, 0xb7ac96, 0x5e7276, 0x505a5b, 0xfbe1c2, 0x9d746c, 0xe4c198, 0x404247, 0x7f817d, 0x6b5a55, 0xd7bb9d, 0xb29a86, 0xefdebd, 0x7f7866, 0xfef0d6, 0x845c4e, 0x958476, 0x423b3d, 0xbcbcbb, 0x504a4a, 0xa59177, 0x50616c, 0x9fabaf, 0xc59d77, 0xebdec5, 0xffffff, 0x69656a, 0x8e755b, 0x8a8c8b, 0xf1eeea, 0x594a4a, 0x9c8b7d, 0x708495, 0x8d5e5d, 0xe0d4b9, 0x647584, 0x343439, 0x9d9590, 0x999999, 0xfbe7ce, 0xc7b5a8, 0x4e3533, 0xcdac8c, 0xe9cfb3, 0x546774, 0x645753, 0x6c615b, 0x624e4b, 0xf9f3e6, 0x7b7a7a, 0x4a4b50, 0x7c6458, 0xb99379, 0x9e8074, 0x737374, 0xbc9c8b, 0x868d92, 0xcdcbc8, 0x8c7f76, 0x535151, 0x4a4142, 0x6f818f, 0xd7c2ac, 0xfef4ce, 0x8e979b, 0xf8dfc5, 0xa19c92, 0xb5b8ba, 0x8e8a85, 0xcdb39d, 0xaf8b76, 0x6b6363, 0x92625d, 0x5a5b5a, 0xdbdcde, 0x646b73, 0x697985, 0xedd7bc, 0x758c9e, 0x63646a, 0x595353, 0x3b3b3c, 0xe6ccac, 0xc4a08c, 0x6c6d75, 0x635d62, 0xbcb49d, 0x302d2f, 0x454a4c, 0x635252, 0x846261, 0xafa69f, 0x444241, 0x8b766d, 0x7d7271, 0xafaca4, 0x4f4844, 0xa5968a, 0xa98674, 0xccd3d5, 0x82838d, 0xbbb6a9, 0xba9581, 0x9d7973, 0x6b7175, 0xb7a094, 0x695a5c, 0xfef3e0, 0xc8cbcd, 0xfaedcb, 0xcdaa94, 0x7e6e69, 0xdfbd9e, 0xf5deb6, 0xfeeec6, 0x747b85, 0x8e9396, 0x9da5a8, 0x5b6b78, 0xf0d4b6, 0x535358, 0x4b4f54, 0x5a5c61, 0x7c7c84, 0x926d6b, 0x7c5a59, 0x8c685c, 0xe5c7a9, 0x756854, 0x798fa2, 0x716b6a, 0xa79381, 0x514b51, 0xbda384, 0xb88f80, 0x595258, 0x70504d, 0x716564, 0xe4e2d9, 0xc4c4b9, 0x74747b, 0x927369, 0xa58e82, 0x928781, 0x8d837b, 0xc8a892, 0xf8e8c5, 0xb2948f, 0x847b72, 0x5c636b, 0xc6ad8d, 0x4a5a64, 0xd9b69d, 0xd5ae96, 0x7a828d, 0xc4b09c, 0xdfc8af, 0xaca08b, 0x553632, 0x6b5055, 0x5b6671, 0x7c8185, 0xa78179, 0xeccfb0, 0xa97c6c, 0x969c9f, 0xf7e8bf, 0xe6d9cd, 0x413a41, 0x333333, 0x666666, 0x917e72, 0xddd4d0, 0xb39483, 0x684a46, 0xc4a187, 0x3c3d41, 0x806d64, 0x4a444a, 0xfde7c6, 0x4b4949, 0xbfa394, 0x706b71, 0xf9eed8, 0xddc3a0, 0x837269, 0x849094, 0x735851, 0x6e7d8b, 0xfeefce, 0xfff6d6, 0x625c5b, 0x616e79, 0x393239, 0x788b97, 0xa27b73, 0x534344, 0x94948c, 0xf6f7f7, 0x73675d, 0x825c5d, 0x6c6b6b, 0xa48d78, 0x6d747e, 0x958b83, 0x725c5d, 0x5b6264, 0x8c7264, 0x82685e, 0xc3977d, 0x8c6c63, 0xaca095, 0xd3b9a4, 0xd8d8d8, 0xbca987, 0xcccccc, 0x867c79, 0x4a5258, 0x535b61, 0x63717c, 0xdecebd, 0x6a7681, 0xa7a7a9, 0xa3a59b, 0x9b6b62, 0xab937d, 0x8b6264, 0xb6aea8, 0x95887d, 0xa48572, 0xad8a7a, 0xfae5cc, 0x996666, 0xd0a78b, 0xb48575, 0xf4d7b2, 0x636b6b, 0xd7bea7, 0xfef6eb, 0x968c8b, 0xf2e5d7, 0xedcfb4, 0xcdb395, 0x957a6c, 0xf7e0bf, 0x807e88, 0xa17365, 0xb2a8a4, 0xbcb8b7, 0x7d90a0, 0x6c6d63, 0x5c6a73, 0x7b7976, 0x848583, 0x848d8f, 0x949494];
  157. var matrix = [
  158.     [160, -1, 218, 50, 81, 7, 168, 193, -3, 81, -2, 87, -1, 168, 169, 0, 169, 193, -1, 169, -3, 193, -4, 87, -2, 193, -2, 36, -1, 36],
  159.     [118, 160, 122, 88, 7, 50, 168, 193, 168, 81, -1, 168, -1, 36, 0, 17, -1, 0, -1, 193, 168, -1, 169, 193, -6, 169, -1, 193, 169, 193, -4, 193],
  160.     [192, 160, 122, 7, 121, 135, 178, -1, 92, 81, 178, -1, 193, -1, 47, 135, 193, 0, 87, 168, -2, 193, 168, -2, 193, 168, -2, 87, 193, -2, 169, 168, -2, 36, 36],
  161.     [192, 251, 3, 50, 206, -1, 19, -1, 60, 180, -1, 17, 60, 200, 137, 59, 193, 60, 81, 178, -1, 92, -2, 178, 193, 168, 178, -1, 36, 87, 168, -1, 169, 87, 168, -2, 81, 81],
  162.     [192, -1, 217, 218, 84, 85, 135, -3, 178, 196, 90, -1, 137, 96, 47, -1, 92, 132, -1, 176, 178, 132, 92, 169, 178, -2, 0, 169, 92, -1, 87, -1, 81, 178, -1, 81, 176],
  163.     [192, 21, 3, 79, 140, 191, 71, 191, 137, 80, 47, 124, 103, 177, 45, -1, 103, 30, 19, 135, 180, 168, 59, 132, 169, 92, 132, 180, 81, -2, 178, 168, 87, 60, 81, 50, -1, 176, 7],
  164.     [118, 151, 206, 104, 54, 71, 130, -1, 137, 51, 162, 145, 103, 51, 187, 55, 230, 196, 80, -1, 168, 132, -1, 193, -1, 59, 132, 19, 89, 196, 92, 132, 17, -1, 125, 17, 59, -1, 7, 88],
  165.     [21, -2, 123, 54, 252, -1, 94, 177, 173, 62, 242, 126, 187, 55, 82, 195, 30, 191, 132, 92, 80, 168, -1, 178, 135, 132, 9, 124, 60, 59, -1, 17, 125, 5, 60, 135, -1, 88, 121],
  166.     [21, 160, 218, 8, 252, 253, 216, 93, 230, 83, 237, 230, 187, 230, 163, -1, 141, 89, 191, 92, 59, 178, -2, 80, -2, 53, 171, 60, 106, 89, 136, 173, 155, 47, 59, 85, 121, 120],
  167.     [118, -1, 253, -1, 68, -1, 58, 173, 102, 83, -1, 210, -1, 127, 244, 127, 208, 106, 59, 180, -1, 73, 59, -1, 191, 135, 185, 55, 199, 30, 137, 187, 230, 82, -1, 208, 80, 26, 120, 122],
  168.     [76, 28, 91, 253, 197, 228, 55, -2, 102, 225, 208, 98, 110, 77, 152, 187, 45, 19, 17, 19, 85, 80, 71, 191, 199, 11, 142, 80, 137, 205, 229, 82, 244, 77, 243, 59, 26, 122, 75],
  169.     [255, 247, 255, 28, 97, 155, 171, 130, 252, 58, -1, 207, 230, -1, 55, -1, 9, 80, -1, 19, 130, 137, -1, 130, 46, 229, 155, 148, 45, 111, 53, 212, 156, -1, 62, 243, 19, 182, 79, 104],
  170.     [95, 91, 197, 37, 155, 93, 130, 223, -1, 213, 38, 19, 9, 141, 195, 141, 46, 94, 130, -1, 216, 94, -2, 171, 69, 97, 199, 46, 208, 98, 173, 55, 145, 69, 16, 180, 54, 75, 140],
  171.     [138, 95, 68, 105, 62, 177, 91, 57, 248, 215, 49, 132, 92, -1, 89, 205, 148, 143, 111, 144, -3, 93, 155, -1, 185, 9, 207, 53, -1, 98, 173, 11, 181, 58, 7, 54, -1, 161],
  172.     [67, 139, 211, 105, 62, 43, 105, 213, 138, 95, 116, 26, 73, 59, 80, 46, 143, 144, 148, 239, 143, -1, 93, 55, 212, 16, 51, 210, 141, 93, 185, 46, -2, 148, 250, 88, 54, 161, 100],
  173.     [149, 38, 220, 55, 181, 65, 241, 167, 198, 247, 239, 216, 94, 253, 223, 143, -1, 148, 204, 97, -1, 16, 11, 237, 230, 229, 173, 208, 37, 227, 201, 178, 92, -1, 49, 122, 50, 104, 100, 56],
  174.     [154, 3, 91, 110, 70, 82, 65, 231, 238, 172, 147, 141, 16, 248, 167, 97, 228, 216, 97, -1, 31, 225, 10, 133, 242, 119, -1, 105, 227, 255, 191, -1, 73, 170, 222, 79, 217, 104, 100, 64],
  175.     [99, 218, 19, 142, 52, 153, 244, -1, 39, 240, 83, 55, 70, 62, 220, 131, 16, 204, 97, 142, 225, 184, -1, 119, 109, -2, 167, 97, 37, 94, 253, 255, 18, 99, 201, 218, 104, 254, 254],
  176.     [108, 104, 7, 30, 126, 209, 119, 244, -1, 231, 43, 184, -1, 12, 156, 131, 16, 97, 131, -1, 82, 146, 109, 189, -3, 48, 40, 142, 243, 211, 57, 198, 215, 252, 104, 140, 186, 254],
  177.     [188, 192, 88, 60, 41, 15, 163, 113, 4, 39, 189, -3, 10, 202, 131, -1, 225, 127, 189, -2, 63, -3, 183, 242, 145, 11, 40, 29, 25, 101, 68, 8, 161, 64, 38],
  178.     [188, 221, 217, 180, 60, 158, 153, 244, 4, 179, 189, -3, 242, 202, 225, -1, 127, 179, 189, 63, -6, 12, 184, 42, 34, 107, 183, 1, 66, 8, 100, 64, 117],
  179.     [188, 221, 218, 50, 196, 158, 98, 244, 4, 179, -1, 189, -1, 146, 175, 70, 133, 127, 244, 189, -2, 63, -9, 14, 24, 157, 66, 8, 254, 18, 74],
  180.     [219, 192, 218, 50, 135, 174, 15, 119, 4, 179, 189, -2, 113, 23, 42, 163, -1, 244, 189, -10, 14, -2, 62, 157, 211, 223, 186, 64, 76],
  181.     [251, -1, 75, 79, 54, 137, 174, 152, 4, 179, 189, -2, 6, -1, 146, 244, 235, 146, 189, -4, 190, -7, 109, 214, 1, 204, 252, 115, 251, 251],
  182.     [219, 115, 154, 115, 26, 94, 174, 134, 244, 4, 109, -1, 244, 235, 189, -2, 113, 235, 189, 63, -6, 190, -4, 82, 150, 86, 250, 56, 115, 2, 22],
  183.     [76, 154, -1, 245, 201, 71, 205, 126, 163, 244, 179, -3, 189, -3, 166, 189, 63, -10, 109, 184, 34, 13, 8, 22, 154, 165, 198],
  184.     [221, -1, 154, 100, 140, 85, 106, 90, 110, 244, 4, 109, -1, 189, -3, 63, -13, 146, -1, 157, 46, 115, 64, 186, 74, 25],
  185.     [149, 192, 115, 100, 140, 26, 191, 205, 5, 241, 244, 179, -1, 189, -2, 114, -1, 63, -13, 62, 128, 49, 154, 221, 22, 25, 25],
  186.     [21, -1, 203, 115, 140, 182, 71, 89, 205, 230, 241, 4, 179, 189, -1, 179, -1, 189, 63, -11, 109, 12, 16, 130, 123, 154, 219, 117, 25, 25],
  187.     [67, 115, 149, 75, 84, -1, 182, 191, 89, 125, 5, 43, 4, -1, 179, 244, 113, 109, 63, -1, 166, 63, -7, 109, 77, 20, 46, 54, 203, -1, 219, 76, 74, 25],
  188.     [25, 74, 104, 122, 79, 54, -1, 85, 80, 89, 136, 164, 152, 244, 179, -2, 189, -2, 166, 109, 14, -4, 109, 12, 150, 27, 128, 85, 79, 192, 219, -2, 22, 25],
  189.     [108, 67, 206, 120, 122, 79, 54, 182, 135, 96, -1, 33, 224, 209, 119, 179, -2, 189, -6, 146, 82, 133, 27, 187, -1, 191, 79, -1, 192, -1, 35, -1, 61, 99],
  190.     [206, 218, 3, -1, 122, -1, 182, 54, 85, 19, -1, 200, 72, -1, 98, 127, 4, 179, 189, -4, 12, 242, 52, 164, 187, -1, 46, -1, 170, 75, -2, 192, 76, 32, -1, 194],
  191.     [218, 217, 3, -3, 26, 54, 85, 59, 30, 90, -1, 226, 72, 246, 10, 4, 39, -1, 244, 82, 42, 209, -1, 134, 207, 9, 71, -1, 26, 84, 115, -1, 251, -1, 35, 249, 78, 32],
  192.     [104, 79, 121, -1, 50, 120, 85, 54, 85, 59, -1, 53, 200, 226, -2, 224, 145, 43, 152, 175, 209, 175, -1, 145, 11, 46, 71, 140, -1, 123, 100, -2, 219, 118, 219, 32, 129, 78],
  193.     [84, 79, 88, -1, 7, 59, 73, 201, 85, 59, 45, 181, 200, -1, 226, -1, 232, 224, 164, 234, 209, 233, 153, -1, 212, 31, 80, 85, 140, 245, -2, 154, 194, 188, 44, 118, 76, 129, 129],
  194.     [206, 120, 88, 176, -1, 178, 120, 122, 135, 59, 45, 212, 124, 200, 226, -1, 5, 164, 234, 175, 152, 163, -1, 10, 62, 199, 59, -1, 122, 84, 203, 84, -1, 221, 219, 21, 44, 35, 32, 129],
  195.     [206, 73, 120, 88, 81, -1, 50, 135, -1, 132, 45, 69, 173, 210, 124, 229, 70, 209, 152, 12, 146, -1, 77, 82, 155, 47, -1, 132, -1, 121, 149, 116, 165, 117, 165, 186, 118, -1, 35, 129],
  196.     [85, 122, -1, 120, 7, 169, 92, 59, -1, 180, 177, 145, -1, 195, -1, 102, 175, 112, 244, 179, 109, -1, 12, -1, 202, 30, -1, 50, 121, 88, 206, 108, 25, -2, 198, 154, 44, 35, 32],
  197.     [85, -1, 120, -1, 50, 36, 81, 132, -1, 180, 243, 83, 69, 230, -1, 175, 153, 119, 109, -1, 189, 109, 12, 163, 207, 30, 19, 121, 122, -1, 217, 218, 108, 25, -2, 165, 21, 35, 188]
  198. ];
  199. $G._set("colors", colors);
  200. $G._set("matrix", matrix);
  201. var g = $.createShape({
  202.     x: 0,
  203.     y: 0,
  204.     parent: ctx.container,
  205.     lifeTime: 14
  206. });
  207. for(y = 0; y < matrix.length; y++) {
  208.     hasPoint = fales;
  209.     bx = 0;
  210.     for(x = 0; x < matrix[y].length; x++) {
  211.         mIndex = matrix[y][x];
  212.         if(mIndex < 0) {
  213.             bx += -mIndex;
  214.             continue;
  215.         }
  216.         if(mIndex == 999) {
  217.             alpha = 0;
  218.         } else {
  219.             alpha = 1;
  220.         }
  221.         if(!hasPoint) {
  222.             hasPoint = true;
  223.             g.graphics.moveTo(bx - 1, y);
  224.         }
  225.         g.graphics.lineTo(bx, y);
  226.         g.graphics.lineStyle(1, colors[mIndex], alpha, true, "none", "none", "bevel", 1);
  227.         bx++;
  228.     }
  229. }
  230.  
  231. var ctx_monster = drawContainer(18, Player.height - 55, {
  232.     pscale: 0.4,
  233.     bar_width: 630,
  234.     bar_height: 40,
  235.     max_blood: 9999,
  236.     current_blood: 9999,
  237.     LV: "??",
  238.     owner: "便当甲",
  239.     lifeTime: 14
  240. });
  241. drawBlood(ctx_monster, ctx_monster.current_blood / ctx_monster.max_blood);
  242. Utils.delay(function() {
  243.     setToBlood(ctx_monster, 0);
  244. }, 10000);
  245.  
  246. //PART II: Login - 登录
  247. ScriptManager.clearEl();
  248. var galTextTmr;
  249. function setGaltext(oTxt, txt, onfinish)
  250. {
  251.     if (galTextTmr!=undefined)
  252.     {
  253.         galTextTmr.stop();
  254.     }
  255.     var galTextTmr = interval(function(){ oTxt.text+=txt.substr(oTxt.length,1);
  256.         if (oTxt.length==txt.length)
  257.         {
  258.             if (onfinish!=undefined) onfinish();
  259.         }
  260.     }, 100, txt.length);
  261. }
  262.  
  263. var login_box = $.createCanvas({x:70,y:120,lifeTime:8});
  264. var sg = $.createShape({parent: login_box,lifeTime:8}), g=sg.graphics;
  265. g.beginFill(0xffffff, 0.6);
  266. g.drawRoundRect(0, 0, 400, 200, 20);
  267. g.endFill();
  268.  
  269. var sg = $.createShape({parent: login_box,x:130, y:16,lifeTime:8}), g=sg.graphics;
  270. g.beginFill(0xffffff, 0.8);
  271. g.drawRoundRect(0, 0, 200, 30, 10);
  272. g.drawRoundRect(0, 60, 200, 30, 10);
  273. g.endFill();
  274.  
  275. $.createComment("ALO帐号:", {x:80, y:140, fontsize:20,lifeTime:8});
  276. $.createComment("ALO密码:", {x:80, y:200, fontsize:20,lifeTime:8});
  277.  
  278. var lblST = $.createComment("  ", {color:0xff9966,x:210, y:260,alpha:0.9,fontsize:20,lifeTime:8});
  279. var cmtf = lblST.getTextFormat(0,1);cmtf.bold=false;lblST.setTextFormat(cmtf,0,1);
  280. var lblUser = $.createComment("|", {x:210, y:140,color:0,fontsize:20,lifeTime:8});
  281. var lblPassword = $.createComment("", {x:210, y:200,color:0,fontsize:20,lifeTime:8});
  282. lblUser.filters = null;
  283. Utils.delay(function(){
  284.     lblUser.text = "";
  285.     setGaltext(lblUser, "Kirito", function(){
  286.       lblPassword.filters = null;
  287.       setGaltext(lblPassword, "********", function(){
  288.             lblST.text = "正在使用意念登录中。。。";
  289.  
  290.             Utils.delay(function(){
  291.               lblST.text = "您的帐号已欠费。。。";
  292.             },1300);
  293.       });
  294.     });
  295.  
  296. }, 500);
  297.  
  298. //PART III: Life Bar II - 生命条2
  299. ScriptManager.clearEl();
  300. var lifetime = 10;
  301.  
  302. function drawHSP(g, hp_value, sp_value)
  303. {
  304.     g.clear();
  305.     g.lineStyle(1,0xffffff);g.lineTo(0,hsp_bar_height);g.lineTo(128,hsp_bar_height);g.lineTo(131,hsp_bar_height / 2);g.lineTo(127,0);g.lineTo(1,0);
  306.     var matr = $.createMatrix();
  307.     matr.createGradientBox(hsp_bar_width, hsp_bar_height / 4, Math.PI*0.5, 0, 0);
  308.  
  309.     g.lineStyle(undefined);
  310.     g.beginGradientFill("linear", [0x00CC00, 0x80FF20], [0.8, 1], [0x00, 0xFF], matr, "reflect");
  311.     g.moveTo(1,1); g.lineTo(1,hsp_bar_height / 2); g.lineTo(hsp_bar_width * hp_value,hsp_bar_height / 2); g.lineTo(hsp_bar_width * hp_value, 1); g.lineTo(1, 1);
  312.     g.endFill();
  313.    
  314.     g.beginGradientFill("linear", [0x0000CC, 0x2080C8], [0.8, 1], [0x00, 0xFF], matr, "reflect");
  315.     g.moveTo(1,1+hsp_bar_height / 2); g.lineTo(1,hsp_bar_height); g.lineTo(hsp_bar_width * sp_value,hsp_bar_height); g.lineTo(hsp_bar_width * sp_value, hsp_bar_height / 2 + 1); g.lineTo(1, hsp_bar_height / 2 + 1);
  316.     g.endFill();
  317. }
  318.  
  319. var name = $.createComment("Lifa",{x:328, y:75, lifeTime:lifetime,fontsize:10,color:0xffffff});
  320. name.filters = [];
  321. name.font = "Berlin Sans FB";
  322. name.bold = false;
  323. var sp=$.createShape({x:331,y:71,lifeTime:lifetime}), g=sp.graphics;
  324. var alphas = [0.4, 0];
  325. var ratios = [0x00, 0xFF];
  326. var colors = [0xcccccc, 0xcccccc];
  327. var matr = $.createMatrix();
  328. matr.createGradientBox(150, 200, 0, 0, 0);
  329. g.lineStyle(undefined);
  330. g.beginGradientFill("linear", colors, alphas, ratios, matr, "pad");
  331. g.lineTo(-8,12);g.lineTo(-1,24);g.lineTo(179,21);g.lineTo(178,2);g.lineTo(0,0);
  332. g.endFill();
  333.  
  334. var hsp_bar_height = 12;
  335. var hsp_bar_width = 120;
  336.  
  337. sp_bar=$.createShape({x:353,y:76,alpha:0.7,lifeTime:lifetime}), g=sp_bar.graphics;
  338. var sp_value = 0.9;
  339. drawHSP(g, 1, sp_value);
  340. Utils.delay(function(){
  341.     Utils.interval(function(){
  342.       sp_value-=0.01;
  343.       drawHSP(g, 1, sp_value);
  344.     }, 100, 40);
  345. }, 300);
Advertisement
Add Comment
Please, Sign In to add comment