| 赞 | 68 |
| VIP | |
| 好人卡 | |
| 积分 | 65 |
| 经验 | |
| 最后登录 | 2023-7-2 |
| 在线时间 | 119 小时 |
- 梦石
- 0
- 星屑
- 6483
- 在线时间
- 119 小时
- 注册时间
- 2020-1-8
- 回帖
- 205
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 RPGzh500223 于 2023-5-6 21:02 编辑
[pre lang="ruby"]
dll = "TextBoard.dll"
str_num = Win32API.new(dll, 'GetUtf8StrCharNum', 'LL', 'L')
gf_rect = Win32API.new(dll, 'bitmap_GradientFill_rect', 'LLLL', 'L')
gf_xywh = Win32API.new(dll, 'bitmap_GradientFill_xywh', 'LLLLLLL', 'L')
text_size = Win32API.new(dll, 'text_size', 'LLLL', 'L')
dt_rect = Win32API.new(dll, 'TB_draw_text_rect', 'LLLLLLLL', 'L')
dt_xywh = Win32API.new(dll, 'TB_draw_text_xywh', 'LLLLLLLLLLL', 'L')
函数原型:
int GetUtf8StrCharNum(UINT strID, int cTerminate);
int bitmap_GradientFill_rect(UINT bitmapID, UINT rectID, UINT sLGClrsID, int anglePct);
int bitmap_GradientFill_xywh(UINT bitmapID, int rectX, int rectY, int rectWdth, int rectHght, UINT sLGClrsID, int anglePct);
int text_size(UINT bitmapID, UINT strID, int cTerminate, UINT sizeID);
int TB_draw_text_rect(UINT bitmapID, UINT rectID, UINT strID, int cTerminate, UINT fontARGB, UINT sLGClrsID, int anglePct, int option);
int TB_draw_text_xywh(UINT bitmapID, int rectX, int rectY, int rectWdth, int rectHght, UINT strID, int cTerminate, UINT fontARGB, UINT sLGClrsID, int anglePct, int option);
※函数仅适用于原版RMXP,参数中 **ID 只进行了简单检查
GetUtf8StrCharNum
功 能:获取符合Utf8编码的字符数(不超过0x7FFF_FFFF)
参 数:strID 字符串,String#object_id
cTerminate 字符串终止符,实际有效的是低位字节
-1 即 无终止符,终止符不计入字符数
返回值:31 bit 表示 strID错误 或 读取到了非Utf8编码字符
0..30bit 表示符合Utf8编码的字符数
示 例:str = "文字\nab\0\x80测试"
api.call(str.__id__, -1) => 0x8000_0006
api.call(str.__id__, 10) => 2
api.call(str.__id__, 0) => 5
bitmap_GradientFill_rect/xywh
功 能:多颜色线性ARGB渐变填充至位图的目标区域
参 数:bitmapID 位图,Bitmap#object_id
rectID/rectXYWH 位图的目标区域,rectID 为 Rect#object_id
sLGClrID 描述颜色渐变构成的 String#object_id
由节点进行描述,每个节点为float pos, UINT argb
首节点pos须为 0.0f,尾节点pos须为 1.0f
后一个节点pos至少比前一节点pos大 0.001f
字符串至少2个节点,且字节数须为 8的倍数
anglePct 颜色的方向,
逆时针角度的百分比数,取值范围[-3600W, +3600W]
返回值:0 表示成功
-n 表示第n个参数错误,-101 表示 申请内存失败
示 例:rect = Rect.new(-10, -10, 100, 50)
str = [0.0, 0xFFFF0000, 0.8, 0xFFFFFF00, 1.0, 0xFF00FF00].pack('fL'*3)
angle = 4550 (45.5度)
api.call(bitmap.__id__, rect.__id__, str.__id__, angle)
text_size
功 能:类似Bitmap#text_size
计算含斜体部分
字符串只读取符合Utf8的部分
参 数:bitmapID 位图,Bitmap#object_id
strID 字符串,String#object_id
cTerminate 字符串终止符,参上
sizeID[out] 接受文本大小的 object_id
当为 String#object_id 时,至少8字节,写入(textW, textH)
其他视为 Rect#object_id,写入(0, 0, textW, textH)
返回值:0 表示成功
-n 表示第n个参数错误,-100 表示 WIN32 API 调用失败
示 例:bitmap.font.size = 33
# ……字体设置……
str = "文字测试"
buf = "\0" * 8
api.call(bitmap.__id__, str.__id__, -1, buf.__id__)
TB_draw_text_rect/xywh
功 能:类似Bitmap#draw_text
字符串只读取符合Utf8的部分
有些字体的缺失字符描绘不同
不支持设置的 bitmap_font_color
目标区域太小时,不会缩小文本
参 数:bitmapID 位图,Bitmap#object_id
rectID/rectXYWH 位图的目标区域,rectID 为 Rect#object_id
strID 字符串,String#object_id
cTerminate 字符串终止符,参上
fontARGB 字体颜色,无法读取到位图设置的颜色自行设置
alpha << 24 | red << 16 | green << 8 | blue
此值设为 0 时,渐变描绘文本,
sLGClrID 与 anglePct 有效
sLGClrID 描述颜色渐变构成的 String#object_id,参上
anglePct 渐变颜色的方向,参上
option 0..7 bit 表示 align 文本对齐方式
对齐位置参照小键盘 1-9,超出该范围,修正为4
8..15bit 表示描绘模式
0 正常描绘;非0 反选描绘
返回值:0 表示成功
-n 表示第n个参数错误,-100 表示 WIN32 API 调用失败
-101 表示 申请内存失败
备 注:颜色alpha为0时,不进行描绘
示 例:rect = Rect.new(-10, -10, 100, 50)
str = "文字描绘测试"
clrs = [0.0, 0xFFFF0000, 0.5, 0xFFFFFF00, 1.0, 0xFF00FF00].pack('fL'*3)
angle = 4550 (45.5度)
# 红色,水平居中,垂直居中,反描绘
api.call(bitmap.__id__, rect.__id__, str.__id__, -1, 0xFFFF0000,
0, 0, 0x0105)
# 红-黄-蓝 逆时针45.5度,水平靠左,垂直靠上,正常描绘
api.call(bitmap.__id__, rect.__id__, str.__id__, -1, 0,
clrs.__id__, angle, 0x0007)
[/pre]
上面的注释在RMXP脚本编辑器内编辑的,网页显示对不齐的话,可以复制到RMXP看。
新:修复已发现BUG。
|
|