November 25, 2020, 08:34:57 AM

Author Topic: [bb] CreateCorona(width,height,curve,flag) by Streaksy [ 1+ years ago ]  (Read 550 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : CreateCorona(width,height,curve,flag)
Author : Streaksy
Posted : 1+ years ago

Description : Small bit of code to generate a masked corona texture.

Code :
Code: BlitzBasic
  1. Function CreateCorona(x=128,y=128,Curv=1,flag=11)
  2. obuf=GraphicsBuffer();RememberBuffer
  3. t=CreateTexture(x,y,flag)
  4. SetBuffer TextureBuffer(t)
  5. LockBuffer
  6. For xx=0 To x-1
  7. For yy=0 To y-1
  8. r#=LimCORONA(DistanceCORONAd(xx,yy,x/2,y/2)/(x/2),0,1)
  9. If Curv=1 Then r=Sin(r*90);curve it
  10. cc=BetweenCORONA(0,255,1-r)
  11. WritePixelFast xx,yy,RGBACORONA(255,255,255,cc)
  12. Next
  13. Next
  14. UnlockBuffer
  15. ;RecallBuffer
  16. SetBuffer obuf
  17. Return t
  18. End Function
  19. Function RGBACORONA(R,G,B,A=255)
  20. If a<0 Then Return (R*256*256)+(g*256)+b
  21. Return A Shl 24 Or R Shl 16 Or G Shl 8 Or B Shl 0
  22. End Function
  23. Function LimCORONA#(vl#,lw#,up#) ; A.K.A - Clamp
  24. If vl<lw Then Return lw
  25. If vl>up Then Return up
  26. Return vl:End Function
  27. Function DistanceCORONAd#(x1#,y1#,x2#,y2#)
  28. Return Sqr((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
  29. End Function
  30. Function BetweenCORONA#(v1#,v2#,t#):dif#=v2-v1
  31. Return v1+(dif*t)
  32. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal