扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 147|回复: 0

[转载发布] 填坑 TextBoard1.0

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    5 小时前
  • 签到天数: 114 天

    连续签到: 4 天

    [LV.6]常住居民II

    2338

    主题

    403

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10622
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13391

    灌水之王

    发表于 2024-4-19 16:57:33 | 显示全部楼层 |阅读模式
    RUBY 代码
    [code]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

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-3-14 23:56 , Processed in 0.085010 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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