Skip to content

Instantly share code, notes, and snippets.

View czlc's full-sized avatar

czlc czlc

  • None
View GitHub Profile
local to_double , from_double
do
local s , e , d
-- Can't use with to_double as we can't strip debug info :(
d = string.dump ( loadstring ( [[return 523123.123145345]] ) )
s , e = d:find ( "\3\54\208\25\126\204\237\31\65" )
s = d:sub ( 1 , s )
e = d:sub ( e+1 , -1 )
function to_double ( n )
unsigned int RSHash(const char* str, unsigned int len)
{
unsigned int b = 378551;
unsigned int a = 63689;
unsigned int hash = 0;
unsigned int i = 0;
for(i = 0; i < len; str++, i++)
{
hash = hash * a + (*str);
/* 部件描述,顶点数是85个,用#uvs / 2计算,(vertices包括被各个骨骼影响的权重所以不是真实顶点数) */
"raptor_body": {
"raptor_body": {
"type": "skinnedmesh",
"uvs": [ 0.89014, 0.11136, 1, 0.22194, 1, 0.42847, 0.88179, 0.38589, 0.874, 0.47986, 0.84783, 0.51728, 0.82504, 0.54984, 0.82403, 0.61606, 0.82305, 0.67972, 0.74042, 0.86709, 0.61596, 0.93097, 0.49649, 0.90968, 0.41186, 0.71379, 0.36955, 0.70086, 0.32823, 0.68824, 0.30082, 0.69962, 0.27515, 0.71028, 0.25301, 0.71948, 0.22568, 0.73082, 0.20832, 0.72362, 0.19092, 0.7164, 0.15952, 0.70337, 0.1301, 0.69116, 0.09227, 0.67546, 0.06029, 0.63165, 0.02855, 0.58817, 0, 0.49874, 0.05045, 0.53494, 0.08267, 0.54507, 0.11815, 0.55623, 0.14733, 0.54161, 0.17913, 0.52568, 0.20324, 0.5136, 0.22867, 0.50087, 0.24871, 0.47664, 0.27523, 0.44458, 0.32026, 0.39015, 0.37517, 0.35747, 0.43476, 0.32201, 0.4893, 0.35534, 0.56021, 0.39867, 0.61587, 0.40674, 0.67769, 0.4157, 0.69094, 0.31314, 0.69362, 0.14742, 0.79219, 0.08354, 0.51541, 0.74573, 0.62393, 0.75425, 0.70856, 0.7287, 0.76132, 0.63288, 0.7566, 0.49454,
union {
struct sprite * children[1];
struct rich_text * rich_text;
int scissor;
struct anchor_data *anchor;
struct pack_polygon *polygon;
} data;
int
1.从offx,offy位置裁剪width, height 区域
-crop width x height + offx + offy
@czlc
czlc / luacs.md
Last active January 4, 2018 07:59
luacs

Lua 代码风格指南

格式化

  • 行首使用4字母缩进(Lua 推荐的是2字母)
  • 行长度不要超过80个字符
  • 不要用分号避免换行
-- bad
local whatever = 'sure';
@czlc
czlc / unicode.c
Last active January 6, 2022 12:44
#include <stdint.h>
static const char trailingBytesForUTF8[256] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
function string.fromhex(str)
return (str:gsub('..', function (cc)
return string.char(tonumber(cc, 16))
end))
end
function string.tohex(str)
return (str:gsub('.', function (c)
return string.format('%02X', string.byte(c))
end))
@czlc
czlc / delete_git_submodule.md
Created April 7, 2018 03:21 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule