How to use the sty.bg function in sty

To help you get started, we’ve selected a few sty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feluxe / sty / tests / docs / coloring.py View on Github external
from .. import Example

print("\n\nCOLORING\n" + "=" * 80)

# ===== Start =====
Example("coloring by name")
from sty import fg, bg, rs

a = fg.li_blue + 'I have a light blue foreground.' + rs.fg
b = bg.cyan + 'I have a cyan background' + rs.bg
c = fg.da_red + bg.li_red + 'I have a dark red fg and light red bg.' + rs.all
d = fg('yellow') + 'I have yellow fg.' + rs.fg

print(a, b, c, d, sep='\n')
# ===== End =====

# ===== Start =====
Example("coloring by 8bit number")
from sty import fg, bg, rs

a = fg(34) + 'I have a green foreground.' + rs.fg
b = bg(133) + 'I have a pink background' + rs.bg
c = fg(226) + bg(19) + 'I have a light yellow fg and dark blue bg.' + rs.all

print(a, b, c, sep='\n')
# ===== End =====
github feluxe / sty / tests / docs / getting_started.py View on Github external
# ===== Start =====
Example("gettings started: select dynamically")
a = ef('italic') + 'Italic text.' + rs.italic
b = fg('blue') + 'Blue text.' + rs.fg
c = bg(randint(0, 254)) + 'Random colored bg' + rs.bg

print(a, b, c, sep='\n')
# ===== End =====

# ===== Start =====
Example("gettings started: select 8bit and 24bit directly")
# select an 8bit color directly.
a = fg(196) + 'This is red text' + rs.fg

# select a 24bit rgb color directly.
b = bg(50, 255, 50) + 'Text with green bg' + rs.bg

print(a, b, sep='\n')
# ===== End =====

# ===== Start =====
Example("hello world")
my_string = fg.black + bg.white + ef.bold + 'Hello world!' + rs.all
print(my_string)
# ===== End =====
github feluxe / sty / tests / docs / muting.py View on Github external
print(a, b, c, d, e, f, sep='\n')
# ===== End =====

# ===== Start =====
Example("mute formatting batch")
from sty import mute, unmute, ef, fg, bg, rs

a1 = fg.red + 'This text is red.' + fg.rs
a2 = bg.red + 'This bg is red.' + bg.rs
a3 = ef.italic + 'This text is italic' + rs.italic

mute(fg, bg, ef, rs)

b1 = fg.red + 'This text is NOT red.' + fg.rs
b2 = bg.red + 'This bg is NOT red.' + bg.rs
b3 = ef.italic + 'This text is NOT italic' + rs.italic

unmute(fg, bg, ef, rs)

c1 = fg.red + 'This text is red.' + fg.rs
c2 = bg.red + 'This bg is red.' + bg.rs
c3 = ef.italic + 'This text is italic' + rs.italic

print(a1, a2, a3, b1, b2, b3, c1, c2, c3, sep='\n')
# ===== End =====
github Hellisotherpeople / CX_DB8 / cx_db8_flair.py View on Github external
sum_str = ""
    html_str = ""
    removed_str = ""
    token_removed_ct = 0
    to_highlight = np.asarray([i for i in val_list if i > h])
    scaler = MinMaxScaler(feature_range = (20, 255))
    scaler.fit(to_highlight.reshape(-1, 1))
    for sum_word in word_list:
        prev_word = "n"
        if float(sum_word[1]) > h:
            if dynamic:
                bgnum = int(scaler.transform(sum_word[1].cpu().detach().numpy().reshape(-1, 1)))
            else:
                bgnum = highlight_color_intensity
            html_str += ef.u + bcolors.HIGHLIGHT + sum_word[0] + " "
            sum_str += ef.u + bg(bgnum, bgnum, 0)
            runner = par.add_run(sum_word[0] + " ")
            runner.underline = True
            runner.bold = True
            sum_str += " ".join([str(sum_word[0]), rs.all])
        elif float(sum_word[1]) > n:
            html_str += ef.u + sum_word[0] + " "
            sum_str += ef.u
            runner = par.add_run(sum_word[0] + " ")
            runner.underline = True
            sum_str += " ".join([str(sum_word[0]), rs.all])
        else:
            html_str += sum_word[0] + " " + bcolors.END
            token_removed_ct += 1
            sum_str += str(sum_word[0])
            runner = par.add_run(sum_word[0] + " ")
            sum_str += " "
github FlameOfIgnis / github-year-draw / github-draw.py View on Github external
def preview():
	print(f"{warn} Preview?")
	if(waitConfirm()):
		for y in range(im.size[1]):
			for x in range(im.size[0]):
				#print(f"{x=}{y=}")
				c = monochromize(pix[y][x])

				#double scale to introduce the flat lose.
				c = scaleIntensity(c,255,intensity)
				c = scaleIntensity(c,intensity,255)
				c = monochromize(pix[y][x])
				c = bg(c,c,c)
				print(c + " ", end='')
			print(bg.rs)