March 05, 2021, 07:14:47 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Like stats
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Quick Color Function by -Rick- [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Quick Color Function by -Rick- [ 1+ years ago ] (Read 695 times)
BlitzBot
Jr. Member
Posts: 1
Total likes: 0
[bb] Quick Color Function by -Rick- [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:39 AM »
Title :
Quick Color Function
Author :
-Rick-
Posted :
1+ years ago
Description :
A convenience function to call basic colors by name as well
as set 5 special effects for making whatever is colored
have various effects. Color call can use text word such as
"blk", "black" or just a 0. Keys 1,2,3,4 and 0 set the effect
The effects are :
0 - Solid Color
1 - Blink Color On and Off
2 - Pulse Color Dark to Bright
3 - Color Brightens then resets Black
4 - Color Darkens then resets Bright
Usage:
SetCol (color, Effect)
Code :
Code: BlitzBasic
Graphics
800
,
600
,
16
,
2
Global
key$ =
"0"
While
Not
KeyHit
(
1
)
SetCol
(
"yellow"
,key
)
Text
GraphicsWidth
(
)
/
2
,
GraphicsHeight
(
)
/
2
,
"This is a test"
,
1
,
1
If
KeyHit
(
2
)
Then
key =
"1"
If
KeyHit
(
3
)
Then
key =
"2"
If
KeyHit
(
4
)
Then
key =
"3"
If
KeyHit
(
5
)
Then
key =
"4"
If
KeyHit
(
11
)
Then
key =
"0"
Wend
End
;XXXXXXXXXXXXXXXXXXXXXX
; SET COLOR
;XXXXXXXXXXXXXXXXXXXXXX
Function
SetCol
(
Kolor$=
"white"
,Effect$ =
"0"
)
FTime$ =
Str
(
MilliSecs
(
)
)
Time$ =
Mid
(
Ftime,
Len
(
ftime
)
-
2
,
2
)
Fade# =
Float
(
Time
)
* .01
Effect$ =
Lower
(
Effect
)
Select
Effect
Case
0
,
"none"
fade =
1.0
Case
1
,
"blink"
If
fade < .5
Then
fade =
1
Else
fade =
0
EndIf
Case
2
,
"pulse"
If
Fade < .5
Then
Fade# =
1
- Fade
EndIf
Case
3
,
"charge"
If
fade <
1
Then
fade = fade + fade /
5
Else
fade =
0
EndIf
Case
4
,
"fade"
If
fade >
0
Then
fade =
1
- fade
Else
fade =
1
EndIf
End Select
Kolor =
Lower
(
Kolor
)
Select
Kolor
Case
"0"
,
"blk"
,
"black"
;Black
Color
0
,
0
,
0
Case
"1"
,
"red"
;Red
Color
255
*Fade,
0
,
0
Case
"2"
,
"grn"
,
"green"
;Green
Color
0
,
255
*Fade,
0
Case
"3"
,
"blu"
,
"blue"
;Blue
Color
0
,
0
,
255
*Fade
Case
"4"
,
"yel"
,
"yellow"
;Yellow
Color
255
*Fade,
255
*Fade,
0
Case
"5"
,
"drd"
,
"dred"
,
"darkred"
;Dark Red
Color
150
*Fade,
0
,
0
Case
"6"
,
"dgr"
,
"dgreen"
,
"darkgreen"
;Dark Green
Color
0
,
150
*Fade,
0
Case
"7"
,
"dbl"
,
"dblue"
,
"darkblue"
;Dark Blue
Color
0
,
0
,
150
*Fade
Case
"8"
,
"dyl"
,
"dyellow"
,
"darkyellow"
;Dark Yellow
Color
150
*Fade,
150
*Fade,
0
Case
"9"
,
"pur"
,
"purple"
;Purple
Color
255
*Fade,
0
,
255
*Fade
Case
"10"
,
"whi"
,
"white"
;White
Color
255
*Fade,
255
*Fade,
255
*Fade
Case
"11"
,
"gry"
,
"grey"
,
"gray"
;Grey
Color
150
*Fade,
150
*Fade,
150
*Fade
Case
"12"
,
"tel"
,
"teal"
;Teal
Color
0
,
255
*Fade,
255
*Fade
Case
"13"
,
"dgry"
,
"dgrey"
,
"dark grey"
,
"dark gray"
;Dark Grey
Color
50
*fade,
50
*Fade,
50
*Fade
End Select
End Function
Comments :
virtlands(Posted 1+ years ago)
Congrats. I've always enjoyed the concept of joining color and code together. If you'd like to take it a step further, you can include names for thousands of colors (instead of just 13).{ In the case of involving 1000s of colors, I don't think you'd be using a CASE statement.
There's got to be a better way. }There are various websites that offer large lists of color names. I'm sure they'd let you copy these color names for your own code. Best to include a "Copied this from this ..." tribute to be nice.
L
ists of Colors:Wikipedia: <a href="
http://tinyurl.com/ak6h49h
" target="_blank">
http://tinyurl.com/ak6h49h
[/url] {<-- List of colors, A-M}<a href="
http://tinyurl.com/ccmheyy
" target="_blank">
http://tinyurl.com/ccmheyy
[/url] {<-- List of colors, N-Z}Color Names Supported by All Browsers:<a href="
http://www.w3schools.com/html/html_colornames.asp
" target="_blank">
http://www.w3schools.com/html/html_colornames.asp
[/url]ColorHexa List of Colors: { also contains color computer for HEX,RGB, CMYK, HSL, HSV, web-safe }<a href="
http://www.colorhexa.com/color-names
" target="_blank">
http://www.colorhexa.com/color-names
[/url]Cloford, 500+ named colors:<a href="
http://cloford.com/resources/colours/500col.htm
" target="_blank">
http://cloford.com/resources/colours/500col.htm
[/url]WorkWithColor:<a href="
http://www.workwithcolor.com/color-names-01.htm
" target="_blank">
http://www.workwithcolor.com/color-names-01.htm
[/url]Color Schemer is a website that offers color harmony and combinations.<a href="
http://www.colorschemer.com/blog/2007/07/24/140-named-colors/
" target="_blank">
http://www.colorschemer.com/blog/2007/07/24/140-named-colors/
[/url]Name that Color: {This website lets you input color codes, and it will do its best to name that color.}<a href="
http://chir.ag/projects/name-that-color/#BE798E
" target="_blank">
http://chir.ag/projects/name-that-color/#BE798E
[/url]{ This also lets you find names of colors: }<a href="
http://www.colblindor.com/color-name-hue/
" target="_blank">
http://www.colblindor.com/color-name-hue/
[/url]Huge Google Search of Color Names: <a href="
http://tinyurl.com/co9g7ay
" target="_blank">
http://tinyurl.com/co9g7ay
[/url]Huge Google Search of Color Charts: <a href="
http://tinyurl.com/bnwtb8t
" target="_blank">
http://tinyurl.com/bnwtb8t
[/url]Maybe you can just invent a program that absorbs color data directly from the
html
, (customized for each webpage, of course) to save your fingers from all the typing and also on your patience.An
.html
is similar to a
.txt
file, therefore it is possible to read it in Blitz3D.(Next is just an interesting color sampling display I found.)<a href="
http://upload.wikimedia.org/wikipedia/commons/2/2b/SVG_Recognized_color_keyword_names.svg
" target="_blank">
http://upload.wikimedia.org/wikipedia/commons/2/2b/SVG_Recognized_color_keyword_names.svg
[/url]
-Rick-(Posted 1+ years ago)
This is just intended for a quick color function with very minor effects that I can cut and paste into various programs that have a basic color scheme. Mostly for quick text color changes or simple graphics rectangles/ovals. I can never seem to recall the correct color codes for various colors so use this to save a little time while programming and thought it might be helpful for newer programmers.
*(Posted 1+ years ago)
couldnt you use 'Select Upper( Kolor )' then just check for uppercase versions of the colours as I could put bLack and it would break the code as it is now
-Rick-(Posted 1+ years ago)
Great idea on the use of upper/lower EdzUp. I went with lower since all Caps always annoy me
. Added in a few other simple effects and cleaned up the Kolor Select code. Also made it as a stand alone to quickly test the effects and people can just strip out the function itself for use.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Quick Color Function by -Rick- [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal