Hi,
( Thats a special for Jeff O'Brien )
This tiny step-by-step example will draw a word with
alignment (left, center, right) and very high text quality
on screen.
Works with subpixel precision by interpolation
through scaling down (oversampling).
Greetings, Stephan Stoske
----------------------------------------------------------------
(REALbasic new project)
Step 1: Popup-Menu "alignPop" with "left, center, right"
In his change event: Redraw
Step 2: Popup-Menu "resPop" with "1x1, 2x2, 3x3, 4x4"
In his change event: Redraw
Step 3: Canvas "view" with size of 200 x 100 pixel
In his paint event: g.drawpicture buffer, 0, 0
Step 4: Create propertie "buffer" as picture
Step 5: In window open event: Redraw
Last Step: Create redraw method:
dim x, y, w, h, s as integer
dim word as string
dim gr as graphics
word = "Leberwurst"
s = resPop.listIndex + 1
buffer = newPicture( 200 * s, 100 * s, 32 )
gr = buffer.graphics
gr.foreColor = rgb( 255, 255, 255 )
gr.fillrect 0, 0, 200 * s, 100 * s
gr.foreColor = rgb( 0, 0, 0 )
gr.textFont = "Verdana"
gr.textSize = 18 * s
w = gr.stringWidth( word )
h = gr.textHeight
y = ( 100 * s - h ) / 2 + gr.textAscent
select case alignPop.listindex
case 0 // left
x = 0
case 1 // center
x = ( 200 * s - w ) / 2
case 2 // right
x = 200 * s - w
end select
gr.drawString word, x, y
view.graphics.drawpicture buffer, 0, 0, 200, 100, 0, 0, 200 * s, 100 * s
----------------------------------------------------------------
-------------------------------------------------------------------------
stoske & bertling - visuelle kommunikation
lohmühler berg 30 - 42553 velbert - fon 02053/504464 - fax 02053/923630
info at stoske-bertling dot de - www.stoske-bertling.de - ftp.stoske-bertling.de
|