News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

PlayBasic Alpha 2.17 - Alpha Blending Pic

Started by kevin, August 02, 2004, 11:47:24 AM

Previous topic - Next topic

kevin

  As you know i've been working my butt off improving the vector art features in PlayBASICc.  We've had some great result with Circles/Ellipses etc.  A massive speed improvement.  Now not content will just plain rendering, i've been adding draw modes to the vector art part of the command set too.  While they do eat up a bit of speed since their done in software, they do give PlayBasic.com a pretty unique flavor now.

The modes currently supported for are

normal
filled
AlphaBlend (variable)
AlphaBlend (50/50)
AlphaBlend ADD
AlphaBlend SUB
AND mode (pixels are AND'd together)
OR mode (pixels are OR'd together)
XOR mode (pixels are XOR'd together)

Got a couple of modes are on my mind.  I like the idea of a "Gray scale mode' where you draw the item over some pixels and it converts them to gray scale.  And perhaps a Fade pixel mode.

This demo is running 32bit (640*480) rending a full screen Shade box, plus a hand full of alpha'd line art.  The biggest drama with doing alpha is that you have to read from video memory, which makes it pretty slow.   But the result is effective !

   (ORIGINAL OBSOLETE CODE)

PlayBASIC Code: [Select]
OpenScreen 640,480,32,2
MakeBitmapFont 1,$ffffff

sw=GetScreenWidth()
sh=GetScreenHeight()

Max=100
Do

mx=MouseX()
my=MouseY()

LockBuffer

c1=RGBFade($ff0000,SinNewValue(50,baseangle#,50))
c2=RGBFade($ffff00,CosNewValue(50,baseangle#,50))

c3=RGBFade($ff00f0,SinNewValue(50,baseangle#*2,50))
c4=RGBFade($1234,CosNewValue(50,baseangle#*2,50))
ShadeBox 0,0,sw,sh,c1,c2,c3,c4

; Set DRawMode to Alpha ADD + Normal
DrawMode 64+1


x=320
y=240
Max=30
Size=150
For lp=1 To max
angle#=baseangle#+((360.0/max)*lp)
xp#=x+CosRadius(angle#,size)
yp#=y+SinRadius(angle#,size)
LineC x,y,xp#,yp#,$304030
Next


DRawmode 64+1
m=getdrawmode()
Ink $808080
Ellipse mx,my,40,60+(cx And $f),1


UnLockBuffer
baseangle#=Mod(baseangle#+1,360)


cx=Mod(cx+2,640)
Ink RGB(255,255,255)
yh=20
yp=(sh/2)-50
CenterText sw/2,yp," Play Basic V2.17 Blend Tech": yp=yp+yh
CenterText sw/2,yp," Shade Box": yp=yp+yh
CenterText sw/2,yp,Str$(max)+" Alpha Blended Lines ": yp=yp+yh
CenterText sw/2,yp," Alpha Blended Ellipse": yp=yp+yh
CenterText sw/2,yp," Fps:"+Str$(FPS()) : yp=yp+yh

Sync
Loop







   (UPDATED CODE: DrawMode now ='s InkMode)

PlayBASIC Code: [Select]
OpenScreen 640,480,32,2
MakeBitmapFont 1,$ffffff

sw=GetScreenWidth()
sh=GetScreenHeight()

Max=100
Do

mx=MouseX()
my=MouseY()

LockBuffer

inkmode 1

c1=RGBFade($ff0000,SinNewValue(50,baseangle#,50))
c2=RGBFade($ffff00,CosNewValue(50,baseangle#,50))

c3=RGBFade($ff00f0,SinNewValue(50,baseangle#*2,50))
c4=RGBFade($1234,CosNewValue(50,baseangle#*2,50))
ShadeBox 0,0,sw,sh,c1,c2,c3,c4

; Set DRawMode to Alpha ADD + Normal
InkMode 64+1


x=320
y=240
Max=30
Size=150
For lp=1 To max
angle#=baseangle#+((360.0/max)*lp)
xp#=x+CosRadius(angle#,size)
yp#=y+SinRadius(angle#,size)
LineC x,y,xp#,yp#,$304030
Next


inkmode 64+1
m=getinkmode()
Ink $808080
Ellipse mx,my,40,60+(cx And $f),1


UnLockBuffer
baseangle#=Mod(baseangle#+1,360)


cx=Mod(cx+2,640)
Ink RGB(255,255,255)
yh=20
yp=(sh/2)-50
CenterText sw/2,yp," PlayBASIC (ALPHA) V2.17 Blend Tech": yp=yp+yh
CenterText sw/2,yp," Shade Box": yp=yp+yh
CenterText sw/2,yp,Str$(max)+" Alpha Blended Lines ": yp=yp+yh
CenterText sw/2,yp," Alpha Blended Ellipse": yp=yp+yh
CenterText sw/2,yp," Fps:"+Str$(FPS()) : yp=yp+yh

Sync
Loop





kevin

#1
Download  (1meg)
===============

old file removed.


Note:  Never mind the TwinTrix splash the screen :)