How to programmicly convert rgb(255,255,255) to $FFFF00 ???

Just starting out? Need help? Post your questions and find answers here.
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

Of couse nobody's posted them before, I researched and wrote them in response to your original question...
so... you're welcome...
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Shannara wrote:Anyways, I PM'd him even though he havent been on the forums since October 2004.
Better try to get him at the german forum.
Good programmers don't comment their code. It was hard to write, should be hard to read.
The_CodeMaster
User
User
Posts: 41
Joined: Wed Dec 29, 2004 11:39 am
Location: Belgium

Post by The_CodeMaster »

Until then, anybody have a way to change the colors of the four corners of a Sprite3D?
Manual
The 2D sprite used to create the 3D sprite must not be deleted when a 3D sprite use it. A single 2D Sprite can be used by any number of 3D Sprite.
mmm... Somehow I know there is a way to perform direct memory-functions on the videocard. Nice one, I will look into it :)
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

Hi there

I have recently done something like this, but not what you want, but i want to share anyway after getting so much from the forum.

Here is how i convert RGB to Hex. Suppose your RGB Color is in this format: 255,30,30

Code: Select all

Procedure.s Hex1(farb.l)  ; To make sure it return 00 not 0
  If Hex(farb.l) = Str(0)
    Result1 = "00"
  Else
    Result1 = Hex(farb.l)
  EndIf
  ProcedureReturn Result1 
EndProcedure 


HexColor  = "#" + Hex1(Val(StringField(RGBColor,1,",")) + Hex1(Val(StringField(RGBColor,2,",")) + Hex1(Val(StringField(RGBColor,3,","))

Take care

Cecil
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Thanks Poly, I must of read your post wrong...

Anyways, Danilo replied stating the his code no longer works because the Sprite3D have changed a bit since the code was posted ... so ... that sucks :)
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

The newest description of the Sprite3D lib and its structures
should be in the PB Library SDK.
You have to rewrite the code every time the PB lib internals
change.
This above is from Danilo. I looked all in the C:\Program Files\PureBasic\Library SDK and there is nothing concerning Sprite3D.. anybody know where else to look? Im still searching.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

A more elegant and cross platform method:

Code: Select all

;Convert a 24bit colour value to a Hex string
Procedure.s RGBToHex(Colour.l)
	Protected HexString.s = "#"
	HexString + RSet(Hex(Red(Colour)), 2, "0")
	HexString + RSet(Hex(Green(Colour)), 2, "0")
	HexString + RSet(Hex(Blue(Colour)), 2, "0")
	ProcedureReturn HexString
EndProcedure
--Kale

Image
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Thanks to both Cecil and Kale :)
Post Reply