| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 0 |
| 经验 | |
| 最后登录 | 2017-9-13 |
| 在线时间 | 784 小时 |
- 梦石
- 0
- 星屑
- 48
- 在线时间
- 784 小时
- 注册时间
- 2013-1-4
- 回帖
- 1057
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 墨凌羽 于 2015-11-24 13:19 编辑
浴巾大美女提议另开一贴,那就另开好了。
这里是个人【6RID墨凌羽,不过常用shitake】脚本的发布帖。嗯,虽然这么说实际上也没多少东西。囧
1.SUtils-个人工具箱类
说明:提供一些便利性的工具函数。不定期更新。
更新日期:2015.11.23
已有函数:
cutBitmap/cutBitmapConfig 位图分割
[fold=代码]
[pre lang="javascript"]/* shitake 的工具箱
*
* cutBitmap Bitmap分割
* 参数说明:
* srcBitmap 欲分割的位图
* width 单帧宽
* height 单帧高
* type 分割类型 枚举型{
* 0:按行分割
* 1:按列分割
* 2:先行后列
* 3:先列后行
* }
* cutBitmapConfig Bitmap按配置分割
* 参数说明
* srcBitmap 预处理的位图
* config 一个二维数组,每个值为[x, y, width, height]这样的记录对应帧的位置矩形
*/
var SUtils = SUtils || {}
SUtils.cutBitmap = function(srcBitmap, width, height, type) {
switch (type) {
case 0:
var bitmaps = this.cutRow(srcBitmap, width, height);
break;
case 1:
var bitmaps = this.cutRank(srcBitmap, width, height);
break;
case 2:
var bitmaps = this.cutRowRank(srcBitmap, width, height);
break;
case 3:
var bitmaps = this.cutRankRow(srcBitmap, width, height);
break;
default:
throw new Error('Type error')
}
return bitmaps;
}
SUtils.cutBitmapConfig = function(srcBitmap, config) {
var bitmaps = [];
var length = config.length;
for (var i = 0; i < length; i++) {
var bitmap = new Bitmap(config[0], config[1]);
bitmap.blt(0,0, srcBitmap, config[0], config[1], config[2], config[3]);
bitmaps.push(bitmap);
};
return bitmaps;
}
SUtils.cut = function(srcBitmap, dx, dy, number, width, height) {
var bitmaps = [];
for (var i = 0; i < number; i++) {
var x = i * dx;
var y = i * dy;
var bitmap = new Bitmap(width, height);
bitmap.blt(srcBitmap, x, y, width, height, 0, 0);
bitmaps.push(bitmap);
};
return bitmaps;
}
SUtils.cutRow = function(srcBitmap, width, height) {
var number = srcBitmap.width / width;
var dx = width;
var dy = 0;
return this.cut(srcBitmap, dx, dy, number, width, height);
}
SUtils.cutRank = function(srcBitmap, width, height) {
var number = srcBitmap.height / height;
var dx = 0;
var dy = height;
return this.cut(srcBitmap, dx, dy, number, width, height);
}
SUtils.cutRowRank = function(srcBitmap, width, height) {
var bitmaps1 = this.cutRow(srcBitmap, width, srcBitmap.height);
var bitmaps2 = [];
for (var i = 0; i < bitmaps1.length; i++) {
bitmaps2 = bitmaps2.concat(this.cutRank(bitmaps1, width, height));
};
return bitmaps2;
}
SUtils.cutRankRow = function(srcBitmap, width, height) {
var bitmaps1 = this.cutRank(srcBitmap, srcBitmap.width, height);
var bitmaps2 = [];
for (var i = 0; i < bitmaps1.length; i++) {
bitmaps2 = bitmaps2.concat(this.cutRow(bitmaps1, width, height));
};
return bitmaps2;
}[/pre][/fold]
以后不定期更新。 |
评分
-
查看全部评分
|