{"id":1743,"date":"2021-08-09T19:32:09","date_gmt":"2021-08-09T11:32:09","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=1743"},"modified":"2021-08-10T13:43:42","modified_gmt":"2021-08-10T05:43:42","slug":"auto-generated-avatar","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/auto-generated-avatar\/","title":{"rendered":"GameCreator \u81ea\u52a8\u751f\u6210\u884c\u8d70\u56fe"},"content":{"rendered":"<pre class=\"brush: jscript; collapse: true; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nconst fs = require('fs');\r\n\r\nfunction gen(png, target, offset_x = 0, offset_y= 0, w  = 32, h = 32) {\r\n\r\n    let t;\r\n    let json = JSON.parse(fs.readFileSync('avatar5.json', 'utf8'));\r\n    json&#x5B;&quot;picUrls&quot;] = &#x5B;&quot;asset\/image\/_RM\/VA\/Characters\/&quot; + png + &quot;.png&quot;];\r\n\r\n    t = json&#x5B;&quot;actionListArr&quot;]&#x5B;0]&#x5B;&quot;frameImageInfo&quot;];\r\n    \r\n    let ox = offset_x*(w*3);\r\n    let oy = offset_y*(h*4);\r\n\r\n    for (let i=0;i&lt;4;++i) {\r\n        t&#x5B;i]&#x5B;0]&#x5B;&quot;rect&quot;]&#x5B;0] = -(w*1+ox);\r\n        t&#x5B;i]&#x5B;0]&#x5B;&quot;rect&quot;]&#x5B;1] = -(h*i+oy);\r\n        t&#x5B;i]&#x5B;0]&#x5B;&quot;rect&quot;]&#x5B;2] = w;\r\n        t&#x5B;i]&#x5B;0]&#x5B;&quot;rect&quot;]&#x5B;3] = h;\r\n        t&#x5B;i]&#x5B;0]&#x5B;&quot;width&quot;] = w;\r\n        t&#x5B;i]&#x5B;0]&#x5B;&quot;height&quot;] = h;\r\n        t&#x5B;i]&#x5B;0].x = -Math.floor(w\/2);\r\n        t&#x5B;i]&#x5B;0].y = -(h-1);\r\n    }\r\n\r\n    t = json&#x5B;&quot;actionListArr&quot;]&#x5B;1]&#x5B;&quot;frameImageInfo&quot;];\r\n\r\n    for (let i=0;i&lt;4;++i) {\r\n        t&#x5B;i].pop();\r\n        for (let j=0;j&lt;3;++j) {\r\n            t&#x5B;i]&#x5B;j]&#x5B;&quot;picUrlIndex&quot;] = 0;\r\n            t&#x5B;i]&#x5B;j]&#x5B;&quot;rect&quot;]&#x5B;0] = -(w*j+ox);\r\n            t&#x5B;i]&#x5B;j]&#x5B;&quot;rect&quot;]&#x5B;1] = -(h*i+oy);\r\n            t&#x5B;i]&#x5B;j]&#x5B;&quot;rect&quot;]&#x5B;2] = w;\r\n            t&#x5B;i]&#x5B;j]&#x5B;&quot;rect&quot;]&#x5B;3] = h;\r\n            t&#x5B;i]&#x5B;j]&#x5B;&quot;width&quot;] = w;\r\n            t&#x5B;i]&#x5B;j]&#x5B;&quot;height&quot;] = h;\r\n            t&#x5B;i]&#x5B;j].x = -Math.floor(w\/2);\r\n            t&#x5B;i]&#x5B;j].y = -(h-1);\r\n        }\r\n    }\r\n\r\n    fs.writeFileSync(target, JSON.stringify(json,null, 4));\r\n}\r\n\r\ngen(&quot;$\u30ad\u30c3\u30ab&quot;, 'avatar8001.json')\r\ngen(&quot;Actor5&quot;, 'avatar8002.json', 1, 1)\r\ngen(&quot;$\u30e9\u30f4\u30a3\u30a2\u30f3&quot;, 'avatar8003.json')\r\ngen(&quot;$\u30bf\u30df\u30cd&quot;, 'avatar8004.json')\r\ngen(&quot;Vehicle&quot;, 'avatar44.json', 1, 0)\r\n<\/pre>\n<pre class=\"brush: cpp; collapse: true; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n\r\nconst int N = int(2e5) + 9;\r\nchar buf&#x5B;5*96*96];\r\n\r\nint n;\r\n\r\nint main() {\r\n#ifndef ONLINE_JUDGE\r\n    \/\/freopen(&quot;PORTMAP.001&quot;, &quot;rb&quot;, stdin);\r\n    freopen(&quot;PORTMAP001.json&quot;, &quot;w&quot;, stdout);\r\n#endif\r\n    int n;\r\n    }*\/\r\n    char c;\r\n\r\n    REP(i, 101) {\r\n        fstream file, outfile;\r\n        string name = &quot;PORTMAP.&quot;;\r\n        int x = i;\r\n        int c = x % 10; x \/= 10;\r\n        int b = x % 10; x \/= 10;\r\n        int a = x % 10;\r\n        name += ('0'+a);\r\n        name += ('0'+b);\r\n        name += ('0'+c);\r\n\r\n        file.open(name.c_str(), ios::binary|ios::in);\r\n\r\n        string out_name = &quot;PORTMAP&quot;;\r\n        out_name += ('0'+a);\r\n        out_name += ('0'+b);\r\n        out_name += ('0'+c);\r\n        out_name += &quot;.json&quot;;\r\n        outfile.open(out_name.c_str(), ios::out);\r\n\r\n        file.read(buf, 96*96);\r\n        REP(i, 96*96) {\r\n            if (i) outfile &lt;&lt; &quot;,&quot;;\r\n            outfile &lt;&lt; int(byte(buf&#x5B;i]));\r\n        }\r\n\r\n        outfile.close();\r\n        file.close();\r\n    }\r\n}\r\n<\/pre>\n<pre class=\"brush: jscript; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nlet t = Game.player.sceneObject.avatar;\r\nt.loadData(1001);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>const fs = require(&#8216;fs&#8217;); function gen(png, target, offset_x = 0, offset_y= 0, w = 32, h = 32) { let t; let json = JSON.parse(fs.readFileSync(&#8216;avatar5.json&#8217;, &#8216;utf8&#8217;)); json&#x5B;&quot;picUrls&quot;] = &#x5B;&quot;asset\/image\/_RM\/VA\/Characters\/&quot; + png + &quot;.png&quot;]; t = json&#x5B;&quot;actionListArr&quot;]&#x5B;0]&#x5B;&quot;frameImageInfo&quot;]; let ox = offset_x*(w*3); let oy = offset_y*(h*4); for (let i=0;i&lt;4;++i) { t&#x5B;i]&#x5B;0]&#x5B;&quot;rect&quot;]&#x5B;0] = -(w*1+ox); t&#x5B;i]&#x5B;0]&#x5B;&quot;rect&quot;]&#x5B;1] = -(h*i+oy); t&#x5B;i]&#x5B;0]&#x5B;&quot;rect&quot;]&#x5B;2] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-1743","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-s7","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=1743"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1743\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=1743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=1743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=1743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}