查看: 10509|回复: 1

[原创发布] 个人脚本发布帖

[复制链接]
梦石
0
星屑
48
在线时间
784 小时
注册时间
2013-1-4
回帖
1057
发表于 2015-11-23 08:08:53 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 墨凌羽 于 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]


以后不定期更新。

点评

基佬来了QSQ  发表于 2016-1-11 11:45

评分

参与人数 1星屑 +66 梦石 +2 收起 理由
余烬之中 + 66 + 2 图书馆收录

查看全部评分

RM-GUI延期。。。最近被黑心老板压迫T_T
二次元少女的shitake,长着长脸,身高165,蓝色卷双马尾,FCUP,瞳色黑色,病气和御宅属性,是天才少女。
梦石
0
星屑
50
在线时间
289 小时
注册时间
2014-12-12
回帖
138
发表于 2015-11-23 17:57:56 | 显示全部楼层
前来支持
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部