diff --git a/black-white/icon.png b/black-white/icon.png new file mode 100644 index 0000000..1ad638d Binary files /dev/null and b/black-white/icon.png differ diff --git a/black-white/metadata.json b/black-white/metadata.json index 3e25e5c..c484b65 100644 --- a/black-white/metadata.json +++ b/black-white/metadata.json @@ -1,8 +1,8 @@ { "$schema": "https://gitlab.com/qu1ck/kicad/-/raw/pcm/kicad/pcm/schemas/pcm.v1.schema.json#", - "name": "black-white theme", - "description": "black-white color theme", - "description_full": "black-white color theme", + "name": "Black-White Theme", + "description": "Black-White color theme", + "description_full": "Black-White color theme", "identifier": "theme-black-white", "type": "colortheme", "author": { diff --git a/black-white/theme-black-white_v1.0_pcm.zip b/black-white/theme-black-white_v1.0_pcm.zip index a1dbd1d..ddc9104 100644 Binary files a/black-white/theme-black-white_v1.0_pcm.zip and b/black-white/theme-black-white_v1.0_pcm.zip differ diff --git a/create_icon.py b/create_icon.py new file mode 100644 index 0000000..6c75487 --- /dev/null +++ b/create_icon.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 + +import argparse +import json +import re + +from pathlib import Path + +ROOT_PATH = Path(__file__).resolve().parent +ICON_EESCHEMA_SVG = ROOT_PATH / "icon_sch_base.svg" +METADATA_FILEAME = "metadata.json" + +REPLACEMENT_TABLE = { + "#d0c5ac": "background", + "#00ff00": "wire", + "#999999": "component_body", + "#ff0000": "component_outline", + "#0000ff": "pin", + "#ff6600": "pin_name", + "#ffff00": "pin_number", + "#000080": "reference", + "#800080": "value" +} + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Create SVG icon applied by color scheme') + parser.add_argument('theme_dir', type=str) + + args = parser.parse_args() + + theme_dir = Path(args.theme_dir) + if not theme_dir.is_dir(): + print(f"{theme_dir} is not a directory") + exit(1) + + for theme_file in theme_dir.glob("*.json"): + if theme_file.name != METADATA_FILEAME: + with theme_file.open("r") as f: + print(f"found {theme_file}") + theme_json = json.load(f) + break + else: + print(f"no .json found in {theme_dir}") + exit(1) + + with ICON_EESCHEMA_SVG.open("r") as f: + svg_data = f.read() + + for orig_color, replacement in REPLACEMENT_TABLE.items(): + replacement_str = theme_json['schematic'][replacement] + match = re.match(r"\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)", replacement_str) + if not match: + print(f"cannot find color for {replacement} in theme!") + exit(1) + red, green, blue = match.groups() + replacement_color = f"#{int(red):02X}{int(green):02X}{int(blue):02X}" + print(f"{replacement} = {replacement_color}") + replace_regex = re.compile(re.escape(orig_color), re.IGNORECASE) + svg_data = replace_regex.sub(replacement_color, svg_data) + + #svg_data = svg_data.replace(orig_color, replacement_color) + + icon_file = theme_dir / "icon.svg" + with icon_file.open("w") as f: + f.write(svg_data) diff --git a/create_repository.py b/create_repository.py index ec869da..98173ef 100644 --- a/create_repository.py +++ b/create_repository.py @@ -3,7 +3,6 @@ import datetime import hashlib import json -import ntpath import zipfile from pathlib import Path diff --git a/icon_sch_base.svg b/icon_sch_base.svg new file mode 100755 index 0000000..79e2ea4 --- /dev/null +++ b/icon_sch_base.svg @@ -0,0 +1,364 @@ + + + + + + + + + + image/svg+xml + + add_arc + + + + + + + + + + + + + + + + + + icon_eeschema + + + + + + + + + + + + + + + + + + + U1 + LM747 + + + + + + + + + + + + + + + + + diff --git a/packages.json b/packages.json index fdcbe96..8a1861c 100644 --- a/packages.json +++ b/packages.json @@ -2,9 +2,9 @@ "packages": [ { "$schema": "https://gitlab.com/qu1ck/kicad/-/raw/pcm/kicad/pcm/schemas/pcm.v1.schema.json#", - "name": "black-white theme", - "description": "black-white color theme", - "description_full": "black-white color theme", + "name": "Black-White Theme", + "description": "Black-White color theme", + "description_full": "Black-White color theme", "identifier": "theme-black-white", "type": "colortheme", "author": { @@ -28,18 +28,18 @@ "version": "1.0", "status": "stable", "kicad_version": "5.99", - "download_sha256": "6bdec83d2a59d35513cc92d424d7717db01793cb30b9f3a1b20fe20191fd333c", - "download_size": 840, + "download_sha256": "5b35ad2d3c910d053c27a9494ce7729e7bc4436591844e4829586a984953f937", + "download_size": 3883, "download_url": "https://raw.githubusercontent.com/pointhi/kicad-color-schemes/master/black-white/theme-black-white_v1.0_pcm.zip", - "install_size": 1928 + "install_size": 4847 } ] }, { "$schema": "https://gitlab.com/qu1ck/kicad/-/raw/pcm/kicad/pcm/schemas/pcm.v1.schema.json#", - "name": "solarized-dark theme", - "description": "solarized-dark color theme", - "description_full": "solarized-dark color theme", + "name": "Solarized Dark Theme", + "description": "Solarized Dark color theme", + "description_full": "Solarized Dark color theme", "identifier": "theme-solarized-dark", "type": "colortheme", "author": { @@ -63,18 +63,18 @@ "version": "1.0", "status": "stable", "kicad_version": "5.99", - "download_sha256": "1722e017ec4c406e5b83c34d384859aca802ed3c773389423ce245431fc4397f", - "download_size": 922, + "download_sha256": "0a99069b18a16536f48d45f5047749d58b5151736978c8652ea826d804c3ce54", + "download_size": 4225, "download_url": "https://raw.githubusercontent.com/pointhi/kicad-color-schemes/master/solarized-dark/theme-solarized-dark_v1.0_pcm.zip", - "install_size": 1954 + "install_size": 5135 } ] }, { "$schema": "https://gitlab.com/qu1ck/kicad/-/raw/pcm/kicad/pcm/schemas/pcm.v1.schema.json#", - "name": "solarized-light theme", - "description": "solarized-light color theme", - "description_full": "solarized-light color theme", + "name": "Solarized Light Theme", + "description": "Solarized Light color theme", + "description_full": "Solarized Light color theme", "identifier": "theme-solarized-light", "type": "colortheme", "author": { @@ -98,10 +98,10 @@ "version": "1.0", "status": "stable", "kicad_version": "5.99", - "download_sha256": "69b95828244851185058788f105a38d9e0f4bf88b5365bc480cac2cfc52d7687", - "download_size": 930, + "download_sha256": "3a07a48c9d886a4540e6b29534fd6319a454a5cbd5b0efc93a085bf2827b520c", + "download_size": 4221, "download_url": "https://raw.githubusercontent.com/pointhi/kicad-color-schemes/master/solarized-light/theme-solarized-light_v1.0_pcm.zip", - "install_size": 1964 + "install_size": 5132 } ] } diff --git a/repository.json b/repository.json index fffe066..a6191db 100644 --- a/repository.json +++ b/repository.json @@ -8,9 +8,9 @@ }, "name": "kicad-color-schemes repository by @pointhi", "packages": { - "sha256": "b8e07357a55e18d74401f9399f4cf2e2159d3e568cb8bc5264136865e7f4f28a", - "update_time_utc": "2021-10-30 16:13:14", - "update_timestamp": 1635610394, + "sha256": "f38236ad8fbd0b55af465a95952c8bfb0a5ff722112c6273fa71290cd8eda04a", + "update_time_utc": "2021-10-30 20:45:45", + "update_timestamp": 1635626745, "url": "https://raw.githubusercontent.com/pointhi/kicad-color-schemes/master/packages.json" } } \ No newline at end of file diff --git a/solarized-dark/icon.png b/solarized-dark/icon.png new file mode 100644 index 0000000..7adf349 Binary files /dev/null and b/solarized-dark/icon.png differ diff --git a/solarized-dark/metadata.json b/solarized-dark/metadata.json index 4292e5c..d8a6c40 100644 --- a/solarized-dark/metadata.json +++ b/solarized-dark/metadata.json @@ -1,8 +1,8 @@ { "$schema": "https://gitlab.com/qu1ck/kicad/-/raw/pcm/kicad/pcm/schemas/pcm.v1.schema.json#", - "name": "solarized-dark theme", - "description": "solarized-dark color theme", - "description_full": "solarized-dark color theme", + "name": "Solarized Dark Theme", + "description": "Solarized Dark color theme", + "description_full": "Solarized Dark color theme", "identifier": "theme-solarized-dark", "type": "colortheme", "author": { diff --git a/solarized-dark/theme-solarized-dark_v1.0_pcm.zip b/solarized-dark/theme-solarized-dark_v1.0_pcm.zip index 08c889d..76e41d8 100644 Binary files a/solarized-dark/theme-solarized-dark_v1.0_pcm.zip and b/solarized-dark/theme-solarized-dark_v1.0_pcm.zip differ diff --git a/solarized-light/icon.png b/solarized-light/icon.png new file mode 100644 index 0000000..481cf2a Binary files /dev/null and b/solarized-light/icon.png differ diff --git a/solarized-light/metadata.json b/solarized-light/metadata.json index a6a0765..af0d5de 100644 --- a/solarized-light/metadata.json +++ b/solarized-light/metadata.json @@ -1,8 +1,8 @@ { "$schema": "https://gitlab.com/qu1ck/kicad/-/raw/pcm/kicad/pcm/schemas/pcm.v1.schema.json#", - "name": "solarized-light theme", - "description": "solarized-light color theme", - "description_full": "solarized-light color theme", + "name": "Solarized Light Theme", + "description": "Solarized Light color theme", + "description_full": "Solarized Light color theme", "identifier": "theme-solarized-light", "type": "colortheme", "author": { diff --git a/solarized-light/theme-solarized-light_v1.0_pcm.zip b/solarized-light/theme-solarized-light_v1.0_pcm.zip index 86f4b1a..02438b3 100644 Binary files a/solarized-light/theme-solarized-light_v1.0_pcm.zip and b/solarized-light/theme-solarized-light_v1.0_pcm.zip differ