4

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

私が間違っていることについてのアイデアはありますか?2 番目のスクリプトは、最初のスクリプトと機能的に同等であるべきではありませんか?

ありがとう。

4

1 に答える 1

3

Cyphre (Richard Smolak) が AltMe で私の質問に答えました。要約すると、 bind ではなく bind/only を実行する必要がありまし。彼はまた、不要な構成を削除するなど、私の例をクリーンアップしました。以下の彼の完全な応答を参照してください。

ddharing: コード スニペットの作業バージョンは次のとおりです。

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にあります。

于 2014-01-10T14:41:14.060 に答える