March 01, 2021, 09:45:11 PM

Author Topic: [bmx] Randomly Generated Icons by GW [ 1+ years ago ]  (Read 426 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] Randomly Generated Icons by GW [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Randomly Generated Icons
Author : GW
Posted : 1+ years ago

Description : This function will create small 32x32 pinwheel style graphic for use as an icon or anything else.

Code :
Code: BlitzMax
  1. SuperStrict
  2. Framework brl.glmax2d
  3. Import brl.basic
  4. AppTitle = "Hit space for more icons"
  5. Graphics 320,240
  6.  
  7. While Not KeyHit( key_escape)
  8.         Cls
  9.                 DrawImage(makeIcon(),0,0)'x*32,y*32)
  10.         Flip
  11.         WaitKey
  12. Wend
  13.  
  14.  
  15.  
  16. Function makeIcon:TImage()
  17.         For Local i% = 0 Until 50
  18.                 Local x% = Rand(-5,50)
  19.                 Local y% = Rand(-5,50)
  20.                 SetColor(Rand(255),Rand(255),Rand(255))
  21.                 SetRotation Rand(300)
  22.                 SetLineWidth(Rand(1,2))
  23.                 Select i Mod 3
  24.                         Case 0
  25.                                 DrawRect(x,y,Rand(20),Rand(20))
  26.                         Case 1
  27.                                 DrawOval(x,y,Rand(20),Rand(20))
  28.                         Case 2
  29.                                 DrawLine(x,y,Rand(64),Rand(64))
  30.                 End Select
  31.         Next
  32.        
  33.         SetColor(255,255,255)
  34.         SetRotation 0
  35.         SetLineWidth 1
  36.        
  37.         Local img:TImage = CreateImage(16,16,1,0) ;  GrabImage(img, 0,0)
  38.         SetImageHandle img, 16,16
  39.  
  40.         For Local j% = 0 Until 360/4
  41.                 SetRotation (360/4)*j
  42.                 DrawImage(img,16,16)
  43.         Next
  44.  
  45.         SetRotation 0
  46.         Local outimg:TImage = CreateImage(32,32,1,0)
  47.         GrabImage(outimg,0,0)
  48.         Cls
  49.         Return outimg
  50. End Function


Comments :


Bobysait(Posted 1+ years ago)

 Nice code !ps : You should not put a waitkey and a keyhit() for exitthe program can't be closed while the keys are consumed before the Keyhit(escape) is checked.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal