Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2e7a3204
Kaydet (Commit)
2e7a3204
authored
Şub 18, 1998
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
rrggbb_to_triplet(), triplet_to_rrggbb(): Improvements given by GvR
üst
4435d5a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
8 deletions
+3
-8
ColorDB.py
Tools/pynche/ColorDB.py
+3
-8
No files found.
Tools/pynche/ColorDB.py
Dosyayı görüntüle @
2e7a3204
...
...
@@ -145,7 +145,7 @@ def get_colordb(file, filetype=X_RGB_TXT):
_namedict
=
{}
def
rrggbb_to_triplet
(
color
):
def
rrggbb_to_triplet
(
color
,
atoi
=
string
.
atoi
):
"""Converts a #rrggbb color to the tuple (red, green, blue)."""
rgbtuple
=
_namedict
.
get
(
color
)
if
rgbtuple
is
None
:
...
...
@@ -153,7 +153,7 @@ def rrggbb_to_triplet(color):
red
=
color
[
1
:
3
]
green
=
color
[
3
:
5
]
blue
=
color
[
5
:
7
]
rgbtuple
=
tuple
(
map
(
lambda
v
:
string
.
atoi
(
v
,
16
),
(
red
,
green
,
blue
)
))
rgbtuple
=
(
atoi
(
red
,
16
),
atoi
(
green
,
16
),
atoi
(
blue
,
16
))
_namedict
[
color
]
=
rgbtuple
return
rgbtuple
...
...
@@ -161,14 +161,9 @@ def rrggbb_to_triplet(color):
_tripdict
=
{}
def
triplet_to_rrggbb
(
rgbtuple
):
"""Converts a (red, green, blue) tuple to #rrggbb."""
def
hexify
(
v
):
hexstr
=
hex
(
v
)[
2
:
4
]
if
len
(
hexstr
)
<
2
:
hexstr
=
'0'
+
hexstr
return
hexstr
hexname
=
_tripdict
.
get
(
rgbtuple
)
if
hexname
is
None
:
hexname
=
'#
%
s
%
s
%
s'
%
tuple
(
map
(
hexify
,
rgbtuple
))
hexname
=
'#
%
02
x
%02
x
%02
x'
%
rgbtuple
_tripdict
[
rgbtuple
]
=
hexname
return
hexname
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment