【问题标题】:Rebol 3 text rendering issue using GOBs使用 GOB 的 Rebol 3 文本渲染问题
【发布时间】:2014-01-05 15:30:36
【问题描述】:

我试图在较低级别更好地理解 Rebol 3 图形(即不使用 R3-GUI)。我在绘制绘图块中呈现文本时遇到问题。

这行得通:

REBOL []

par: make system/standard/para []

gob-svg: make gob! [ ;this GOB is just for SVG graphics
    offset: 0x0
    size: 640x480
    draw: none
]

rt: bind/only [
    size 18 para par text "This is a test!"
] import 'text

gob-svg/draw: bind compose/only [
    box 20x20 50x50 1 text 100x100 640x480 anti-aliased rt
] import 'draw 

view gob-svg

这不起作用:

REBOL []

par: make system/standard/para []

gob-svg: make gob! [ ;this GOB is just for SVG graphics
    offset: 0x0
    size: 640x480
    draw: none
]

gob-svg/draw: bind compose/only [
    box 20x20 50x50 1 text 100x100 640x480 anti-aliased (
        bind/only compose [
            size 18 para (par) text "This is a test!"
        ] import 'text
    )
] import 'draw

view gob-svg

关于我做错了什么有什么想法吗?第二个脚本不应该在功能上等同于第一个吗?

谢谢。

【问题讨论】:

    标签: svg rebol rebol3


    【解决方案1】:

    Cyphre (Richard Smolak) 在 AltMe 上回答了我的问题。总结是我应该做一个 bind/only 而不是一个 bind。他还清理了我的示例,例如消除了不必要的组合。请参阅下面的完整回复:

    ddharing:这是您的代码 sn-p 的工作版本:

    par: make system/standard/para []
    
    gob-svg: make gob! [;this GOB is just for SVG graphics
        offset: 0x0
        size: 640x480
        draw: none
    ]
    
    gob-svg/draw: bind/only compose/only [
        box 20x20 50x50 1
        text 100x100 640x480 vectorial (
            bind [
                size 18
                para par
                text "This is a test!"
            ] import 'text
        )
    ] import 'draw
    
    view gob-svg
    

    为了更轻松地对 DRAW 块进行预处理,我建议使用我包含在 R3-GUI 中的方言预处理器。见这里:https://github.com/saphirion/r3-gui/blob/master/source/gfx-pre.r3

    此代码也可以独立于 r3-gui 工作...只需在实际代码之前执行 gfx-pre.r3 脚本,然后您就可以使用 TO-TEXT 和 TO-DRAW 函数以方便您使用。

    绘图预处理器使用“经典”DRAW 方言语法(无需使用命令!直接调用),因此您的代码示例可能如下所示:

    do %gfx-pre.r3
    
    par: make system/standard/para []
    
    gob-svg: make gob! [;this GOB is just for SVG graphics
        offset: 0x0
        size: 640x480
        draw: none
    ]
    
    gob-svg/draw: to-draw [
        box 20x20 50x50
        text 100x100 640x480 vectorial [
            size 18
            para par
            "This is a test!"
        ]
    ] copy []
    
    view gob-svg
    

    R3 DRAW 方言语法的参考可以在这里找到:http://www.rebol.com/r3/docs/view/draw.html

    【讨论】:

      猜你喜欢
      • 2021-07-29
      • 2010-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-13
      相关资源
      最近更新 更多