Oxygen Basic
Programming => Example Code => Topic started by: Peter on April 09, 2012, 02:18:22 AM
-
Deleted
-
Ok..
First example work little bit slow.
Second work fine ;)
Third work perfect ( i add some bouncing ) ;)
include "win64.inc"
window "Constrain Demo",640,490,2
font 12,24,0,"courier"
function Constrain(single xb,mi,ma) as single
if xb > mi and xb < ma then
return xb
elseif xb < mi then
return mi
elseif xb < ma then
return ma
end if
end function
single x, y=200, a
While EscKey()=0
ClsColor 0,0,0
'bouncing ball
y=200 + 50 * SIN(x/16)
Oval x,y,30,30,255,0,0
a = Constrain(x,0,Width)
Text 0,0,"constrain: " + str(a,0),255,255,255
IF Constrain(x,0,Width) > 0
x = x + 0.15
Else
x=0
END IF
FlipBuffer
'WaitFor 80
Wend
WinEnd
-
Yeah...it's better. :)
-
I wanted to create some nice transparent raindrops and waterfalls, but per-pixel alpha blending appears to be broken in GDI. - so transparent sprites are not possible, in Vista at least. Have you found a way round this Peter?
http://msdn.microsoft.com/en-us/library/dd183351(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/dd183393(v=vs.85).aspx
Charles
PS: This thread confirms the problem on 64 bit Windows Vista and 7.
http://social.msdn.microsoft.com/Forums/en-US/windowscompatibility/thread/34f16345-8b61-4427-b72a-64a42261fa1c/
-
Hi Charles..
I found something here :
http://www.functionx.com/win32/Lesson11.htm
I'm not sure if it help... :-\
-
Thanks Aurel,
I've found it can be done with GDIplus, which has no problem with alpha transparency. Once GDIplus is set up, it is quite similar to GDI and can be used without OOP.
Charles
-
Thanks Peter. Yes handling pixels restricts the performance.
Let me show what I have so far with GDIplus. (I think you could replace GDI in your windows API without anyone noticing :) )
Charles
-
I only set two levels for the Water drop alpha - 0 for the dark surround and 0x60 for the drop itself.
One useful feature of GDIPlus is the ability to change pen color and brush color directly. So no need to create new brushes every time you need to change color.
I also got Fonts working.
Charles
-
FYI
Here is a link I found awhile back when I was researching gdi+ with a number of examples written for Autoit.
http://www.autoitscript.com/forum/topic/87200-some-graphical-examples-using-gdi/
They might be useful to translate to O2?
James
Edit: the link went missing?
-
Thanks James,
There are hundreds of GDIP functions, I've just picked up the essentials. On the image processing side, it fills in all the functionality missing in OpenGl.
Charles