tripcode.py
30 lines
| 892 B
| text/x-python
|
PythonLexer
neko259
|
r1296 | class Tripcode: | ||
def __init__(self, code_str): | ||||
self.tripcode = code_str | ||||
def get_color(self): | ||||
return self.tripcode[:6] | ||||
def get_background(self): | ||||
code = self.get_color() | ||||
result = '' | ||||
for i in range(0, len(code), 2): | ||||
p = code[i:i+2] | ||||
background = hex(255 - int(p, 16))[2:] | ||||
if len(background) < 2: | ||||
background = '0' + background | ||||
result += background | ||||
return result | ||||
def get_short_text(self): | ||||
return self.tripcode[:8] | ||||
neko259
|
r1297 | def get_full_text(self): | ||
return self.tripcode | ||||
neko259
|
r1296 | def get_view(self): | ||
neko259
|
r1301 | return '<span class="tripcode" title="{title}" style="border: solid 2px #{color}; border-left: solid 1ex #{color};">{text}</span>'\ | ||
.format(title=self.get_full_text(), color=self.get_color(), | ||||
text=self.get_short_text()) | ||||