![]()
|
User Interface Extension Library Usage Example 5.This example demonstrates the usage of clipping path and different fill styles. Here are some screenshots of the exsample dialog box:
The preview is built by the following code: SUB BuildPreview cx&=315 ' Preview window dimensions in pixels cy&=79 s$=Sample IF s$="" THEN s$=Font$ ' If sample string is empty, display font name instead BeginImage cx,cy,WHITE ' Create an empty image in memory ImageBeginPath ImageGetTextSize s$,x&,y&,Font,Size,400+300*Bold,Italic,FALSE,FALSE ' Calculate the string size in pixels (returned in X& and Y&). Required to center the string ImageTextOut s$,(cx-x)\2,(cy-y)\2,Font,Size,400+300*Bold,Italic,FALSE,FALSE,0 ' Draw the text string in the center of image ImageEndPath ImageSavePath ImageSelectClipPath RGN_COPY ImageGetClipBox x1&,y1&,x2&,y2& SELECT CASE FillType CASE 1 ' Uniform ImageSolidFill ColorVal(Color1) ImageFillRectEx x1,y1,x2,y2 CASE 2 ' Fountain Stp&=31 r1&=ColorVal(Color1) AND 255 g1&=(ColorVal(Color1)\256) AND 255 b1&=(ColorVal(Color1)\65536) AND 255 r2&=ColorVal(Color2) AND 255 g2&=(ColorVal(Color2)\256) AND 255 b2&=(ColorVal(Color2)\65536) AND 255 FOR i&=0 to Stp ImageFillRect x1+(x2-x1)*i\Stp,y1,x1+(x2-x1)*(i+1)\Stp,y2, \\ RGB(r1+(r2-r1)*i\Stp,g1+(g2-g1)*i\Stp,b1+(b2-b1)*i\Stp) NEXT i CASE 3 ' Hatch ImageHatchFill HatchType,ColorVal(Color2) ImageFillRectEx x1,y1,x2,y2 CASE 4 ' Bitmap ImageBitmapFill Bitmap ImageFillRectEx x1,y1,x2,y2 END SELECT ImageResetClipRegion ImageLoadPath ImageStrokePath 1,BLACK EndImage ImageFile$ ' Save the image to file and free memory MainDialog.Preview.SetImage ImageFile ' Display the image in dialog box IMAGE control END SUB
[ <Previous page | Next Page> ] |
Copyright © 2000 by Alex Vakulenko. All rights reserved.
|