Compare commits
No commits in common. "d05e382063e35126255f127b87b6d564cdbae4ce" and "c478ee23db13631ac3f878f89fb1964ef6e13132" have entirely different histories.
d05e382063
...
c478ee23db
@ -19,6 +19,6 @@ pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
|
|||||||
pip.parse(
|
pip.parse(
|
||||||
hub_name = "pytools_deps",
|
hub_name = "pytools_deps",
|
||||||
python_version = "3.10",
|
python_version = "3.10",
|
||||||
requirements_lock = "//pytools:requirements.lock",
|
requirements_lock = "//pytools:requirements.txt",
|
||||||
)
|
)
|
||||||
use_repo(pip, "pytools_deps")
|
use_repo(pip, "pytools_deps")
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"lockFileVersion": 3,
|
"lockFileVersion": 3,
|
||||||
"moduleFileHash": "b7a605dff62d0b97615cf1feb669dc4d3ce630abf1e74374f624b71287684b40",
|
"moduleFileHash": "f69bdb13b0df2f6d309d415437228ebef31fa559567a65ecfe60de77e328ae1d",
|
||||||
"flags": {
|
"flags": {
|
||||||
"cmdRegistries": [
|
"cmdRegistries": [
|
||||||
"https://bcr.bazel.build/"
|
"https://bcr.bazel.build/"
|
||||||
@ -72,7 +72,7 @@
|
|||||||
"attributeValues": {
|
"attributeValues": {
|
||||||
"hub_name": "pytools_deps",
|
"hub_name": "pytools_deps",
|
||||||
"python_version": "3.10",
|
"python_version": "3.10",
|
||||||
"requirements_lock": "//pytools:requirements.lock"
|
"requirements_lock": "//pytools:requirements.txt"
|
||||||
},
|
},
|
||||||
"devDependency": false,
|
"devDependency": false,
|
||||||
"location": {
|
"location": {
|
||||||
@ -1741,60 +1741,10 @@
|
|||||||
"os:windows,arch:amd64": {
|
"os:windows,arch:amd64": {
|
||||||
"bzlTransitiveDigest": "EY+DGyyJhrqMHBCiplU6kCYiNtiUXl3Olt6+vF4JnfE=",
|
"bzlTransitiveDigest": "EY+DGyyJhrqMHBCiplU6kCYiNtiUXl3Olt6+vF4JnfE=",
|
||||||
"accumulatedFileDigests": {
|
"accumulatedFileDigests": {
|
||||||
"@@//pytools:requirements.lock": "5a2eed9c6e50e9034521853f6016123e3e526900ddf3ff81cc1dbaaa28683629"
|
"@@//pytools:requirements.txt": "ecb2c096486b1bb4dbe407a48fb3375ba496b6ea658c0cd7fc34571f381cd504"
|
||||||
},
|
},
|
||||||
"envVariables": {},
|
"envVariables": {},
|
||||||
"generatedRepoSpecs": {
|
"generatedRepoSpecs": {
|
||||||
"pytools_deps_310_jinja2": {
|
|
||||||
"bzlFile": "@@rules_python~0.31.0//python/pip_install:pip_repository.bzl",
|
|
||||||
"ruleClassName": "whl_library",
|
|
||||||
"attributes": {
|
|
||||||
"name": "rules_python~0.31.0~pip~pytools_deps_310_jinja2",
|
|
||||||
"requirement": "Jinja2==3.1.3",
|
|
||||||
"repo": "pytools_deps_310",
|
|
||||||
"repo_prefix": "pytools_deps_310_",
|
|
||||||
"whl_patches": {},
|
|
||||||
"experimental_target_platforms": [],
|
|
||||||
"python_interpreter": "",
|
|
||||||
"python_interpreter_target": "@@rules_python~0.31.0~python~python_3_10_host//:python",
|
|
||||||
"quiet": true,
|
|
||||||
"timeout": 600,
|
|
||||||
"isolated": true,
|
|
||||||
"extra_pip_args": [],
|
|
||||||
"download_only": false,
|
|
||||||
"pip_data_exclude": [],
|
|
||||||
"enable_implicit_namespace_pkgs": false,
|
|
||||||
"environment": {},
|
|
||||||
"envsubst": [],
|
|
||||||
"group_name": "",
|
|
||||||
"group_deps": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pytools_deps_310_markupsafe": {
|
|
||||||
"bzlFile": "@@rules_python~0.31.0//python/pip_install:pip_repository.bzl",
|
|
||||||
"ruleClassName": "whl_library",
|
|
||||||
"attributes": {
|
|
||||||
"name": "rules_python~0.31.0~pip~pytools_deps_310_markupsafe",
|
|
||||||
"requirement": "MarkupSafe==2.1.5",
|
|
||||||
"repo": "pytools_deps_310",
|
|
||||||
"repo_prefix": "pytools_deps_310_",
|
|
||||||
"whl_patches": {},
|
|
||||||
"experimental_target_platforms": [],
|
|
||||||
"python_interpreter": "",
|
|
||||||
"python_interpreter_target": "@@rules_python~0.31.0~python~python_3_10_host//:python",
|
|
||||||
"quiet": true,
|
|
||||||
"timeout": 600,
|
|
||||||
"isolated": true,
|
|
||||||
"extra_pip_args": [],
|
|
||||||
"download_only": false,
|
|
||||||
"pip_data_exclude": [],
|
|
||||||
"enable_implicit_namespace_pkgs": false,
|
|
||||||
"environment": {},
|
|
||||||
"envsubst": [],
|
|
||||||
"group_name": "",
|
|
||||||
"group_deps": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pytools_deps_310_pillow": {
|
"pytools_deps_310_pillow": {
|
||||||
"bzlFile": "@@rules_python~0.31.0//python/pip_install:pip_repository.bzl",
|
"bzlFile": "@@rules_python~0.31.0//python/pip_install:pip_repository.bzl",
|
||||||
"ruleClassName": "whl_library",
|
"ruleClassName": "whl_library",
|
||||||
@ -1836,12 +1786,6 @@
|
|||||||
"name": "rules_python~0.31.0~pip~pytools_deps",
|
"name": "rules_python~0.31.0~pip~pytools_deps",
|
||||||
"repo_name": "pytools_deps",
|
"repo_name": "pytools_deps",
|
||||||
"whl_map": {
|
"whl_map": {
|
||||||
"jinja2": [
|
|
||||||
"3.10"
|
|
||||||
],
|
|
||||||
"markupsafe": [
|
|
||||||
"3.10"
|
|
||||||
],
|
|
||||||
"pillow": [
|
"pillow": [
|
||||||
"3.10"
|
"3.10"
|
||||||
]
|
]
|
||||||
|
@ -15,11 +15,3 @@ $ bazel run -c opt sdl_host.exe
|
|||||||
```
|
```
|
||||||
$ bazel run sdl_host.exe
|
$ bazel run sdl_host.exe
|
||||||
```
|
```
|
||||||
|
|
||||||
## Dump requirements
|
|
||||||
|
|
||||||
(TODO: Automate)
|
|
||||||
|
|
||||||
```
|
|
||||||
$ pip freeze -r requirements.txt > requirements.lock
|
|
||||||
```
|
|
@ -2,10 +2,9 @@ load("@pytools_deps//:requirements.bzl", "requirement")
|
|||||||
|
|
||||||
py_binary(
|
py_binary(
|
||||||
name = "font",
|
name = "font",
|
||||||
srcs = ["font.py", "shared.py"],
|
srcs = ["font.py"],
|
||||||
deps = [
|
deps = [
|
||||||
requirement("pillow"),
|
requirement("pillow"),
|
||||||
requirement("Jinja2"),
|
|
||||||
],
|
],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
@ -1,13 +1,6 @@
|
|||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import sys
|
import sys
|
||||||
import shared
|
|
||||||
|
|
||||||
TEMPLATE = """
|
|
||||||
// generated code! be nice!
|
|
||||||
#include "sys/sys.h"
|
|
||||||
sys_glyph {{ font_name }}[{{ n_glyphs }}] = { {{- glyphs|join(", ") -}} };
|
|
||||||
""".lstrip()
|
|
||||||
|
|
||||||
|
|
||||||
def main(font_name, n_glyphs, fname_png, fname_c):
|
def main(font_name, n_glyphs, fname_png, fname_c):
|
||||||
@ -15,17 +8,22 @@ def main(font_name, n_glyphs, fname_png, fname_c):
|
|||||||
assert(len(glyphs) == n_glyphs), f"must be exactly {n_glyphs} glyphs"
|
assert(len(glyphs) == n_glyphs), f"must be exactly {n_glyphs} glyphs"
|
||||||
|
|
||||||
with open(fname_c, "wt") as output:
|
with open(fname_c, "wt") as output:
|
||||||
output.write(
|
output.writelines([
|
||||||
shared.templates.from_string(TEMPLATE).render(
|
"// generated code! be nice!\n",
|
||||||
font_name=font_name,
|
"#include \"sys/sys.h\"\n",
|
||||||
n_glyphs=n_glyphs,
|
f"sys_glyph {font_name}[{n_glyphs}] = {{{', '.join(str(g) for g in glyphs)}}};\n"
|
||||||
glyphs=glyphs,
|
])
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def load_glyphs(fname_png: str):
|
def load_glyphs(fname_png: str):
|
||||||
width, height, data = shared.load_image(fname_png)
|
with Image.open(fname_png) as im:
|
||||||
|
width = im.width
|
||||||
|
height = im.height
|
||||||
|
|
||||||
|
assert width % 8 == 0, "width must be a multiple of 8"
|
||||||
|
assert height % 8 == 0, "height must be a multiple of 8"
|
||||||
|
|
||||||
|
data = list(im.convert("RGBA").getdata())
|
||||||
monochrome = [pixel_to_monochrome(p) for p in data]
|
monochrome = [pixel_to_monochrome(p) for p in data]
|
||||||
|
|
||||||
glyphs = []
|
glyphs = []
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
pillow==10.2.0
|
|
||||||
Jinja2==3.1.3
|
|
||||||
## The following requirements were added by pip freeze:
|
|
||||||
MarkupSafe==2.1.5
|
|
@ -1,2 +1 @@
|
|||||||
pillow==10.2.0
|
pillow==10.2.0
|
||||||
Jinja2==3.1.3
|
|
@ -1,17 +0,0 @@
|
|||||||
from PIL import Image
|
|
||||||
from jinja2 import Environment, BaseLoader, select_autoescape
|
|
||||||
|
|
||||||
templates = Environment(
|
|
||||||
loader=BaseLoader(),
|
|
||||||
autoescape=select_autoescape(),
|
|
||||||
)
|
|
||||||
|
|
||||||
def load_image(fname):
|
|
||||||
with Image.open(fname) as im:
|
|
||||||
width = im.width
|
|
||||||
height = im.height
|
|
||||||
|
|
||||||
assert width % 8 == 0, "width must be a multiple of 8"
|
|
||||||
assert height % 8 == 0, "height must be a multiple of 8"
|
|
||||||
|
|
||||||
return width, height, list(im.convert("RGBA").getdata())
|
|
@ -3,18 +3,10 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define SYS_COLOR_TRANSPARENT 255
|
|
||||||
#define SYS_COLOR_N 256
|
|
||||||
#define SYS_SPRITE_H 8
|
|
||||||
#define SYS_SPRITE_W 8
|
|
||||||
|
|
||||||
typedef int32_t sys_i32;
|
typedef int32_t sys_i32;
|
||||||
typedef uint8_t sys_color;
|
typedef uint8_t sys_color;
|
||||||
typedef uint32_t sys_screen_color;
|
typedef uint32_t sys_screen_color;
|
||||||
typedef uint64_t sys_glyph;
|
typedef uint64_t sys_glyph;
|
||||||
typedef struct {
|
|
||||||
sys_color pixels[SYS_SPRITE_H][SYS_SPRITE_W];
|
|
||||||
} sys_sprite;
|
|
||||||
|
|
||||||
sys_screen_color sys_make_screen_color(uint8_t r, uint8_t g, uint8_t b);
|
sys_screen_color sys_make_screen_color(uint8_t r, uint8_t g, uint8_t b);
|
||||||
|
|
||||||
@ -23,4 +15,7 @@ sys_i32 sys_min_i32(sys_i32 x, sys_i32 y);
|
|||||||
sys_i32 sys_abs_i32(sys_i32 x);
|
sys_i32 sys_abs_i32(sys_i32 x);
|
||||||
sys_i32 sys_sgn_i32(sys_i32 x);
|
sys_i32 sys_sgn_i32(sys_i32 x);
|
||||||
|
|
||||||
|
#define SYS_COLOR_TRANSPARENT 255
|
||||||
|
#define SYS_COLOR_N 256
|
||||||
|
|
||||||
#endif // CROCPARTY_SYS_DATA_H
|
#endif // CROCPARTY_SYS_DATA_H
|
Loading…
Reference in New Issue
Block a user