mirror of
https://github.com/csd4ni3l/browser.git
synced 2026-01-01 04:03:43 +01:00
Add backgrounds to finish layout tutorial, add inline and remote CSS support with a default of browser.css which currently supports fonts and backgrounds
This commit is contained in:
@@ -32,6 +32,36 @@ menu_background_color = arcade.color.WHITE
|
||||
log_dir = 'logs'
|
||||
discord_presence_id = 1393164073566208051
|
||||
|
||||
BLOCK_ELEMENTS = [
|
||||
"html", "body", "article", "section", "nav", "aside",
|
||||
"h1", "h2", "h3", "h4", "h5", "h6", "hgroup", "header",
|
||||
"footer", "address", "p", "hr", "pre", "blockquote",
|
||||
"ol", "ul", "menu", "li", "dl", "dt", "dd", "figure",
|
||||
"figcaption", "main", "div", "table", "form", "fieldset",
|
||||
"legend", "details", "summary"
|
||||
]
|
||||
|
||||
SELF_CLOSING_TAGS = [
|
||||
"area", "base", "br", "col", "embed", "hr", "img", "input",
|
||||
"link", "meta", "param", "source", "track", "wbr",
|
||||
]
|
||||
|
||||
HEAD_TAGS = [
|
||||
"base", "basefont", "bgsound", "noscript",
|
||||
"link", "meta", "title", "style", "script",
|
||||
]
|
||||
|
||||
INHERITED_PROPERTIES = {
|
||||
"font-family": "Arial",
|
||||
"font-size": "16px",
|
||||
"font-style": "normal",
|
||||
"font-weight": "normal",
|
||||
"color": "black",
|
||||
"display": "inline",
|
||||
"width": "auto",
|
||||
"height": "auto"
|
||||
}
|
||||
|
||||
button_style = {'normal': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK), 'hover': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK),
|
||||
'press': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK), 'disabled': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK)}
|
||||
big_button_style = {'normal': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, font_size=26), 'hover': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, font_size=26),
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import arcade.gui, arcade
|
||||
from http_client.html_parser import CSSParser
|
||||
|
||||
button_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture("assets/graphics/button.png"))
|
||||
button_hovered_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4, 64 // 4, arcade.load_texture("assets/graphics/button_hovered.png"))
|
||||
|
||||
DEFAULT_STYLE_SHEET = CSSParser(open("assets/css/browser.css").read()).parse()
|
||||
|
||||
@@ -63,3 +63,23 @@ class FakePyPresence():
|
||||
...
|
||||
def close(self, *args, **kwargs):
|
||||
...
|
||||
|
||||
def hex_to_rgb(hex_color):
|
||||
hex_color = hex_color.lstrip('#')
|
||||
if len(hex_color) != 6:
|
||||
return (127, 127, 127)
|
||||
return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
|
||||
|
||||
def get_color_from_name(rgb_name):
|
||||
rgb_name = rgb_name.upper()
|
||||
if rgb_name.startswith("LIGHT"):
|
||||
color_name = rgb_name.split("LIGHT")[1]
|
||||
color_value = arcade.csscolor.__dict__.get(f"LIGHT_{color_name}")
|
||||
if not color_value:
|
||||
arcade.color.__dict__.get(f"LIGHT_{color_name}")
|
||||
|
||||
if color_value:
|
||||
return color_value
|
||||
|
||||
color_value = arcade.csscolor.__dict__.get(rgb_name)
|
||||
return color_value if color_value else arcade.color.__dict__.get(rgb_name, arcade.color.GRAY)
|
||||
|
||||
Reference in New Issue
Block a user