Code: Alles auswählen
OpenWindow(0, 0,0, 800,600, "dot glow test", #PB_Window_ScreenCentered|#PB_Window_TitleBar|#PB_Window_SystemMenu)
Global pxsize.w ;größe eines pixels beim einzeichnen
Global h.w, w.w ;größe des leuchtradius
Global zx.l, zy.l ;counter
Global *sintable_x.float ;sinustabelle auf x
Global *sintable_y.float ;sinustabelle auf y
Global *st_x.float
Global *st_y.float
Global degstep.f ;winkel-schritt, der pro pixel beim vorberechnen der sinus-tabelle gemacht wird
Global alpha.f
Global pxcolor.l, r.c, g.c, b.c
Global event.l
;------------------------------
w = 21
h = 21
pxsize = 5
pxcolor = $ff00
;{ create table per runtime
If *sintable_x > 0: FreeMemory(*sintable_x): *sintable_x = 0 :EndIf
If *sintable_y > 0: FreeMemory(*sintable_y): *sintable_y = 0 :EndIf
*sintable_x = AllocateMemory(w * SizeOf(float))
*sintable_y = AllocateMemory(h * SizeOf(float))
*st_x = *sintable_x
degstep = #PI / (w + 1)
For zx = 1 To w
*st_x\f = Sin(zx * degstep) - 0.5
*st_x + SizeOf(float)
Next
*st_y = *sintable_y
degstep = #PI / (h + 1)
For zy = 1 To h
*st_y\f = Sin(zy * degstep) - 0.5
*st_y + SizeOf(float)
Next
;}
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Repaint
;{ draw
StartDrawing(WindowOutput(0))
Box(0,0, WindowWidth(0),WindowHeight(0), $000000)
*st_y = *sintable_y
For zy = 1 To h
*st_x = *sintable_x
For zx = 1 To w
; If *st_x\f > 1.0 Or *st_y\f > 1.0
alpha = *st_x\f + *st_y\f
If alpha > 0.0
r = Red (Point(zx,zy)) * (1.0 - alpha) + Red (pxcolor) * alpha
g = Green(Point(zx,zy)) * (1.0 - alpha) + Green(pxcolor) * alpha
b = Blue (Point(zx,zy)) * (1.0 - alpha) + Blue (pxcolor) * alpha
Box(zx*pxsize,zy*pxsize,pxsize,pxsize, r + g << 8 + b << 16)
EndIf
*st_x + SizeOf(float)
Next
*st_y + SizeOf(float)
Next
StopDrawing()
;}
EndIf
Until event = #PB_Event_CloseWindow
- lässt sich leicht abwandeln und für andere Zwecke missbrauchen
- Leicht einzubinden

Nagut, ich geb zu dass der Kreis nicht ganz rund ist, aber bei Leuchteffekten ist das ja relativ unwichtig, wie ich finde
