Compare commits
	
		
			3 Commits
		
	
	
		
			50f2df77df
			...
			586fd61781
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 586fd61781 | |
|  | 8ac998ef7d | |
|  | 1fda5e0138 | 
|  | @ -1,2 +1,3 @@ | ||||||
|  | .direnv/ | ||||||
| # Don't include rendered JPEGs and PNGs in git. | # Don't include rendered JPEGs and PNGs in git. | ||||||
| public/**/*.png | public/**/*.png | ||||||
|  |  | ||||||
|  | @ -0,0 +1,59 @@ | ||||||
|  | { | ||||||
|  |   "nodes": { | ||||||
|  |     "flake-utils": { | ||||||
|  |       "inputs": { | ||||||
|  |         "systems": "systems" | ||||||
|  |       }, | ||||||
|  |       "locked": { | ||||||
|  |         "lastModified": 1705309234, | ||||||
|  |         "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", | ||||||
|  |         "owner": "numtide", | ||||||
|  |         "repo": "flake-utils", | ||||||
|  |         "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", | ||||||
|  |         "type": "github" | ||||||
|  |       }, | ||||||
|  |       "original": { | ||||||
|  |         "owner": "numtide", | ||||||
|  |         "repo": "flake-utils", | ||||||
|  |         "type": "github" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "nixpkgs": { | ||||||
|  |       "locked": { | ||||||
|  |         "lastModified": 1705242415, | ||||||
|  |         "narHash": "sha256-a8DRYrNrzTudvO7XHUPNJD89Wbf1ZZT0VbwCsPnHWaE=", | ||||||
|  |         "owner": "NixOS", | ||||||
|  |         "repo": "nixpkgs", | ||||||
|  |         "rev": "ea780f3de2d169f982564128804841500e85e373", | ||||||
|  |         "type": "github" | ||||||
|  |       }, | ||||||
|  |       "original": { | ||||||
|  |         "id": "nixpkgs", | ||||||
|  |         "type": "indirect" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "root": { | ||||||
|  |       "inputs": { | ||||||
|  |         "flake-utils": "flake-utils", | ||||||
|  |         "nixpkgs": "nixpkgs" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "systems": { | ||||||
|  |       "locked": { | ||||||
|  |         "lastModified": 1681028828, | ||||||
|  |         "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | ||||||
|  |         "owner": "nix-systems", | ||||||
|  |         "repo": "default", | ||||||
|  |         "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | ||||||
|  |         "type": "github" | ||||||
|  |       }, | ||||||
|  |       "original": { | ||||||
|  |         "owner": "nix-systems", | ||||||
|  |         "repo": "default", | ||||||
|  |         "type": "github" | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   "root": "root", | ||||||
|  |   "version": 7 | ||||||
|  | } | ||||||
|  | @ -0,0 +1,13 @@ | ||||||
|  | { | ||||||
|  |   inputs.flake-utils.url = "github:numtide/flake-utils"; | ||||||
|  | 
 | ||||||
|  |   outputs = { self, nixpkgs, flake-utils }: | ||||||
|  |     flake-utils.lib.eachDefaultSystem (system: | ||||||
|  |       let | ||||||
|  |         pkgs = nixpkgs.legacyPackages.${system}; | ||||||
|  |       in | ||||||
|  |       { | ||||||
|  |         devShells.default = import ./shell.nix { inherit pkgs; }; | ||||||
|  |       } | ||||||
|  |     ); | ||||||
|  | } | ||||||
							
								
								
									
										14
									
								
								render.py
								
								
								
								
							
							
						
						
									
										14
									
								
								render.py
								
								
								
								
							|  | @ -2,7 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| from pathlib import Path | from pathlib import Path | ||||||
| from subprocess import run | from subprocess import run | ||||||
| from typing import List, Optional | from typing import List, Optional, Tuple | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def main() -> None: | def main() -> None: | ||||||
|  | @ -14,8 +14,7 @@ def main() -> None: | ||||||
|                 convert_to_image( |                 convert_to_image( | ||||||
|                     source=svg, |                     source=svg, | ||||||
|                     destination=svg.with_name(f"{svg.stem}-{resolution}.png"), |                     destination=svg.with_name(f"{svg.stem}-{resolution}.png"), | ||||||
|                     width=resolution, |                     resolution=(resolution, resolution), | ||||||
|                     height=resolution, |  | ||||||
|                 ) |                 ) | ||||||
|         else: |         else: | ||||||
|             convert_to_image(source=svg, destination=svg.with_suffix(".png")) |             convert_to_image(source=svg, destination=svg.with_suffix(".png")) | ||||||
|  | @ -24,19 +23,20 @@ def main() -> None: | ||||||
| def convert_to_image( | def convert_to_image( | ||||||
|     source: Path, |     source: Path, | ||||||
|     destination: Path, |     destination: Path, | ||||||
|     width: Optional[int] = None, |     resolution: Optional[Tuple[int, int]] = None, | ||||||
|     height: Optional[int] = None, |  | ||||||
| ) -> None: | ) -> None: | ||||||
|  |     """Convert an SVG to an image with `inkscape`.""" | ||||||
|     inkscape_args: List[str] = ["inkscape", str(source), "-o", str(destination)] |     inkscape_args: List[str] = ["inkscape", str(source), "-o", str(destination)] | ||||||
| 
 | 
 | ||||||
|     if width is not None and height is not None: |     if resolution is not None: | ||||||
|         inkscape_args.extend(["-w", str(width), "-h", str(height)]) |         inkscape_args.extend(["-w", str(resolution[0]), "-h", str(resolution[1])]) | ||||||
| 
 | 
 | ||||||
|     run(args=inkscape_args) |     run(args=inkscape_args) | ||||||
|     mat2_image(destination) |     mat2_image(destination) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def mat2_image(image: Path) -> None: | def mat2_image(image: Path) -> None: | ||||||
|  |     """Run `mat2` on the image path.""" | ||||||
|     run(args=["mat2", "--inplace", image]) |     run(args=["mat2", "--inplace", image]) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue