Açıklama : Hex renk kodlarını 10luk sistemdeki RGB karşılığını veren fonksiyon
Örnek : Hex2RGB ( "0CAB10" ; "-" ; "Hex is written wrong" )
Sonuç : 12-171-16
Parametreler : hex, delimiter, alert
Fonksiyon
Let (
// Yazılan değer kontrolü
chex = Upper ( Filter ( hex ; "0123456789aAbBcCdDeEfF" ) ) ;
If ( Length ( chex ) = 6 ;
// Kırmızı
Substitute ( Middle ( chex;1;1) ;
[ "A" ; 10 ] ; [ "B" ; 11 ] ; [ "C" ; 12 ] ; [ "D" ; 13 ] ; [ "E" ; 14 ] ; [ "F" ; 15 ] ) * 16 +
Substitute ( Middle ( chex;2;1) ;
[ "A" ; 10 ] ; [ "B" ; 11 ] ; [ "C" ; 12 ] ; [ "D" ; 13 ] ; [ "E" ; 14 ] ; [ "F" ; 15 ] ) * 1
& delimiter &
// Yeşil
Substitute ( Middle (chex;3;1) ;
[ "A" ; 10 ] ; [ "B" ; 11 ] ; [ "C" ; 12 ] ; [ "D" ; 13 ] ; [ "E" ; 14 ] ; [ "F" ; 15 ] ) * 16 +
Substitute ( Middle (chex;4;1) ; [ "A" ; 10 ] ; [ "B" ; 11 ] ; [ "C" ; 12 ] ; [ "D" ; 13 ] ; [ "E" ; 14 ] ; [ "F" ; 15 ] ) * 1
& delimiter &
// Mavi
Substitute ( Middle (chex;5;1) ;
[ "A" ; 10 ] ; [ "B" ; 11 ] ; [ "C" ; 12 ] ; [ "D" ; 13 ] ; [ "E" ; 14 ] ; [ "F" ; 15 ] ) * 16 +
Substitute ( Middle (chex;6;1) ;
[ "A" ; 10 ] ; [ "B" ; 11 ] ; [ "C" ; 12 ] ; [ "D" ; 13 ] ; [ "E" ; 14 ] ; [ "F" ; 15 ] ) * 1
// uyarı mesajı
; alert ) )
Hiç yorum yok:
Yorum Gönder