March 01, 2021, 09:56:02 PM

Author Topic: [bb] Curved Text (part 2) by Andy_A [ 1+ years ago ]  (Read 462 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Curved Text (part 2) by Andy_A [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Curved Text (part 2)
Author : Andy_A
Posted : 1+ years ago

Description : This snippet runs as is, but you'll need the Curved Text routines (in part 1) to use the new functions with your own images and programs.

New Functions:
makeData() - save an image to a data text file that can be cut and pasted into your code

getImgData() - reads the image stored in data statements into memory for further processing

data2buffer() - reads the image stored in data statements and creates an image in a Blitz image buffer. You can rotate at 0, 90, 180, and 270 degrees when storing in a Blitz image buffer. Correct buffer dimensions are handled in the function. Now you can use just like any other image that you load from an external file (bmp, png, etc...).

dat2curv2buf() - reads the image stored in data statements, fits the image around a curve, and creates an image in a Blitz image buffer.

Simple usage example included.


Code :
Code: BlitzBasic
  1. ;     Title: Blitz RLE Vector Data To Buffer Demo
  2. ;Programmer: Andy Amaya
  3. ;      Date: 2004.03.25
  4. ;   Version: 1.08-Added dat2curv2buf() function
  5. ;    Update: 1.07-Added data2buffer() function
  6. ;    Update: 1.06-Added makeData() and getImgData() functions
  7. ;    Update: 1.05-Lock & UnLock buffer to use ReadPixelFast (does NOT work in B2D)
  8. ;    Update: 1.04-Added constants to support use with 16 bit color cards
  9. ;    Update: 1.03-Added curveImg Routine
  10. ;    Update: 1.01-Added maskImg, replaceColor, maskAndReplace routines
  11. ;    Update: 1.00-Original RLE image routine
  12.  
  13. AppTitle "Blitz Run Length Encoded Vector Data To Image Buffer"
  14.  
  15. Global sw% = 800
  16. Global sh% = 600
  17. Global cd% = 32 ;<--------------- Color depth
  18.  
  19. Graphics sw, sh , cd, 2
  20. SetBuffer BackBuffer()
  21.  
  22. Dim vecs(1) ;vector array (true dimension size in image data)
  23. Dim pal%(1)     ;Color palette array (true dimension size in image data)
  24.  
  25. ;========== masking constants for 32 bit color =========
  26.         Global maskRed% = 16711680
  27.         Global maskGrn% = 65280
  28.         Global maskBlu% = 255
  29. ;=======================================================
  30.  
  31. ;========= masking constants for 16 bit (5-6-5) ========
  32. ;       Global maskRed% = 16252928
  33. ;       Global maskGrn% = 64512 ;change to 63488 for (5-5-5)
  34. ;       Global maskBlu% = 248
  35. ;=======================================================
  36.  
  37. Arial18b%  = LoadFont("Arial",18,True)
  38.  
  39. st = MilliSecs()
  40. SetFont arial18b
  41. Color 0, 128, 255
  42. Rect 0, 0, sw-1, sh-1, True
  43.  
  44.  
  45. ;use "Data to Image Buffer" image data statements
  46. Restore data2buf
  47. ;Get text image and store in gfxMsg0 image buffer
  48.   gfxMsg0 = data2buffer(0)
  49.  
  50. ;use "Data to Image Buffer" image data statements
  51. Restore data2buf
  52. ;Get text image and store in gfxMsg90 image buffer
  53.  gfxMsg90 = data2buffer(90)
  54.  
  55. ;use "Data to Image Buffer" image data statements
  56. Restore data2buf
  57. ;Get text image and store in gfxMsg180 image buffer
  58. gfxMsg180 = data2buffer(180)
  59.  
  60. ;use "Data to Image Buffer" image data statements
  61. Restore data2buf
  62. ;Get text image and store in gfxMsg270 image buffer
  63. gfxMsg270 = data2buffer(270)
  64.  
  65. ;use "Data to Image Buffer" image data statements
  66. Restore data2buf
  67. ;Get text image, make it curved  and store in gfxCurve image buffer
  68. gfxCurve = dat2curv2buf(125, 115.0, 310.0, 3, 255, 0, 0)
  69.  
  70. ;use yellow "gradient" image data statements
  71. Restore gradient
  72. ;Get gradient image, flip to 180 degrees and store in gfxGrad image buffer
  73. gfxGrad = data2buffer(180)
  74.  
  75.  
  76.  
  77. DrawBlock(  gfxMsg0, 227, 100)
  78. DrawBlock( gfxMsg90, 227+305, 140)
  79. DrawBlock(gfxMsg180, 227, 485)
  80. DrawBlock(gfxMsg270, 227, 140)
  81.  
  82. DrawBlock(gfxGrad,267,140)
  83.  
  84. MaskImage gfxCurve, 255, 0, 0
  85. DrawImage(gfxCurve, 400-125, 320-125)
  86.  
  87. et = MilliSecs() - st
  88.  
  89. Color 128,255,255
  90.  
  91. Text 0, 0, "To read in one text image from data statements four times at  0, 90, 180, and 270 degrees."
  92. Text 0, 32, "Read in a gradient image from data statements."
  93. Text 0, 16, "Read in the same text image from data statements one more time, and wrap around a curve."
  94. Text 0, 48, "Store all six images in separate Blitz image buffers."
  95. Text 0, 64, "And then to display all six newly created image buffers on the screen."
  96. Text 0, 80, "Takes "+et+" milliseconds."
  97.  
  98. Text 0, 112, "(The text image was a 41K bmp,"
  99. Text 0, 128, "it was reduced to a 9K text file."
  100. Text 0, 160, "The gradient image was a 274K"
  101. Text 0, 176, "bmp, it was reduced to a 5K"
  102. Text 0, 192, "text file. )"
  103.  
  104.  
  105.  
  106.  
  107.  
  108. Text 10,570,"click to exit"
  109.  
  110.  
  111. Flip
  112. WaitMouse()
  113.  
  114. FreeFont Arial18b
  115.  
  116. FreeImage gfxMsg0
  117. FreeImage gfxMsg90
  118. FreeImage gfxMsg180
  119. FreeImage gfxMsg270
  120. FreeImage gfxGrad
  121. FreeImage gfxCurve
  122.  
  123. .data2buf ;image data for "Data to Image Buffer" text on red background - 345x40
  124. Data 345,40,3994,5
  125. Data -65536,-32897,-1,-16449,-24673
  126. Data 345,0,345,0,345,0,345,0,345,0,345,0,345,0,5,0,1,1,11,2,1,3,1,4,1,1,113,0,1,1,5,2,104,0,1,1,13,2,1,3,1,4,1,1,31,0,1,4,1,3,3,2,1,3,1,4,1,1,4,0,1,4,1,3,3,2,1,3,1,4,1,1,34,0,5,0,1,1,14,2,1,3,1,1,32,0
  127. Data 1,1,1,3,39,0,1,1,1,3,36,0,1,1,4,2,1,3,104,0,1,1,16,2,1,3,29,0,1,3,8,2,3,0,1,3,8,2,34,0,5,0,1,4,16,2,1,1,30,0,1,3,1,2,1,3,38,0,1,3,1,2,1,3,36,0,1,4,4,2,1,4,104,0,1,4,17,2,1,3,27,0,1,4,8,2,1,3,2,0,1,4
  128. Data 8,2,1,3,34,0,5,0,1,3,17,2,1,1,27,0,1,4,3,2,1,3,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1,3,4,2,1,1,12,0,1,0,12,2,2,3,1,4,1,1,11,0,1,1,1,3,3,2,1,3,1,4,1,1,1,0,5,2,1,1,5,0,1,1,1,3,4,2,1,3,4,0,1,1,1,3,3,2,1,3,1,4,1,1,1,0,5,2,1,1,15,0
  165. Data 1,1,1,3,4,2,1,3,7,0,1,1,1,4,1,3,3,2,2,3,1,4,17,0,5,2,1,1,4,0,5,2,1,1,5,0,5,2,1,1,5,0,5,2,1,1,5,0,1,1,1,3,3,2,1,3,1,4,1,1,1,0,5,2,1,1,6,0,1,4,1,3,3,2,1,3,1,1,1,0,5,2,9,0,1,1,1,3,4,2,1,3,1,4,16,0,15,2
  166. Data 1,3,1,4,1,1,9,0,1,1,1,3,3,2,1,3,1,1,2,0,5,2,5,0,5,2,1,1,6,0,5,2,1,1,10,0,1,1,1,3,4,2,1,3,1,4,6,0,5,2,1,1,12,0,200,0,1,1,4,2,1,3,139,0,189,0,1,2,3,3,1,4,6,0,1,3,4,2,1,4,139,0,189,0,5,2,1,4,1,1,2,0
  167. Data 1,1,1,4,5,2,1,1,139,0,189,0,1,3,14,2,1,3,140,0,189,0,1,1,14,2,1,1,140,0,190,0,1,4,11,2,1,3,1,1,141,0,192,0,1,4,1,3,5,2,2,3,1,1,143,0,345,0
  168.  
  169. .gradient ;image data for black to yellow gradient - 265x345
  170. Data 265,345,690,255
  171. Data -256,-66048,-131840,-197632,-263424,-329216,-395008,-460800,-526592,-592384,-658176,-723968,-789760,-855552,-921344,-987136,-1052928,-1118720,-1184512,-1250304,-1316096,-1381888,-1447680,-1513472
  172. Data -1579264,-1645056,-1710848,-1776640,-1842432,-1908224,-1974016,-2039808,-2105600,-2171392,-2237184,-2302976,-2368768,-2434560,-2500352,-2566144,-2631936,-2697728,-2763520,-2829312,-2895104,-2960896
  173. Data -3026688,-3092480,-3158272,-3224064,-3289856,-3355648,-3421440,-3487232,-3553024,-3618816,-3684608,-3750400,-3816192,-3881984,-3947776,-4013568,-4079360,-4145152,-4210944,-4276736,-4342528,-4408320
  174. Data -4474112,-4539904,-4605696,-4671488,-4737280,-4803072,-4868864,-4934656,-5000448,-5066240,-5132032,-5197824,-5263616,-5329408,-5395200,-5460992,-5526784,-5592576,-5658368,-5724160,-5789952,-5855744
  175. Data -5921536,-5987328,-6053120,-6118912,-6184704,-6250496,-6316288,-6382080,-6447872,-6513664,-6579456,-6645248,-6711040,-6776832,-6842624,-6908416,-6974208,-7040000,-7105792,-7171584,-7237376,-7303168
  176. Data -7368960,-7434752,-7500544,-7566336,-7632128,-7697920,-7763712,-7829504,-7895296,-7961088,-8026880,-8092672,-8158464,-8224256,-8290048,-8355840,-8421632,-8487424,-8553216,-8619008,-8684800,-8750592
  177. Data -8816384,-8882176,-8947968,-9013760,-9079552,-9145344,-9211136,-9276928,-9342720,-9408512,-9474304,-9540096,-9605888,-9671680,-9737472,-9803264,-9869056,-9934848,-10000640,-10066432,-10132224,-10198016
  178. Data -10263808,-10329600,-10395392,-10461184,-10526976,-10592768,-10658560,-10724352,-10790144,-10855936,-10921728,-10987520,-11053312,-11119104,-11184896,-11250688,-11316480,-11382272,-11448064,-11513856
  179. Data -11579648,-11645440,-11711232,-11777024,-11842816,-11908608,-11974400,-12040192,-12105984,-12171776,-12237568,-12303360,-12369152,-12434944,-12500736,-12566528,-12632320,-12698112,-12763904,-12829696
  180. Data -12895488,-12961280,-13027072,-13092864,-13158656,-13224448,-13290240,-13356032,-13421824,-13487616,-13553408,-13619200,-13684992,-13750784,-13816576,-13882368,-13948160,-14013952,-14079744,-14145536
  181. Data -14211328,-14277120,-14342912,-14408704,-14474496,-14540288,-14606080,-14671872,-14737664,-14803456,-14869248,-14935040,-15000832,-15066624,-15132416,-15198208,-15264000,-15329792,-15395584,-15461376
  182. Data -15527168,-15592960,-15658752,-15724544,-15790336,-15856128,-15921920,-15987712,-16053504,-16119296,-16185088,-16250880,-16316672,-16382464,-16448256,-16514048,-16579840,-16645632,-16711424
  183. Data 265,0,265,1,265,1,265,2,265,3,265,4,265,4,265,5,265,6,265,7,265,7,265,8,265,9,265,10,265,10,265,11,265,12,265,13,265,13,265,14,265,15,265,16,265,16,265,17,265,18,265,18,265,19,265,20,265,21,265,21
  184. Data 265,22,265,23,265,24,265,24,265,25,265,26,265,27,265,27,265,28,265,29,265,30,265,30,265,31,265,32,265,32,265,33,265,34,265,35,265,35,265,36,265,37,265,38,265,38,265,39,265,40,265,41,265,41,265,42
  185. Data 265,43,265,44,265,44,265,45,265,46,265,47,265,47,265,48,265,49,265,49,265,50,265,51,265,52,265,52,265,53,265,54,265,55,265,55,265,56,265,57,265,58,265,58,265,59,265,60,265,61,265,61,265,62,265,63
  186. Data 265,63,265,64,265,65,265,66,265,66,265,67,265,68,265,69,265,69,265,70,265,71,265,72,265,72,265,73,265,74,265,75,265,75,265,76,265,77,265,78,265,78,265,79,265,80,265,80,265,81,265,82,265,83,265,83
  187. Data 265,84,265,85,265,86,265,86,265,87,265,88,265,89,265,89,265,90,265,91,265,92,265,92,265,93,265,94,265,94,265,95,265,96,265,97,265,97,265,98,265,99,265,100,265,100,265,101,265,102,265,103,265,103,265,104
  188. Data 265,105,265,106,265,106,265,107,265,108,265,109,265,109,265,110,265,111,265,111,265,112,265,113,265,114,265,114,265,115,265,116,265,117,265,117,265,118,265,119,265,120,265,120,265,121,265,122,265,123
  189. Data 265,123,265,124,265,125,265,125,265,126,265,127,265,128,265,128,265,129,265,130,265,131,265,131,265,132,265,133,265,134,265,134,265,135,265,136,265,137,265,137,265,138,265,139,265,140,265,140,265,141
  190. Data 265,142,265,142,265,143,265,144,265,145,265,145,265,146,265,147,265,148,265,148,265,149,265,150,265,151,265,151,265,152,265,153,265,154,265,154,265,155,265,156,265,156,265,157,265,158,265,159,265,159
  191. Data 265,160,265,161,265,162,265,162,265,163,265,164,265,165,265,165,265,166,265,167,265,168,265,168,265,169,265,170,265,171,265,171,265,172,265,173,265,173,265,174,265,175,265,176,265,176,265,177,265,178
  192. Data 265,179,265,179,265,180,265,181,265,182,265,182,265,183,265,184,265,185,265,185,265,186,265,187,265,187,265,188,265,189,265,190,265,190,265,191,265,192,265,193,265,193,265,194,265,195,265,196,265,196
  193. Data 265,197,265,198,265,199,265,199,265,200,265,201,265,202,265,202,265,203,265,204,265,204,265,205,265,206,265,207,265,207,265,208,265,209,265,210,265,210,265,211,265,212,265,213,265,213,265,214,265,215
  194. Data 265,216,265,216,265,217,265,218,265,218,265,219,265,220,265,221,265,221,265,222,265,223,265,224,265,224,265,225,265,226,265,227,265,227,265,228,265,229,265,230,265,230,265,231,265,232,265,233,265,233
  195. Data 265,234,265,235,265,235,265,236,265,237,265,238,265,238,265,239,265,240,265,241,265,241,265,242,265,243,265,244,265,244,265,245,265,246,265,247,265,247,265,248,265,249,265,249,265,250,265,251,265,252
  196. Data 265,252,265,253,265,254
  197.  
  198. End
  199.  
  200. Function makeData(dataFile$, imgWidth%, imgHeight%)
  201.         ;=======================================================
  202.         ;approximate length of characters per data statement for
  203.         ;palette data and image data
  204.         ;longer data lines take up less room overall
  205.         dataLen%  = 200
  206.         ;=======================================================
  207.         vCount%   = 0
  208.         pal(0)    = vecs(1)
  209.         clrCount% = 1
  210.         idx%      = 0
  211.     For i% = 1 To imgHeight
  212.                 lineLen% = 0
  213.         While lineLen < imgWidth
  214.                         vLen% = vecs(vCount)
  215.                         vClr% = vecs(vCount + 1)
  216.                         lineLen = lineLen + vLen
  217.                         ;build the list of palette colors in the pal() array
  218.                         colorExists% = 0
  219.                         For j% = 1 To clrCount
  220.                                 ;if the current color already exists
  221.                                 ;don't look any further, exit the loop
  222.                                 If pal(j-1) = vClr Then
  223.                                     colorExists = 1
  224.                                         Exit
  225.                                 End If
  226.                         Next
  227.                         ;if we didn't find an existing color then add to pal() array then
  228.                         ;increment the number of colors in the image and add to pal() array
  229.                         If colorExists = 0 Then
  230.                                 idx = idx + 1
  231.                                 clrCount = clrCount + 1
  232.                                 pal(idx) = vClr
  233.                         End If
  234.                         colorExists = 0
  235.                         ;increment the vector counter                  
  236.             vCount = vCount+2
  237.         Wend
  238.     Next
  239.     hiCount% = vCount ; + 2 ;extra two elements, just in case ;)
  240.         fileOut% = WriteFile(dataFile$)
  241.     ;Save the width and height of the image followed by largest number of
  242.         ;vectors in a raster line in the image and the number of unique
  243.         ;colors to dimension vec() array and pal() array in main program
  244.         dat$ = "Data "+Str(imgWidth)+","+Str(imgHeight)+","+Str(hiCount)+","+Str(clrCount)
  245.     WriteLine(fileOut, dat$)
  246.         ;Now write the palette table into the text data file
  247.         dat$ = "Data "
  248.         For idx = 0 To clrCount-1
  249.                 dat$ = dat$ + Str(pal(idx))+","
  250.                 If Len(dat$) > dataLen Then
  251.                         dat$= Left$(dat$,Len(dat$)-1)
  252.                         WriteLine(fileOut, dat$)
  253.                         dat$ = "Data "
  254.                 End If
  255.         Next
  256.         If Right$(dat$,1) = "," Then
  257.                 dat$ = Left$(dat$, Len(dat$)-1)
  258.             WriteLine(fileOut, dat$)
  259.         Else
  260.                 If dat$ <> "Data " Then WriteLine(fileOut, dat$)
  261.         End If
  262.  
  263.         ;All set to go, let's start writing data to disk!
  264.     dat$ = "Data "
  265.         vCount = 0
  266.         For i = 1 To imgHeight
  267.                 lineLen = 0
  268.                 While lineLen < imgWidth
  269.                         lineLen = lineLen + vecs(vCount)
  270.                         For j% = 0 To clrCount-1
  271.                                 If vecs(vCount + 1) = pal(j) Then
  272.                                         idx = j
  273.                                         Exit
  274.                                 End If
  275.                         Next
  276.                         dat$ = dat$ + Str(vecs(vCount))+","+Str(idx)+","
  277.                         If Len(dat$) > dataLen Then
  278.                                 dat$ = Left$(dat$,Len(dat$)-1)
  279.                                 WriteLine(fileOut, dat$)
  280.                                 dat$ = "Data "
  281.                         End If
  282.                         vCount = vCount + 2
  283.                 Wend
  284.     Next
  285.         If dat$ <> "Data " Then
  286.                 If Right$(dat$,1) = "," Then
  287.                         dat$ = Left$(dat$,Len(dat$)-1)
  288.                     WriteLine(fileOut, dat$)
  289.                 Else
  290.                     WriteLine(fileOut, dat$)
  291.                 End If
  292.         End If
  293.     CloseFile fileOut
  294. End Function
  295.  
  296. Function getImgData%()
  297.     Read imgWidth
  298.     Read imgHeight
  299.         Read numVecs
  300.         Read palSize
  301.     Dim vecs(numVecs)
  302.         Dim pal(palSize-1)
  303.         For i = 0 To palSize-1
  304.                 Read pal(i)
  305.         Next
  306.         ras = 1
  307.         lineLen = 0
  308.         vCount = 0
  309.         While ras <= imgHeight
  310.                 Read vecLen
  311.                 Read idx
  312.                 vecs(vCount) = vecLen
  313.                 vecs(vCount+1) = pal(idx)
  314.                 lineLen = lineLen + vecLen
  315.                 vCount = vCount + 2
  316.                 If lineLen >= imgWidth Then
  317.                         lineLen = 0
  318.                         ras = ras + 1
  319.                 End If
  320.         Wend
  321. End Function
  322.  
  323. Function data2buffer%(displayAngle%)
  324.         If displayAngle = 0 Or displayAngle = 90 Or displayAngle = 180 Or displayAngle = 270 Then
  325.                 Read imgWidth%
  326.             Read imgHeight%
  327.                 Read numVecs%
  328.                 Read palSize%
  329.             Dim vecs(numVecs)
  330.                 Dim pal(palSize-1)
  331.                 For i% = 0 To palSize-1
  332.                         Read pal(i)
  333.                 Next
  334.                 ras% = 1
  335.                 vCount% = 0
  336.                 lineLen% = 0
  337.                 While ras <= imgHeight
  338.                         Read vecLen%
  339.                         Read idx%
  340.                         vecs(vCount) = vecLen
  341.                         vecs(vCount+1) = pal(idx)
  342.                         lineLen = lineLen + vecLen
  343.                         If lineLen = imgWidth Then
  344.                                 lineLen = 0
  345.                                 ras = ras + 1
  346.                         End If
  347.                         vCount = vCount + 2
  348.                 Wend
  349.                 Select displayAngle
  350.                         Case   0
  351.                                 newWidth%  = imgWidth
  352.                                 newHeight% = imgHeight
  353.                                 x% = 0
  354.                                 y% = 0
  355.                         Case  90
  356.                                 newWidth%  = imgHeight
  357.                                 newHeight% = imgWidth
  358.                                 x% = newWidth-1
  359.                                 y% = 0
  360.                         Case 180
  361.                                 newWidth%  = imgWidth
  362.                                 newHeight% = imgHeight
  363.                                 x% = imgWidth-1
  364.                                 y% = imgHeight-1
  365.                         Case 270
  366.                                 newWidth%  = imgHeight
  367.                                 newHeight% = imgWidth
  368.                                 x% = 0
  369.                                 y% = newHeight-1
  370.                 End Select
  371.                 imgTemp% = CreateImage(newWidth, newHeight)
  372.                 SetBuffer ImageBuffer(imgTemp)
  373.         angle2% = displayAngle + 90
  374.                 vCount = 0
  375.         For i = 1 To imgHeight
  376.             p# = Cos(angle2)*(i-1)+x
  377.             q# = Sin(angle2)*(i-1)+y
  378.                         lineLen = 0
  379.             While lineLen < imgWidth
  380.                             vecLen% = vecs(vCount)
  381.                                 lineLen = lineLen + vecLen
  382.                     red = (vecs(vCount + 1) And maskRed) Shr 16
  383.                 grn = (vecs(vCount + 1) And maskGrn) Shr 8
  384.                     blu =  vecs(vCount + 1) And maskBlu
  385.                 Color red,grn,blu
  386.                             r# = Cos(displayAngle)*vecLen+p
  387.                             s# = Sin(displayAngle)*vecLen+q
  388.                             Line p,q,r,s
  389.                 vCount = vCount+2
  390.                             p=r
  391.                             q=s
  392.             Wend
  393.         Next
  394.             SetBuffer BackBuffer()
  395.                 Return imgTemp
  396.         Else
  397.                 Return 0
  398.         End If
  399. End Function
  400.  
  401. Function dat2curv2buf(radius%, startAngle#, arcSegment#, penSize%, bkR%, bkG%, bkB%)
  402.         Read imgWidth%
  403.     Read imgHeight%
  404.         Read numVecs%
  405.         Read palSize%
  406.     Dim vecs(numVecs)
  407.         Dim pal(palSize-1)
  408.         For i% = 0 To palSize-1
  409.                 Read pal(i)
  410.         Next
  411.         ras% = 1
  412.         vCount% = 0
  413.         lineLen% = 0
  414.         While ras <= imgHeight
  415.                 Read vecLen%
  416.                 Read idx%
  417.                 vecs(vCount) = vecLen
  418.                 vecs(vCount+1) = pal(idx)
  419.                 lineLen = lineLen + vecLen
  420.                 If lineLen = imgWidth Then
  421.                         lineLen = 0
  422.                         ras = ras + 1
  423.                 End If
  424.                 vCount = vCount + 2
  425.         Wend
  426.         ;Create a Blitz image buffer
  427.         diameter% = radius Shl 1
  428.         imgTemp% = CreateImage(diameter%, diameter%)
  429.         SetBuffer ImageBuffer(imgTemp)
  430.         ;Fill the background with desired color
  431.         Color bkR, bkG, bkB
  432.         Rect(0,0,diameter, diameter, True)
  433.         ;Start drawing the curved image on the image buffer
  434.         If penSize > 1 Then
  435.                 penOffset# = penSize Shr 1
  436.         End If
  437.         stepSize# = arcSegment/imgWidth
  438.         vCount = 0
  439.         centerX% = radius
  440.         centerY% = radius
  441.         For i% = 1 To imgHeight
  442.                 lineLen = 0
  443.                 arc# = startAngle
  444.                 While lineLen < imgWidth
  445.                         arcLen = vecs(vCount)
  446.                         lineLen = lineLen + arcLen
  447.                         red = (vecs(vCount + 1) And maskRed) Shr 16
  448.                         grn = (vecs(vCount + 1) And maskGrn) Shr 8
  449.                         blu =  vecs(vCount + 1) And maskBlu
  450.                         Color red, grn, blu
  451.                         arcInc# = arcLen*stepSize
  452.                         c# = arc#
  453.                         While c <= arc+arcInc
  454.                                 x = Cos(c)*radius+centerX
  455.                                 y = Sin(c)*radius+centerY
  456.                                 If penSize > 1 Then
  457.                                         Rect x-penOffset, y-penOffset, penSize, penSize, True
  458.                                 Else
  459.                                         Plot x,y
  460.                                 End If
  461.                                 c = c+stepSize
  462.                         Wend
  463.                         arc = arc+arcInc
  464.                         vCount = vCount+2
  465.                 Wend
  466.                 radius = radius - 1
  467.         Next
  468.         SetBuffer BackBuffer()
  469.         Return imgTemp 
  470. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal