From 036fe269aa1fbaa1d3d64b06824c19ccfe70a14f Mon Sep 17 00:00:00 2001
From: pushfoo <36696816+pushfoo@users.noreply.github.com>
Date: Wed, 16 Oct 2024 09:03:33 -0400
Subject: [PATCH 1/5] Fix constant literals and 1 px gap at bottom of color
swatches
---
doc/_static/css/custom.css | 9 +++++----
doc/conf.py | 22 ++++++++++++++++------
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/doc/_static/css/custom.css b/doc/_static/css/custom.css
index 049f6738fc..bd77a22712 100644
--- a/doc/_static/css/custom.css
+++ b/doc/_static/css/custom.css
@@ -228,10 +228,11 @@ body:not([data-theme="light"]) .highlight .c1 {
color: #007507;
}
-/* Color tables */
-.checkered {
- background-image: url(../checkered.png);
- background-repeat: repeat;
+/* Color tables and resource pages*/
+.checkered, {
+ /*background: url(../checkered.png);*/
+ box-sizing: border-box;
+ background-repeat: repeat, repeat;
margin:0px;
padding: 0px;
}
diff --git a/doc/conf.py b/doc/conf.py
index a1d00dce1e..038739e4ba 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -331,16 +331,26 @@ def generate_color_table(filename, source):
if not matches:
continue
- color_rgba = f"({matches.group('red')}, {matches.group('green')}, {matches.group('blue')}, {matches.group('alpha')})"
+ name, r, g, b, a = matches.groupdict().values()
+ color_rgb_comma_sep= f"{r}, {g}, {b}"
# Generate the alpha for CSS color function
- alpha = int( matches.group('alpha') ) / 255
- css_rgba = f"({matches.group('red')}, {matches.group('green')}, {matches.group('blue')}, {alpha!s:.4})"
+ rgba_css = f"rgba({color_rgb_comma_sep}, {int(a) / 255!s:.4})"
+ style = (
+ f"linear-gradient(to right, {rgba_css}, {rgba_css}), "
+ "url(/_static/checkered.png)"
+ )
append_text += "
"
- append_text += f"{matches.group('name')} | "
- append_text += f"{color_rgba} | "
- append_text += f"  | "
+ append_text += (
+ f""
+ f""
+ f"{name}"
+ f" "
+ f" | "
+ )
+ append_text += f"({color_rgb_comma_sep}, {a}) | "
+ append_text += f"  | "
append_text += "
\n"
append_text += " "
From 7e7ac4093bcf866ba79ff86a4cde6b3a7644638c Mon Sep 17 00:00:00 2001
From: pushfoo <36696816+pushfoo@users.noreply.github.com>
Date: Wed, 16 Oct 2024 11:23:11 -0400
Subject: [PATCH 2/5] Add .color-swatch to .checkered as resource prep
---
doc/_static/css/custom.css | 51 ++++++++++++++++++++++++++++----------
doc/conf.py | 6 +----
2 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/doc/_static/css/custom.css b/doc/_static/css/custom.css
index bd77a22712..ec03a4a33c 100644
--- a/doc/_static/css/custom.css
+++ b/doc/_static/css/custom.css
@@ -208,18 +208,50 @@ table.dataTable.display tbody tr.even > .sorting_1 {
color: var(--color-foreground-primary);
}
-/* Named color chart */
+/* Color tables and resource pages */
+.checkered-bg, .color-swatch{
+ background: url(../checkered.png);
+ background-repeat: repeat;
+}
+
+table.resource-table {
+ empty-cells: hide;
+}
table.colorTable {
- border-spacing: 5px;
+ border-width: 1px;
}
-table.colorTable tr > td:nth-child(3) {
- border: 1px solid black;
+
+/* Named color tables for larger screens */
+table.colorTable td, table.colorTable th {
+ padding: 2px;
}
-table.colorTable tr > td:nth-child(3) > div {
+table.colorTable tr:not(:last-child) {
+ border-bottom-width: 1px;
+}
+
+.colorTable .color-swatch {
display: block;
+ border: 1px solid black;
+ padding: 0px;
+ box-sizing: border-box;
width: 80px;
min-width: 80px;
}
+
+/* Use compact mode for color tables on smaller screens*/
+@media screen and (width <= 700px) {
+ table.colorTable {
+ border-spacing: collapse;
+ }
+ table.colorTable td, table.colorTable th {
+ padding: 0px;
+ }
+ .colorTable .color-swatch {
+ width: 40px;
+ min-width: 40px;
+ }
+}
+
/* Custom code syntax highlighting */
body:not([data-theme="light"]) .highlight .c1 {
color: #48A148;
@@ -228,14 +260,7 @@ body:not([data-theme="light"]) .highlight .c1 {
color: #007507;
}
-/* Color tables and resource pages*/
-.checkered, {
- /*background: url(../checkered.png);*/
- box-sizing: border-box;
- background-repeat: repeat, repeat;
- margin:0px;
- padding: 0px;
-}
+
/* Change font for headers and title*/
@font-face {
diff --git a/doc/conf.py b/doc/conf.py
index 038739e4ba..74ec6a8f13 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -336,10 +336,6 @@ def generate_color_table(filename, source):
# Generate the alpha for CSS color function
rgba_css = f"rgba({color_rgb_comma_sep}, {int(a) / 255!s:.4})"
- style = (
- f"linear-gradient(to right, {rgba_css}, {rgba_css}), "
- "url(/_static/checkered.png)"
- )
append_text += " "
append_text += (
@@ -349,8 +345,8 @@ def generate_color_table(filename, source):
f""
f""
)
+ append_text += f"  | "
append_text += f"({color_rgb_comma_sep}, {a}) | "
- append_text += f"  | "
append_text += "
\n"
append_text += " "
From c9968d471f4232a7cd1756da875cf1d1addf2972 Mon Sep 17 00:00:00 2001
From: pushfoo <36696816+pushfoo@users.noreply.github.com>
Date: Wed, 16 Oct 2024 11:53:21 -0400
Subject: [PATCH 3/5] Wire arcade.uicolor into the doc
* Add a file compliant with current color table approach
* Add it to the API overview toctree under colors
* Temp append 255 to all arcade.uicolor files to simplify parsing logic
* Add the color reading to conf.py
---
arcade/uicolor.py | 40 ++++++++++++++++-----------------
doc/api_docs/arcade.rst | 1 +
doc/api_docs/arcade.uicolor.rst | 19 ++++++++++++++++
doc/conf.py | 3 ++-
4 files changed, 42 insertions(+), 21 deletions(-)
create mode 100644 doc/api_docs/arcade.uicolor.rst
diff --git a/arcade/uicolor.py b/arcade/uicolor.py
index cc1b4fef2a..eb04094282 100644
--- a/arcade/uicolor.py
+++ b/arcade/uicolor.py
@@ -6,26 +6,26 @@
from arcade.color import BLACK, WHITE, Color
WHITE = WHITE
-GREEN_TURQUOISE = Color(26, 188, 156)
-GREEN_GREEN_SEA = Color(22, 160, 133)
-GREEN_NEPHRITIS = Color(39, 174, 96)
-GREEN_EMERALD = Color(46, 204, 113)
-BLUE_PETER_RIVER = Color(52, 152, 219)
-BLUE_BELIZE_HOLE = Color(41, 128, 185)
-PURPLE_AMETHYST = Color(155, 89, 182)
-PURPLE_WISTERIA = Color(142, 68, 173)
-DARK_BLUE_WET_ASPHALT = Color(52, 73, 94)
-DARK_BLUE_MIDNIGHT_BLUE = Color(44, 62, 80)
-YELLOW_SUN_FLOWER = Color(241, 196, 15)
-YELLOW_ORANGE = Color(243, 156, 18)
-ORANGE_CARROT = Color(230, 126, 34)
-ORANGE_PUMPKIN = Color(211, 84, 0)
-RED_ALIZARIN = Color(231, 76, 60)
-RED_POMEGRANATE = Color(192, 57, 43)
-WHITE_CLOUDS = Color(236, 240, 241)
-WHITE_SILVER = Color(189, 195, 199)
-GRAY_CONCRETE = Color(149, 165, 166)
-GRAY_ASBESTOS = Color(127, 140, 141)
+GREEN_TURQUOISE = Color(26, 188, 156, 255)
+GREEN_GREEN_SEA = Color(22, 160, 133, 255)
+GREEN_NEPHRITIS = Color(39, 174, 96, 255)
+GREEN_EMERALD = Color(46, 204, 113, 255)
+BLUE_PETER_RIVER = Color(52, 152, 219, 255)
+BLUE_BELIZE_HOLE = Color(41, 128, 185, 255)
+PURPLE_AMETHYST = Color(155, 89, 182, 255)
+PURPLE_WISTERIA = Color(142, 68, 173, 255)
+DARK_BLUE_WET_ASPHALT = Color(52, 73, 94, 255)
+DARK_BLUE_MIDNIGHT_BLUE = Color(44, 62, 80, 255)
+YELLOW_SUN_FLOWER = Color(241, 196, 15, 255)
+YELLOW_ORANGE = Color(243, 156, 18, 255)
+ORANGE_CARROT = Color(230, 126, 34, 255)
+ORANGE_PUMPKIN = Color(211, 84, 0, 255)
+RED_ALIZARIN = Color(231, 76, 60, 255)
+RED_POMEGRANATE = Color(192, 57, 43, 255)
+WHITE_CLOUDS = Color(236, 240, 241, 255)
+WHITE_SILVER = Color(189, 195, 199, 255)
+GRAY_CONCRETE = Color(149, 165, 166, 255)
+GRAY_ASBESTOS = Color(127, 140, 141, 255)
BLACK = BLACK
__all__ = [
diff --git a/doc/api_docs/arcade.rst b/doc/api_docs/arcade.rst
index 01b2180f19..a541e0500f 100644
--- a/doc/api_docs/arcade.rst
+++ b/doc/api_docs/arcade.rst
@@ -69,3 +69,4 @@ for the Python Arcade library. See also:
arcade.key
arcade.csscolor
arcade.color
+ arcade.uicolor
diff --git a/doc/api_docs/arcade.uicolor.rst b/doc/api_docs/arcade.uicolor.rst
new file mode 100644
index 0000000000..9a2e5cf26e
--- /dev/null
+++ b/doc/api_docs/arcade.uicolor.rst
@@ -0,0 +1,19 @@
+.. _uicolor:
+
+arcade.uicolor package
+====================
+
+.. _FlatUI: https://materialui.co/flatuicolors/
+
+This module contains colors from MaterialUI's `FlatUI`_ palette.
+
+.. note:: `WHITE` and `BLACK` are aliases.
+
+ These are imported from `arcade.color`.
+
+You can specify colors four ways:
+
+* Standard CSS color names :ref:`csscolor`: ``arcade.csscolor.RED``
+* Nonstandard color names (this package): ``arcade.color.RED``
+* Three-byte numbers: ``(255, 0, 0)``
+* Four-byte numbers (fourth byte is transparency. 0 transparent, 255 opaque): ``(255, 0, 0, 255)``
diff --git a/doc/conf.py b/doc/conf.py
index 74ec6a8f13..5cf0773198 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -382,7 +382,8 @@ def _get_dir(app, path):
generate_color_table(_get_dir(_app, "color/__init__.py"), source)
elif doc_name == "api_docs/arcade.csscolor":
generate_color_table(_get_dir(_app, "csscolor/__init__.py"), source)
-
+ elif doc_name == "api_docs/arcade.uicolor":
+ generate_color_table(_get_dir(_app, "uicolor.py"), source)
def on_autodoc_process_bases(app, name, obj, options, bases):
"""We don't care about the `object` base class, so remove it from the list of bases."""
From eb94d3d9cf77700a3b56df24b47d9ebec1b1506b Mon Sep 17 00:00:00 2001
From: pushfoo <36696816+pushfoo@users.noreply.github.com>
Date: Wed, 16 Oct 2024 12:19:44 -0400
Subject: [PATCH 4/5] Add alpha grid and centering to resource images
---
doc/_static/css/custom.css | 7 +++++++
util/create_resources_listing.py | 6 +++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/doc/_static/css/custom.css b/doc/_static/css/custom.css
index ec03a4a33c..0f30b0db5d 100644
--- a/doc/_static/css/custom.css
+++ b/doc/_static/css/custom.css
@@ -217,6 +217,13 @@ table.dataTable.display tbody tr.even > .sorting_1 {
table.resource-table {
empty-cells: hide;
}
+/* Make the resource page's table cell contents look neat */
+table.resource-table td {
+ text-align: center;
+}
+table.resource-table td > img {
+ display: inline-block;
+}
table.colorTable {
border-width: 1px;
}
diff --git a/util/create_resources_listing.py b/util/create_resources_listing.py
index 2562560f74..639a556966 100644
--- a/util/create_resources_listing.py
+++ b/util/create_resources_listing.py
@@ -175,7 +175,11 @@ def process_resource_files(out, file_list: List[Path]):
name = path.name
resource_copyable = f"{create_resource_path(path)}"
if suffix in [".png", ".jpg", ".gif", ".svg"]:
- out.write(f" {start_row} - .. image:: ../../{resource_path}\n\n")
+ out.write(f" {start_row} - .. image:: ../../{resource_path}\n")
+ # IMPORTANT:
+ # 1. 11 chars to match the start of "image" above
+ # 2. :class: checkered-bg to apply the checkers to transparent images
+ out.write(f" :class: checkered-bg\n\n")
out.write(f" {name}\n")
elif suffix in SUFFIX_TO_AUDIO_TYPE:
file_path = FMT_URL_REF_EMBED.format(resource_path)
From 9687bf6c29dab997a328cf5d9e07b6d6592f7dbd Mon Sep 17 00:00:00 2001
From: pushfoo <36696816+pushfoo@users.noreply.github.com>
Date: Wed, 16 Oct 2024 12:31:23 -0400
Subject: [PATCH 5/5] Fix too-short title underline
---
doc/api_docs/arcade.uicolor.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/api_docs/arcade.uicolor.rst b/doc/api_docs/arcade.uicolor.rst
index 9a2e5cf26e..0166f2c843 100644
--- a/doc/api_docs/arcade.uicolor.rst
+++ b/doc/api_docs/arcade.uicolor.rst
@@ -1,7 +1,7 @@
.. _uicolor:
arcade.uicolor package
-====================
+======================
.. _FlatUI: https://materialui.co/flatuicolors/