Home   Archive   Permalink



Can R3's Draw Dialect handle characters?

Is there a way to add some letters to the picture I draw with the draw dialect?
e.g. draw a circle and add "rex" to the center of it.

posted by:   Rex       22-Sep-2014/11:10:09-7:00



Hi Rex
    
-1st example-
R E B O L []
    
do %r3-gui.r3
    
;gui
view [
    drawing [
        anti-alias on
        fill-pen red
        circle viewport-box/center 120
        text (as-pair 0 viewport-box/center/y) [
            center
            bold size 20 "Rex"
        ]
    ] 320x320
]
    
-2nd example-
R E B O L []
    
do %r3-gui.r3
    
;image
img-size: 320x320
    
save/all %image.png do draw make image! reduce [img-size white 0] to-draw reduce [
    'anti-alias on
    'fill-pen red
    'circle (img-size / 2) 120
    'text as-pair 0 (img-size/y / 2) [
        center
        bold size 20 "Rex"
    ]
] copy []

posted by:   Linh       22-Sep-2014/23:39:58-7:00



-3rd example-
R E B O L []
    
do %r3-gui.r3
    
size: 320x320
    
;gui use para
view [
    drawing (reduce [
        'anti-alias on
        'fill-pen red
        'circle 'viewport-box/center (size/x / 2)
        'text 0x0 reduce [
            'para make system/standard/para [
                valign: 'middle
            ]
            'center
            'bold 'size 20 "Rex"
        ]
    ]) size
]
    
-4th example-
R E B O L []
    
do %r3-gui.r3
    
;image use para
img-size: 320x320
    
save/all %image.png do draw make image! reduce [img-size white 0] to-draw reduce [
    'anti-alias on
    'fill-pen red
    'circle (img-size / 2) (img-size/x / 2)
    'text 0x0 reduce [
        'para make system/standard/para [
            valign: 'middle
        ]
        'center
        'bold 'size 20 "Rex"
    ]
] copy []

posted by:   Linh       22-Sep-2014/23:58:38-7:00



Draw document and example: http://rebol.net/wiki/Draw

posted by:   Linh       23-Sep-2014/3:15:54-7:00



I also looked for a way to do this, but didn't find anything.

posted by:   Bo       23-Sep-2014/19:47:10-7:00



Thanks, Linh. The technique is quite complicated, and I'll need some time to digest it. But I am very glad when I know this is indeed possible.

posted by:   Rex       25-Sep-2014/7:17:16-7:00