[No Bug]in 'Color = RGBA(Red, ...)', should use 'Color.q'
[No Bug]in 'Color = RGBA(Red, ...)', should use 'Color.q'
updated:
in 'Color = RGBA(Red, Green, Blue, Alpha)', should use 'Color.q'
bug when using 32-bit system:
RGBA()
Syntax
Color = RGBA(Red, Green, Blue, Alpha)
----------
should use 'Color.q' , because:
Color=Color.l<$80000000<$ffffffff
x.q<=$100000000*$80000000-1
this bug on using 32-bit system, because:
-----------
Variables and Types
Variables declaration
To declare a variable in PureBasic, simply type its name. You can also specify the type you want this variable to be. By default, when a data type is not indicated, the data is an integer. Variables do not need to be explicitly declared, as they can be used as "variables on-the-fly". The Define keyword can be used to declare multiple variables in one statement. If you don't assign an initial value to the variable, their value will be 0.
-----------
Long .l 4 bytes -2147483648 to +2147483647
Integer .i 4 bytes (using 32-bit compiler) -2147483648 to +2147483647
Integer .i 8 bytes (using 64-bit compiler) -9223372036854775808 to +9223372036854775807
in 'Color = RGBA(Red, Green, Blue, Alpha)', should use 'Color.q'
bug when using 32-bit system:
RGBA()
Syntax
Color = RGBA(Red, Green, Blue, Alpha)
----------
should use 'Color.q' , because:
Color=Color.l<$80000000<$ffffffff
x.q<=$100000000*$80000000-1
this bug on using 32-bit system, because:
-----------
Variables and Types
Variables declaration
To declare a variable in PureBasic, simply type its name. You can also specify the type you want this variable to be. By default, when a data type is not indicated, the data is an integer. Variables do not need to be explicitly declared, as they can be used as "variables on-the-fly". The Define keyword can be used to declare multiple variables in one statement. If you don't assign an initial value to the variable, their value will be 0.
-----------
Long .l 4 bytes -2147483648 to +2147483647
Integer .i 4 bytes (using 32-bit compiler) -2147483648 to +2147483647
Integer .i 8 bytes (using 64-bit compiler) -9223372036854775808 to +9223372036854775807
Last edited by gurj on Thu Mar 16, 2017 8:40 pm, edited 3 times in total.
my pb for chinese:
http://ataorj.ys168.com
http://ataorj.ys168.com
Re: in 'Result = Alpha(Color)', should use 'Result.q'
Alpha returns the value of the alpha channel only, so it's always between 0 and 255.
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Re: in 'Result = Alpha(Color)', should use 'Result.q'
will update,is
in 'Color = RGBA(Red, Green, Blue, Alpha)', should use 'Color.q'
thanks Shield !
in 'Color = RGBA(Red, Green, Blue, Alpha)', should use 'Color.q'
thanks Shield !
my pb for chinese:
http://ataorj.ys168.com
http://ataorj.ys168.com
Re: in 'Color = RGBA(Red, Green, Blue, Alpha)', should use '
red is 1 byte, green is 1 byte, blue is 1 byte, alpha is 1 byte, which makes a total of 4 bytes (long):
returning a quad would make no sense. you are simply getting confused by longs being signed and therefore returning a negative value. no bug.
c ya,
nco2k
Code: Select all
Color.l = RGBA(11, 22, 33, 44)
Red.a = Red(Color)
Green.a = Green(Color)
Blue.a = Blue(Color)
Alpha.a = Alpha(Color)
Debug Red
Debug Green
Debug Blue
Debug Alpha
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: in 'Color = RGBA(Red, Green, Blue, Alpha)', should use '
@nco2k:
Code: Select all
Debug Bool(RGBA(255,255,255,255)=$ffffffff)
a.l=$ffffffff
Debug a
;x.l<$80000000
;$ffffffff=$80000000*2-1
Debug Bool($ffffffff=$80000000*2-1)
my pb for chinese:
http://ataorj.ys168.com
http://ataorj.ys168.com
Re: in 'Color = RGBA(Red, Green, Blue, Alpha)', should use '
Debug $ffffffff;4294967295=2147483647*2+1
;Long .l 4 bytes -2147483648 To +2147483647
;Long .l 4 bytes -2147483648 To +2147483647
my pb for chinese:
http://ataorj.ys168.com
http://ataorj.ys168.com
Re: in 'Color = RGBA(Red, Green, Blue, Alpha)', should use '
whats your point? a signed longs -1 equals an unsigned longs 4294967295.
as i said earlier, you are confused by the negative value of a signed variable.
a byte is a byte, wether you read it as signed or unsigned:purebasic doesnt support unsigned longs and quads. why should pb return 8 bytes for a 4 byte variable, only to fix your cosmetical issue?
c ya,
nco2k
Code: Select all
Debug StrU(-1, #PB_Long)
a byte is a byte, wether you read it as signed or unsigned:
Code: Select all
q.q = -1
Debug PeekB(@q)
Debug PeekA(@q)
Debug PeekW(@q)
Debug PeekU(@q)
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: in 'Color = RGBA(Red, Green, Blue, Alpha)', should use '
Debug uses a quad (8 byte) container, thats why it can display $ffffffff as 4294967295.gurj wrote:Debug $ffffffff;4294967295=2147483647*2+1
;Long .l 4 bytes -2147483648 To +2147483647
you can still apply a value up to 4294967295 to a long, which will correctly be displayed as -1, since a long is signed:
Code: Select all
l.l = 4294967295
Debug l
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: in 'Color = RGBA(Red, Green, Blue, Alpha)', should use '
ok , thanks nco2k !
; in pb ,for Color Example:
; -16776961=4278190335
; so use 4 bytes
; in pb ,for Color Example:
; -16776961=4278190335
; so use 4 bytes
Code: Select all
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 400, 200)
If StartVectorDrawing(CanvasVectorOutput(0))
AddPathBox(50, 50, 200, 50)
VectorSourceColor(RGBA(255, 0, 0, 255))
StrokePath(10)
l.l=RGBA(255, 0, 0, 255)
Debug l;=-16776961
AddPathBox(150, 75, 200, 50)
VectorSourceColor(l)
StrokePath(10)
q.q=$ff0000ff;RGBA(255, 0, 0, 255)
Debug q;=4278190335
AddPathBox(200, 105, 200, 50)
VectorSourceColor(q)
StrokePath(10)
StopVectorDrawing()
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
my pb for chinese:
http://ataorj.ys168.com
http://ataorj.ys168.com
- Andre
- PureBasic Team
- Posts: 2058
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
Re: [no bug]in 'Color = RGBA(Red, ...)', should use 'Color.q
As it seems to be no bug nor a needed change/addition to the PB docs I close this topic now.
If there is still something wrong feel free to post here again...
If there is still something wrong feel free to post here again...
Re: [No Bug]in 'Color = RGBA(Red, ...)', should use 'Color.q
Done.
(I can't change the title of this thread ! Maybe because it's a moved thread)
(I can't change the title of this thread ! Maybe because it's a moved thread)