麦甜甜圈


  • 首页

  • 分类

  • 关于

  • 过往作品

  • 一些个有意思的链接

Unity自用2D像素图描边Shader

发表于 2018-08-20 | 分类于 Unity3D |

Shader 学习中,基于 Sprite-Default。

效果

img

阅读全文 »

Ruby计算文件的md5值

发表于 2018-08-16 | 分类于 Ruby |
1
2
require "digest/md5"
md5 = Digest::MD5.hexdigest(File.open(filename, 'rb'){|fs|fs.read})

检查是否处于微信浏览器内

发表于 2018-08-16 | 分类于 JavaScript |

简单判断userAgent

1
2
3
4
5
6
7
function isInWeiXin() {
var ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
}
return false
}

【RMVA】缓动工具方法移植

发表于 2018-07-17 | 分类于 RPG Maker |

预览

效果1

阅读全文 »

Cocos DrawNode绘制实心圆

发表于 2017-12-23 | 分类于 Cocos2d-X |

原 cc.DrawNode 的 drawCircle 方法绘制的是空心圆,而 drawDot 方法绘制的是指定 radius 的矩形,这里扩展 cc.DrawNode ,绘制实心圆。

环境

  • Cocos Creator 1.7.0 release

脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(function() {
// 扩展cc.DrawNode
var cc_DrawNode = cc.DrawNode;
/**
* 绘制实心圆
*/
cc_DrawNode.prototype.drawSolidCircle = function(center, r, color) {
// 利用cc.Mask类型为ellipse的算法
var radius = {
x: r,
y: r
};
var segements = 64;
var polies =[];
var anglePerStep = Math.PI * 2 / segements;
for(var step = 0; step < segements; ++ step) {
polies.push(cc.v2(radius.x * Math.cos(anglePerStep * step) + center.x,
radius.y * Math.sin(anglePerStep * step) + center.y));
}
this.drawPoly(polies, color, 0, color);
};
})();

算法本身是绘制 segement 边的实心多边形,故 segement 越大,越接近圆。

使用方法

  1. 保存为js文件
  2. 在 Creator 编辑器中将脚本导入为插件

解决VS2015无法创建新项目问题

发表于 2017-08-01 | 分类于 笔记 |

问题

VS2015无法建立新项目,点击确定会反复弹出创建工程窗口:

问题

解决

  • 删除 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE 下的 ItemTemplatesCache 和 ProjectTemplatesCache 两个文件夹

  • 在VS2015开发人员命令提示(开始-程序-visual studio 2015-visual studio tools下)中输入

    1
    devenv /InstallVSTemplates
  • 执行成功后输入

    1
    devenv /Setup

之后再打开就可以成功创建了。

proto折腾

发表于 2017-04-04 | 分类于 笔记 |

protoc-gen-lua

  • 安装 proto-python

  • 安装 setuptools

    • 下载get-pip.py
    • 然后 python get-pip.py
    • 或者直接 python -m pip install -U pip setuptools
    • 编译好的 protoc.exe 需要放到 protobuf-python-3.2.0\protobuf-3.2.0\src 下
  • 下载 protoc-gen-lua

  • genlua命令:
    >protoc.exe --lua_out=lua --plugin=protoc-gen-lua="绝对路径\plugin\protoc-gen-lua.bat" xxxx.proto

  • 转码,有些proto文件是gbk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require "find"
Find.find("."){|file|
next unless File.extname(file) == ".proto"
break_to_next = false
f = File.open(file, "r")
line = []
f.each_line{|l|
from = l.dup.encode("utf-8","gbk") rescue break_to_next = true;break
to = from.encode("gbk","utf-8")
line << to
}
f.close
next if break_to_next
f = File.open(file, "wb")
line.each{|l|
f.puts l
}
f.close
}

项目相关

  • 使用 *.proto 通配符时用bash命令行执行(git-bash)

  • 改脚本

    原

    ../tools/protoc.exe --cpp_out=. *.proto -I=../ProtoMessage/;./

    -I后2路径改成两次-I 、

    ../tools/protoc.exe --cpp_out=. *.proto -I=../ProtoMessage/ -I./

  • 给subevent.proto增加import(121~185)


然而还没搞完

简单像素脸图

发表于 2017-02-06 | 分类于 HTML |

利用对称的随机点形成脸图/o\







阅读全文 »

脑壳LOGO

发表于 2017-02-06 | 分类于 HTML |

脑壳logo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<html>
<body style="text-align:center;background-color:#1e576b">
<canvas id="logoCanvas"></canvas>
</body>
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>

<script type="text/javascript">
function drawLogo() {
var w = 11;
var h = 17;
var border = 24;
var map = [
[1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,0,0,0,1],
[1,0,1,0,1,1,1,1,1,0,1],
[1,0,1,0,0,0,0,0,1,0,1],
[1,0,1,0,1,1,1,0,1,0,1],
[1,0,1,0,1,0,1,0,1,0,1],
[1,0,1,0,1,0,1,0,1,0,1],
[1,0,1,0,0,0,0,0,1,0,1],
[1,0,1,1,1,0,1,1,1,0,1],
[1,0,1,0,0,0,0,0,1,0,1],
[1,0,1,0,1,1,1,0,1,0,1],
[1,0,1,0,1,0,0,0,1,0,1],
[1,0,1,0,1,1,1,0,1,0,1],
[1,0,1,0,0,0,0,0,1,0,1],
[1,0,1,1,1,0,1,1,1,0,1],
[1,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,1]
]
var canvas=document.getElementById('logoCanvas');
var fillWidth = border * w;
var fillHeight = border * h;
$(canvas).attr("height", fillHeight + "px");
$(canvas).attr("width", fillWidth + "px");
var ctx=canvas.getContext('2d');
ctx.clearRect(0, 0, fillWidth, fillHeight);
for (var y = 0; y < h; y += 1) {
for (var x = 0; x < w; x += 1) {
if (map[y][x] == 0) {continue;}
ctx.fillStyle='#FFF';
ctx.fillRect(x * border, y * border, border, border);
}
}
}
$(document).ready(function() {
drawLogo();

});

</script>
</html>

预览:



从前的一个A*

发表于 2017-02-06 | 分类于 Ruby |

以前的一个a*练习,搬过来凑个数……

A*算法描述见这篇博文

阅读全文 »
12345
烁灵SureBrz

烁灵SureBrz

50 日志
13 分类
47 标签
邻家的小屋
  • 哈库纳玛塔塔(原23RPG)论坛
  • 橡皮擦擦
  • ShiinaYASHIRO Games
© 2013 - 2024 烁灵SureBrz |
由 Hexo 强力驱动
主题 - NexT.Mist