Author Topic: AlphaScreen  (Read 2082 times)

0 Members and 1 Guest are viewing this topic.

Aaron

  • Guest
AlphaScreen
« on: March 12, 2014, 09:31:07 AM »
Hello,

now is it possible to use an alpha screen.
Code: [Select]
include "ss.inc"
OpenWindow 800,600,1

Type Star
   sys xStar
   sys yStar
   sys speed
End Type

Dim Stars(500) As Star
sys xRes =800
sys yRes =600

sys i
For i = 1 To 500
   Stars(i).xStar = Rnd(1, xRes -2)
   Stars(i).yStar = Rnd(1, yRes -2)
   Stars(i).speed = Rnd(2, 4)
Next

Sub MoveStars()
sys i
For i = 1 To 500
   color Rnd(64,255),255,255, 255
   DrawPoint Stars(i).xStar,Stars(i).yStar,2
   Stars(i).xStar = Stars(i).xStar + Stars(i).speed
   iF Stars(i).xStar > xRes
      Stars(i).xStar = 0
      Stars(i).yStar = Rnd(1, yRes -2)
      Stars(i).speed = Rnd(2, 4)
   End iF
Next
End Sub

While Key(27)=0
AlphaCls 0,0,0,25
MoveStars
Redraw
Wait 4
Wend
CloseWindow

.

Aaron

  • Guest
Re: AlphaScreen
« Reply #1 on: March 12, 2014, 09:48:52 AM »
Hello again,

You are now able to use your own sdl-commands.
Try out all (sdl) dlls.     
Only an api declaration, ( Low or High) and you got it.

Code: [Select]
include "ss.inc"

Extern cdecl Lib "sdl_gfx.dll"
! filledCircleColor
! filledEllipsColor
! filledTrigonColor   
! pixelColor
! lineColor
! bezierColor
! arcColor
! pieColor
! boxColor
! characterColor
! stringColor
! circleColor
! ellipseColor
! rectangleColor
! thickLineColor
End Extern

OpenWindow 320,240,1
hdc = GetScreenDC

int x

while KeyDown(27)=0
Cls 255,255,255

filledCircleColor hdc,x,100,20, RGBA(255,0,0,100)
filledCircleColor hdc,x,120,20, RGBA(255,0,0,100)

x +=1
if x >=360 then x=-40

Redraw
Wait 8
wend
CloseWindow

JRS

  • Guest
Re: AlphaScreen
« Reply #2 on: March 12, 2014, 05:35:36 PM »
Peter,

I think I'm getting a little closer or seeing the same thing with a different approach. The strange thing is the alpha value is aways returned as 255 but if I use a different alpha value to set the pixel, the color R,G,B values are changed based on the alpha value I passed. Here is the Script BASIC GFX extension module gfx_GetPixelRGBA.

Code: [Select]
besFUNCTION(gfx_GetPixelRGBA)
  DIM AS SDL_Surface PTR this_surface;
  DIM AS Uint32 PTR pixels;
  DIM AS int x, y;
  DIM AS Uint8 r, g, b, a;
  besARGUMENTS("iii")
    AT this_surface, AT x, AT y
  besARGEND
  pixels = (Uint32 *)this_surface->pixels;
  SDL_GetRGBA(pixels[(y * this_surface->w) + x], this_surface->format, &r, &g, &b, &a);
  printf("r = %i, g = %i, b = %i, a = %i\n", r, g, b, a); 
  besRETURNVALUE = NULL;
besEND

Code: [Select]
IMPORT gfx.inc

s = gfx::Window(320, 240, "Pixel Test")
gfx::pixelRGBA s, 100, 100, 64, 128, 64, 255
gfx::Update
gfx::GetPixelRGBA(s, 100, 100)
WHILE gfx::KeyName(1) <> "+escape"
WEND
gfx::Close

jrs@laptop:~/sb/sb22/gfx$ scriba getpixel.sb
r = 64, g = 128, b = 64, a = 255

Code: [Select]
gfx::pixelRGBA s, 100, 100, 64, 128, 64, 0

jrs@laptop:~/sb/sb22/gfx$ scriba getpixel.sb
r = 0, g = 0, b = 0, a = 255

Code: [Select]
gfx::pixelRGBA s, 100, 100, 64, 128, 64, 100

jrs@laptop:~/sb/sb22/gfx$ scriba getpixel.sb
r = 25, g = 50, b = 25, a = 255

If I create another surface and use it to set the pixel and gfx::GetPixelRGBA, the alpha value changes as does the color values. Here are the return values using the same process as above. (alpha 255, 0, 100)

Code: [Select]
IMPORT gfx.inc

sv = gfx::Window(320, 240, "Pixel Test")
s = gfx::CreateSurface(320, 240, 32)
gfx::pixelRGBA s, 100, 100, 64, 128, 64, 100
gfx::GetPixelRGBA(s, 100, 100)
gfx::BlitSurface s, 0, sv, 0
gfx::Update
WHILE gfx::KeyName(1) <> "+escape"
WEND
gfx::Close

jrs@laptop:~/sb/sb22/gfx$ scriba getpixel.sb
r = 64, g = 128, b = 64, a = 255
jrs@laptop:~/sb/sb22/gfx$ scriba getpixel.sb
r = 0, g = 0, b = 0, a = 0
jrs@laptop:~/sb/sb22/gfx$ scriba getpixel.sb
r = 25, g = 50, b = 25, a = 39
jrs@laptop:~/sb/sb22/gfx$

I added in my standard gfx::GetPixel function and printed it as a HEX value. (using an alpha value of 100)

jrs@laptop:~/sb/sb22/gfx$ scriba getpixel.sb
r = 25, g = 50, b = 25, a = 39
19321927
jrs@laptop:~/sb/sb22/gfx$
« Last Edit: March 12, 2014, 08:43:19 PM by John »