bug fixes

This commit is contained in:
alcoholicgirl
2026-04-27 01:26:42 +08:00
parent 5d93af0666
commit b720504e48
5 changed files with 7 additions and 7 deletions

View File

@ -9,10 +9,11 @@ cmd_marchtoy = on_command("march")
async def _(args: Message = CommandArg()):
if cmd := args.extract_plain_text():
try:
img = await render.render(cmd, (256, 256))
img = await render.render(cmd, (512, 512))
buffer = io.BytesIO()
# img.show()
img.save(buffer, format="PNG")
buffer.seek(0)
await cmd_marchtoy.send(await UniMessage().image(raw=buffer).export())
except Exception as e:
await cmd_marchtoy.send(await Message(message=f"发生了错误: {e}"))
await cmd_marchtoy.send(await UniMessage.text(f"发生了错误: {e}").export())

View File

@ -67,7 +67,6 @@ class CommandParser:
return Command(cmd_id, cmd_args)
raise StopIteration
class Scene:
def __init__(self, _instruction: str) -> None:
self.canvas_objs: list[tuple[Object, str]] = []

View File

@ -19,8 +19,8 @@ async def render(command: str, res: tuple[int, int]):
vertex_shader=vs,
fragment_shader=fs
)
except Exception as _:
raise Exception("cannot compile glsl")
except Exception as e:
raise Exception(f"cannot compile glsl: {e}") from e
uniform = program['u_resolution']
uniform.write(np.array(res, dtype=np.float32))
vertices = np.array([-1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0], dtype=np.float32)

View File

@ -21,7 +21,7 @@ class Transform:
@staticmethod
def normalize(p: np.ndarray) -> np.ndarray:
return p / np.sqrt(np.dot(p, p))
return p / (np.sqrt(np.dot(p, p)) + 1e-8)
def translate(self, x: float, y: float, z: float):
mat = np.identity(4, dtype=np.float32)

View File

@ -6,7 +6,7 @@
#define float2 vec2
const float EPS = 0.001;
const int MAX_ITER = 64;
const int MAX_ITER = 128;
uniform vec2 u_resolution;
out vec4 fragColor;