设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 681|回复: 1
打印 上一主题 下一主题

[原创发布] 填坑 TextBoard1.0

[复制链接]

Lv4.逐梦者

梦石
0
星屑
6483
在线时间
119 小时
注册时间
2020-1-8
帖子
234
跳转到指定楼层
1
发表于 2023-5-3 15:46:25 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 RPGzh500223 于 2023-5-6 21:02 编辑

RUBY 代码复制
  1. dll = "TextBoard.dll"
  2.  
  3. str_num = Win32API.new(dll, 'GetUtf8StrCharNum', 'LL', 'L')
  4. gf_rect = Win32API.new(dll, 'bitmap_GradientFill_rect', 'LLLL', 'L')
  5. gf_xywh = Win32API.new(dll, 'bitmap_GradientFill_xywh', 'LLLLLLL', 'L')
  6. text_size = Win32API.new(dll, 'text_size', 'LLLL', 'L')
  7. dt_rect = Win32API.new(dll, 'TB_draw_text_rect', 'LLLLLLLL', 'L')
  8. dt_xywh = Win32API.new(dll, 'TB_draw_text_xywh', 'LLLLLLLLLLL', 'L')
  9.  
  10.  
  11. 函数原型:
  12. int GetUtf8StrCharNum(UINT strID, int cTerminate);
  13. int bitmap_GradientFill_rect(UINT bitmapID, UINT rectID, UINT sLGClrsID, int anglePct);
  14. int bitmap_GradientFill_xywh(UINT bitmapID, int rectX, int rectY, int rectWdth, int rectHght, UINT sLGClrsID, int anglePct);
  15. int text_size(UINT bitmapID, UINT strID, int cTerminate, UINT sizeID);
  16. int TB_draw_text_rect(UINT bitmapID, UINT rectID, UINT strID, int cTerminate, UINT fontARGB, UINT sLGClrsID, int anglePct, int option);
  17. 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);
  18.  
  19.  
  20. ※函数仅适用于原版RMXP,参数中 **ID 只进行了简单检查
  21.  
  22.  
  23. GetUtf8StrCharNum
  24. 功  能:获取符合Utf8编码的字符数(不超过0x7FFF_FFFF)
  25.  
  26. 参  数:strID       字符串,String#object_id
  27.         cTerminate  字符串终止符,实际有效的是低位字节
  28.                       -1 即 无终止符,终止符不计入字符数
  29.  
  30. 返回值:31 bit   表示 strID错误 或 读取到了非Utf8编码字符
  31.         0..30bit 表示符合Utf8编码的字符数
  32.  
  33. 示  例:str = "文字\nab\0\x80测试"
  34.         api.call(str.__id__, -1) => 0x8000_0006
  35.         api.call(str.__id__, 10) => 2
  36.         api.call(str.__id__,  0) => 5
  37.  
  38.  
  39. bitmap_GradientFill_rect/xywh
  40. 功  能:多颜色线性ARGB渐变填充至位图的目标区域
  41.  
  42. 参  数:bitmapID         位图,Bitmap#object_id
  43.         rectID/rectXYWH  位图的目标区域,rectID 为 Rect#object_id                     
  44.         sLGClrID         描述颜色渐变构成的 String#object_id
  45.                            由节点进行描述,每个节点为float pos, UINT argb
  46.                            首节点pos须为 0.0f,尾节点pos须为 1.0f
  47.                            后一个节点pos至少比前一节点pos大 0.001f
  48.                            字符串至少2个节点,且字节数须为 8的倍数                           
  49.         anglePct         颜色的方向,
  50.                            逆时针角度的百分比数,取值范围[-3600W, +3600W]
  51.  
  52. 返回值:0    表示成功
  53.         -n   表示第n个参数错误,-101 表示 申请内存失败
  54.  
  55. 示  例:rect = Rect.new(-10, -10, 100, 50)
  56.         str = [0.0, 0xFFFF0000, 0.8, 0xFFFFFF00, 1.0, 0xFF00FF00].pack('fL'*3)
  57.         angle = 4550 (45.5)
  58.         api.call(bitmap.__id__, rect.__id__, str.__id__, angle)
  59.  
  60.  
  61. text_size
  62. 功  能:类似Bitmap#text_size
  63.         计算含斜体部分
  64.         字符串只读取符合Utf8的部分
  65.  
  66. 参  数:bitmapID    位图,Bitmap#object_id        
  67.         strID       字符串,String#object_id
  68.         cTerminate  字符串终止符,参上
  69.         sizeID[out] 接受文本大小的 object_id
  70.                       当为 String#object_id 时,至少8字节,写入(textW, textH)
  71.                       其他视为 Rect#object_id,写入(0, 0, textW, textH)
  72.  
  73. 返回值:0    表示成功
  74.         -n   表示第n个参数错误,-100 表示 WIN32 API 调用失败
  75.  
  76. 示  例:bitmap.font.size = 33
  77.         # ……字体设置……
  78.  
  79.         str = "文字测试"
  80.         buf = "\0" * 8
  81.         api.call(bitmap.__id__, str.__id__, -1, buf.__id__)
  82.  
  83.  
  84. TB_draw_text_rect/xywh        
  85. 功  能:类似Bitmap#draw_text
  86.         字符串只读取符合Utf8的部分
  87.         有些字体的缺失字符描绘不同
  88.         不支持设置的 bitmap_font_color
  89.         目标区域太小时,不会缩小文本
  90.  
  91. 参  数:bitmapID         位图,Bitmap#object_id
  92.         rectID/rectXYWH  位图的目标区域,rectID 为 Rect#object_id
  93.         strID            字符串,String#object_id
  94.         cTerminate       字符串终止符,参上
  95.         fontARGB         字体颜色,无法读取到位图设置的颜色自行设置
  96.                            alpha << 24 | red << 16 | green << 8 | blue
  97.                            此值设为 0 时,渐变描绘文本,
  98.                            sLGClrID 与 anglePct 有效
  99.         sLGClrID         描述颜色渐变构成的 String#object_id,参上                           
  100.         anglePct         渐变颜色的方向,参上
  101.         option           0..7 bit 表示 align 文本对齐方式
  102.                                   对齐位置参照小键盘 1-9,超出该范围,修正为4
  103.                          8..15bit 表示描绘模式
  104.                                   0 正常描绘;非0 反选描绘
  105.  
  106.  
  107. 返回值:0    表示成功
  108.         -n   表示第n个参数错误,-100 表示 WIN32 API 调用失败
  109.                                 -101 表示 申请内存失败
  110.  
  111. 备  注:颜色alpha为0时,不进行描绘
  112.  
  113. 示  例:rect = Rect.new(-10, -10, 100, 50)
  114.         str = "文字描绘测试"
  115.         clrs = [0.0, 0xFFFF0000, 0.5, 0xFFFFFF00, 1.0, 0xFF00FF00].pack('fL'*3)
  116.         angle = 4550 (45.5)
  117.  
  118.         # 红色,水平居中,垂直居中,反描绘
  119.         api.call(bitmap.__id__, rect.__id__, str.__id__, -1, 0xFFFF0000,
  120.           0, 0, 0x0105)
  121.  
  122.         # 红-黄-蓝 逆时针45.5度,水平靠左,垂直靠上,正常描绘
  123.         api.call(bitmap.__id__, rect.__id__, str.__id__, -1, 0,
  124.           clrs.__id__, angle, 0x0007)


上面的注释在RMXP脚本编辑器内编辑的,网页显示对不齐的话,可以复制到RMXP看。
新:修复已发现BUG。

temp.png (28.15 KB, 下载次数: 1)

temp.png

TextBoard.zip

12.53 KB, 下载次数: 1

TextBoard.dll

点评

大神你把xp转换成ps了  发表于 2023-5-8 17:11
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-28 08:55

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表