Thanks Peter & Mike
Here is my code in Oxygen:
'gui-skeleton app
$ Filename "buffered.exe"
Include "RTL32.inc"
Include "awinh.inc"
#lookahead
INT fseed = 0x12345678 ' seed number
INT win
INT w,h
w=800:h=600
INT winstyle
winstyle = WS_MINMAXSIZE or WS_CLIPCHILDREN
'##### GLOBALS ###############################################
INT hdc, hdcMem, hbmMem, oldBmp, oldBrush, oldPen, oldFont, fColor
INT textX,textY,hBrush
String tBuffer
'##############################################################
'create window *************************************************
win = SetWindow("Double Buffered Window",0,0,w,h,0,winstyle)
'**************************************************************
InitDrawing()
Int n,count,fc,fb
Float ww,wh,a,b,c,x,y,j,dots,xfocus,yfocus
'set window color - dark blue
WindowColor(win,0,0,0)
xfocus = w * 0.47
yfocus = h * 0.45
again:
count = count + 1
WindowColor(win,0,0,0)
random = RAND(0,5)
FOR rep=1 TO random
' set up some random starting positions ..
a = RND2(1.0)
b = 0.9998
c = 2 - 2 * a
dots = 2000
x = 0
j = 0
y = RND2(1.0)*12 + 0.1
' calculate and draw the points ..
FOR i=0 TO dots
z = x
x = b * y + j
j = a * x + c * (x*x)/(1 + x*x)
y = j - z
xpos = x*20 + xfocus
ypos = y*20 + yfocus
rr = RAND(0,255)
gg = RAND(0,255)
bb = RAND(0,255)
fc=RGB(rr,gg,bb):fb=RGB(0,0,0)
TextColor win,fc,fb
Pset win,xpos,ypos
NEXT i
NEXT rep
if count < 5
goto again
end if
'/////////
Wait()
'\\\\\\\\\
Function WndProc (sys hwnd,wmsg,wparam,lparam) as sys callback
SELECT hwnd
'----------------------------------------
CASE win
'----------------------------------------
Select wmsg
CASE WM_CLOSE
DestroyWindow win
'Clean DC objects
CleanUp()
PostQuitMessage 0
CASE WM_SIZE
'get current size of window
GetSize(win,0,0,w,h)
int bColor = RGB(0,0,80)
FillSolidRect(win,0,0,w,h,bColor)
',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
CASE WM_PAINT
' blit the now completed screen view back to the window...
BitBlt(hDC, 0, 0, w, h, hdcMem, 0, 0, SRCCOPY)
END SELECT
END SELECT
RETURN Default
END FUNCTION
'----------------------------------------------------
'##########################################################
SUB TextColor (wID as INT,byval frontColor as sys,byval backColor as sys )
hdc = GetDC(wID)
fColor=frontColor
SetTextColor( hDC, frontColor)
SetBkColor( hDC, backColor)
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
END SUB
'########################################################
SUB TextOn(wID as INT,tx as INT,ty as INT,txt as string)
hdc = GetDC(wID)
'draw text to screen DC
TextOut hdc,tx,ty,txt,Len(txt)
'blit screen DC to memDC
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
END SUB
'-------------------------------------------------
SUB Pset (wID as int , px as int ,py as int)
hdc = GetDC(wID)
SetPixel ( hdc, px, py, fColor)
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
END SUB
'----------------------------------------------------------------
SUB LineXY (wID as INT,Lx as INT,Ly as INT,Lx1 as INT,Ly1 as INT)
hdc = GetDC(wID)
SelectObject(hdc, CreatePen(PS_SOLID,1,fColor))
MoveToEx (hdc,Lx,Ly,ByVal 0)
LineTo (hdc,Lx1,Ly1)
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
END SUB
'----------------------------------------------------------
' set window color
Sub FillSolidRect(wID as INT, x As Long, Y As Long, cx As Long, cy As Long, bColor as INT)
Dim hBr As Long ' rc As RECT
hDC=GetDC(wID)
rc.Left = x
rc.Top = Y
rc.right = x + cx
rc.bottom = Y + cy
hBr = CreateSolidBrush(bColor)
FillRect hDC, rc, hBr
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( wID, hdc)
End Sub
'----------------------------------------------------------
SUB WindowColor(wID as INT,wr as INT,wg as INT,wb as INT)
INT backColor = RGB (wr,wg,wb)
FillSolidRect(wID,0,0,w,h,backColor)
END SUB
'------------------------------------------------------
SUB InitDrawing
''get current size of window
GetSize(win,0,0,w,h)
'get window DC
hdc=GetDC(win)
hdcMem = CreateCompatibleDC(0)
hbmMem = CreateCompatibleBitmap(hdc, w, h)
oldBmp = SelectObject( hdcMem, hbmMem )
oldBrush = SelectObject(hdcMem, CreateSolidBrush( RGB(231,223,231)) )
oldPen = SelectObject(hdcMem, CreatePen(PS_SOLID,1,RGB(231,223,231)))
'fill rectangle memDC with brush color
FillRect ( hdcMem,rc, oldBrush)
SetTextColor( hDC,RGB(0,0,0))
SetBkColor( hDC, RGB(231,223,231))
'blit to memDC
BitBlt(hDCmem, 0, 0, w, h, hdc, 0, 0, SRCCOPY)
ReleaseDC( win, hdc)
End SUB
'------------------------------------------------------------
Function Rnd(float randMax) as float
rret = Rand(0,randMax)/(randMax + 1.0)
Return rret
End Function
Function Rnd2(float d) as float
d=1/0x7fffffff
fseed=(fseed <<< 7)*13
Return abs(d*fseed)
End Function
'##########################################################
SUB CleanUp
DeleteDC(hdcMem)
DeleteObject(SelectObject(hdcMem, oldBrush))
DeleteObject(SelectObject(hdcMem, oldPen))
DeleteObject(SelectObject(hdcMem, oldBmp))
END SUB
And here is code in ruben interpreter:
'original code written in Creative Basic by GWS
defn i ,n ,red ,green ,blue
defn ww ,wh ,dots ,xpos ,ypos
defn repeat ,random
defn a ,b ,c ,x ,y ,z
defn j ,xfocus ,yfocus
defn rr ,gg ,bb , count
set ww = 800
set wh = 600
'open window
wform 0,0,ww,wh,#MMS,0,"CB Fractal Patterns"
wColor 0,0,0
set xfocus = ww * 0.47
set yfocus = wh * 0.45
label repeat
set count = count + 1
wColor 0,0,0
set random = RAND(5)
FOR repeat,1,random
' set up some random starting positions ..
set a = RND(1.0)
set b = 0.9998
set c = 2 - 2 * a
set dots = 2000
set x = 0
set j = 0
set y = RND(1.0)*12 + 0.1
' calculate and draw the points ..
FOR i,0,dots
set z = x
set x = b * y + j
set j = a * x + c * (x*x)/(1 + x*x)
set y = j - z
set xpos = x*20 + xfocus
set ypos = y*20 + yfocus
set rr = RAND(255)
set gg = RAND(255)
set bb = RAND(255)
txColor rr,gg,bb
pix xpos,ypos
NEXT i
NEXT repeat
if count,<,5
jump repeat
endif
repeat=0
random=0
dots=0
It is interesting that almost there is no difference in speed .
It is clear that this way is not fast with classic GDI.
.