forked from mttu-developers/konabot
Compare commits
10 Commits
raymarch_t
...
b4f167e5f6
| Author | SHA1 | Date | |
|---|---|---|---|
| b4f167e5f6 | |||
| b720504e48 | |||
| 5d93af0666 | |||
| 24e59a7f52 | |||
| 197535cd34 | |||
| c3c22e7145 | |||
| 6a68db70f5 | |||
| 3f3a375dd6 | |||
| facd2d0e84 | |||
| cc97ca5493 |
@ -1,4 +1,22 @@
|
||||
# 指令介绍
|
||||
简易 Raymarch 小玩具
|
||||
用法:march <scene>
|
||||
例:march sphere(1) cam(4).pos(-5).lookat(0)
|
||||
例:march sphere(1).color(red) box(0.5, 2.0, 0.5).pos(0, 0, 0) cam(0.5).pos(-5).lookat(0)
|
||||
|
||||
# 主要语法
|
||||
<scene> ::= <scene> "." <op>
|
||||
| <obj>
|
||||
|
||||
<obj> ::= <obj_ty>
|
||||
| <obj_ty> "(" <args> ")"
|
||||
|
||||
<op> ::= <op_ty>
|
||||
| <op_ty> "(" <args> ")"
|
||||
|
||||
<args> ::= <args> "," <arg>
|
||||
| <arg>
|
||||
|
||||
其中 obj_ty、op_ty 分别为物体类型(如 cube、sphere、torus 等)与变换类型(如 pos、rot)。
|
||||
|
||||
# 特殊说明
|
||||
<op_ty> 不包含 scale,因为本工具基于 SDF 渲染,非正交的变换会破坏 SDF 的性质。
|
||||
@ -2,14 +2,18 @@ from nonebot import on_command
|
||||
from nonebot.adapters import Message
|
||||
from nonebot_plugin_alconna import UniMessage
|
||||
from nonebot.params import CommandArg
|
||||
import render
|
||||
import konabot.plugins.marchtoy.gl_render as render
|
||||
import io
|
||||
cmd_marchtoy = on_command("march", priority=10, block=True)
|
||||
cmd_marchtoy = on_command("march")
|
||||
@cmd_marchtoy.handle()
|
||||
async def _(args: Message = CommandArg()):
|
||||
if cmd := args.extract_plain_text():
|
||||
img = await render.render(cmd, 256, 256)
|
||||
buffer = io.BytesIO()
|
||||
img.save(buffer, format="PNG")
|
||||
buffer.seek(0)
|
||||
await cmd_marchtoy.send(await UniMessage().image(raw=buffer).export())
|
||||
try:
|
||||
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 UniMessage.text(f"发生了错误: {e}").export())
|
||||
@ -18,9 +18,9 @@ from dataclasses import dataclass
|
||||
import re
|
||||
import numpy as np
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
from konabot.plugins.marchtoy.obj import Object, Camera, OBJECT_ENTRIES
|
||||
from konabot.plugins.marchtoy.op import OPERATION_ENTRIES
|
||||
from typing import Optional
|
||||
|
||||
@dataclass
|
||||
class Command:
|
||||
@ -29,7 +29,7 @@ class Command:
|
||||
|
||||
|
||||
class CommandChainParser:
|
||||
CHAIN_PATTERN = r"^[a-zA-Z]+(\([^(]*\))?(\.[a-zA-Z]+(\([^(]*\))?)+"
|
||||
CHAIN_PATTERN = r"^[a-zA-Z]+(\([^(]*\))?(\.[a-zA-Z]+(\([^(]*\))?)*"
|
||||
|
||||
def __init__(self, _command_chain: str) -> None:
|
||||
self.command_chain = _command_chain
|
||||
@ -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]] = []
|
||||
@ -113,8 +112,8 @@ class Scene:
|
||||
def __str__(self) -> str:
|
||||
return ", ".join([str(type(obj)) for obj in self.canvas_objs])
|
||||
|
||||
def compile(self) -> str:
|
||||
PATH = pathlib.Path(__file__).parent / "shaders" / "raymarch.sksl"
|
||||
def compile(self, fs_src: str = "frag.glsl") -> str:
|
||||
PATH = pathlib.Path(__file__).parent / "shaders" / fs_src
|
||||
with PATH.open(encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
sdf_block: str = ""
|
||||
|
||||
35
konabot/plugins/marchtoy/gl_render.py
Normal file
35
konabot/plugins/marchtoy/gl_render.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""
|
||||
headless moderngl
|
||||
"""
|
||||
import pathlib
|
||||
import moderngl
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
from konabot.plugins.marchtoy.command import Scene
|
||||
|
||||
async def render(command: str, res: tuple[int, int]):
|
||||
fs = Scene(command).compile()
|
||||
PATH = pathlib.Path(__file__).parent / "shaders"
|
||||
with (PATH / "vert.glsl").open(encoding='utf-8') as f:
|
||||
vs = f.read()
|
||||
ctx = moderngl.create_context(standalone=True)
|
||||
ctx.gc_mode = "auto"
|
||||
try:
|
||||
program = ctx.program(
|
||||
vertex_shader=vs,
|
||||
fragment_shader=fs
|
||||
)
|
||||
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)
|
||||
indices = np.array([0, 1, 2, 1, 2, 3], dtype=np.int32)
|
||||
ibo = ctx.buffer(indices)
|
||||
vbo = ctx.buffer(vertices)
|
||||
vao = ctx.vertex_array(program, vbo, 'in_position', index_buffer = ibo)
|
||||
fbo = ctx.simple_framebuffer(res)
|
||||
fbo.use()
|
||||
fbo.clear(0.0, 0.0, 0.0, 0.0)
|
||||
vao.render(moderngl.TRIANGLES)
|
||||
return Image.frombytes('RGBA', fbo.size, fbo.read(components=4), 'raw', 'RGBA', 0, -1)
|
||||
@ -1,14 +1,14 @@
|
||||
import numpy as np
|
||||
from konabot.plugins.marchtoy.texture import Texture
|
||||
from konabot.plugins.marchtoy.utilities import ArgParser, SkslFormatter
|
||||
from konabot.plugins.marchtoy.utilities import ArgParser, Formatter
|
||||
|
||||
OBJECT_ENTRIES = {}
|
||||
|
||||
|
||||
def make_obj(name: str, aliases: list[str] = []):
|
||||
def make_obj(*name: str):
|
||||
def decorator(cls):
|
||||
OBJECT_ENTRIES[name] = cls
|
||||
for alias in aliases:
|
||||
# OBJECT_ENTRIES[name] = cls
|
||||
for alias in [*name]:
|
||||
OBJECT_ENTRIES[alias] = cls
|
||||
return cls
|
||||
|
||||
@ -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)
|
||||
@ -29,7 +29,7 @@ class Transform:
|
||||
self.t = mat @ self.t
|
||||
return self
|
||||
|
||||
# scale 会破坏 sdf 的性质,不应该使用
|
||||
# scale 会破坏 sdf 的性质 梯度大小会变 导致 overshoot 等问题
|
||||
def scale(self, x: float, y: float, z: float):
|
||||
mat = np.identity(4, dtype=np.float32)
|
||||
mat[0, 0], mat[1, 1], mat[2, 2] = x, y, z
|
||||
@ -65,7 +65,6 @@ class Transform:
|
||||
zaxis = Transform.normalize(q - p)
|
||||
xaxis = Transform.normalize(np.cross(zaxis, up))
|
||||
yaxis = Transform.normalize(np.cross(xaxis, zaxis))
|
||||
# 约定本地 -Z 为“朝前”,这样和 shader 中使用的相机射线方向保持一致。
|
||||
self.t[:3, 0] = xaxis
|
||||
self.t[:3, 1] = yaxis
|
||||
self.t[:3, 2] = -zaxis
|
||||
@ -73,7 +72,7 @@ class Transform:
|
||||
|
||||
def p_expr(self) -> str:
|
||||
inv = np.linalg.inv(self.t) # + 1e-5 * np.identity(4, dtype=np.float32))
|
||||
return f"({SkslFormatter.mat4(inv)} * float4(p, 1.0)).xyz"
|
||||
return f"({Formatter.float4(inv)} * vec4(p, 1.0)).xyz"
|
||||
|
||||
|
||||
class Object:
|
||||
@ -88,7 +87,7 @@ class Object:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@make_obj("cube")
|
||||
@make_obj("cube", "box")
|
||||
class Cube(Object):
|
||||
def __init__(self, _size: np.ndarray = np.array([1.0, 1.0, 1.0])) -> None:
|
||||
super().__init__()
|
||||
@ -98,10 +97,10 @@ class Cube(Object):
|
||||
self.size = ArgParser.as_vec3(args)
|
||||
|
||||
def sdf_block(self) -> str:
|
||||
return f"sdCube({self.transform.p_expr()}, float3({self.size[0]}, {self.size[1]}, {self.size[2]}))"
|
||||
return f"sdCube({self.transform.p_expr()}, vec3({self.size[0]}, {self.size[1]}, {self.size[2]}))"
|
||||
|
||||
|
||||
@make_obj("sphere")
|
||||
@make_obj("sphere", "ball")
|
||||
class Sphere(Object):
|
||||
def __init__(self, _radius: float = 1.0) -> None:
|
||||
super().__init__()
|
||||
@ -114,11 +113,62 @@ class Sphere(Object):
|
||||
return f"sdSphere({self.transform.p_expr()}, {self.radius})"
|
||||
|
||||
|
||||
@make_obj("camera", ["cam"])
|
||||
@make_obj("cylinder", "cyl")
|
||||
class Cylinder(Object):
|
||||
def __init__(self, _radius: float = 1.0, _height: float = 1.0) -> None:
|
||||
super().__init__()
|
||||
self.radius = _radius
|
||||
self.height = _height
|
||||
|
||||
def parse_args(self, args: list[str]):
|
||||
param = ArgParser.as_vec2(args)
|
||||
self.radius = param[0]
|
||||
self.height = param[1]
|
||||
|
||||
def sdf_block(self) -> str:
|
||||
return (
|
||||
f"sdCappedCylinder({self.transform.p_expr()}, {self.radius}, {self.height})"
|
||||
)
|
||||
|
||||
|
||||
@make_obj("torus")
|
||||
class Torus(Object):
|
||||
def __init__(self, _r1: float = 1.0, _r2: float = 0.4) -> None:
|
||||
super().__init__()
|
||||
self.r1 = _r1
|
||||
self.r2 = _r2
|
||||
|
||||
def parse_args(self, args: list[str]):
|
||||
param = ArgParser.as_vec2(args)
|
||||
self.r1 = param[0]
|
||||
self.r2 = param[1]
|
||||
|
||||
def sdf_block(self) -> str:
|
||||
return f"sdTorus({self.transform.p_expr()}, vec2({self.r1}, {self.r2}))"
|
||||
|
||||
|
||||
@make_obj("capsule", "pill")
|
||||
class Capsule(Object):
|
||||
def __init__(self, _h: float = 1.0, _r: float = 0.25) -> None:
|
||||
super().__init__()
|
||||
self._h = _h
|
||||
self._r = _r
|
||||
|
||||
def parse_args(self, args: list[str]):
|
||||
param = ArgParser.as_vec2(args)
|
||||
self._h = param[0]
|
||||
self._r = param[1]
|
||||
|
||||
def sdf_block(self) -> str:
|
||||
return f"sdVerticalCapsule({self.transform.p_expr()}, {self._h}, {self._r})"
|
||||
|
||||
|
||||
@make_obj("camera", "cam")
|
||||
class Camera(Object):
|
||||
def __init__(self, _focus: float = 1.0) -> None:
|
||||
super().__init__()
|
||||
self.focus = _focus
|
||||
self.transform.translate(5.0, 5.0, 5.0).lookat(0.0, 0.0, 0.0)
|
||||
|
||||
def parse_args(self, args: list[str]):
|
||||
self.focus = ArgParser.as_float(args)
|
||||
|
||||
@ -1,39 +1,37 @@
|
||||
from konabot.plugins.marchtoy.obj import Object
|
||||
import numpy as np
|
||||
from konabot.plugins.marchtoy.utilities import ArgParser
|
||||
|
||||
OPERATION_ENTRIES = {}
|
||||
|
||||
|
||||
def make_operation(name: str, aliases: list[str] = []):
|
||||
def make_operation(*name: str):
|
||||
def decorator(op):
|
||||
OPERATION_ENTRIES[name] = op
|
||||
for alias in aliases:
|
||||
# OPERATION_ENTRIES[name] = op
|
||||
for alias in [*name]:
|
||||
OPERATION_ENTRIES[alias] = op
|
||||
return op
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
@make_operation("pos", ["translate", "position", "p"])
|
||||
@make_operation("pos", "translate", "position", "p")
|
||||
def translate(obj: Object, args: list[str]):
|
||||
pos = ArgParser.as_vec3(args)
|
||||
obj.transform.translate(pos[0], pos[1], pos[2])
|
||||
|
||||
|
||||
@make_operation("rot", ["rotate", "r"])
|
||||
@make_operation("rot", "rotate", "r")
|
||||
def rotate(obj: Object, args: list[str]):
|
||||
pos = ArgParser.as_vec3(args)
|
||||
obj.transform.rotate(pos[0], pos[1], pos[2])
|
||||
|
||||
|
||||
@make_operation("lookat", ["look", "l"])
|
||||
@make_operation("lookat", "look", "l")
|
||||
def lookat(obj: Object, args: list[str]):
|
||||
pos = ArgParser.as_vec3(args)
|
||||
obj.transform.lookat(pos[0], pos[1], pos[2])
|
||||
|
||||
|
||||
@make_operation("color", ["col", "texture"])
|
||||
@make_operation("color", "col", "texture")
|
||||
def color(obj: Object, args: list[str]):
|
||||
try:
|
||||
if len(args) == 1:
|
||||
|
||||
99
konabot/plugins/marchtoy/shaders/frag.glsl
Normal file
99
konabot/plugins/marchtoy/shaders/frag.glsl
Normal file
@ -0,0 +1,99 @@
|
||||
#version 330
|
||||
// compatibility
|
||||
#define float4x4 mat4x4
|
||||
#define float4 vec4
|
||||
#define float3 vec3
|
||||
#define float2 vec2
|
||||
|
||||
const float EPS = 0.001;
|
||||
const int MAX_ITER = 128;
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
out vec4 fragColor;
|
||||
|
||||
struct sdQuery {
|
||||
float value;
|
||||
int obj_id;
|
||||
};
|
||||
|
||||
float sdCube(vec3 p, vec3 b) {
|
||||
p = abs(p) - b;
|
||||
return length(max(p, 0.0)) + min(max(p.x, max(p.y, p.z)), 0.0);
|
||||
}
|
||||
|
||||
float sdSphere(vec3 p, float r) {
|
||||
return length(p) - r;
|
||||
}
|
||||
|
||||
float sdCappedCylinder( vec3 p, float r, float h )
|
||||
{
|
||||
vec2 d = abs(vec2(length(p.xz),p.y)) - vec2(r,h);
|
||||
return min(max(d.x,d.y),0.0) + length(max(d,0.0));
|
||||
}
|
||||
|
||||
float sdVerticalCapsule( vec3 p, float h, float r )
|
||||
{
|
||||
p.y -= clamp( p.y, 0.0, h );
|
||||
return length( p ) - r;
|
||||
}
|
||||
float sdTorus( vec3 p, vec2 t )
|
||||
{
|
||||
vec2 q = vec2(length(p.xz)-t.x,p.y);
|
||||
return length(q)-t.y;
|
||||
}
|
||||
|
||||
sdQuery sd(vec3 p) {
|
||||
sdQuery qry;
|
||||
qry.value = 100000000.0;
|
||||
qry.obj_id = -1;
|
||||
<SDF_BLOCK>
|
||||
return qry;
|
||||
}
|
||||
|
||||
vec3 nrm(vec3 p) {
|
||||
vec2 d = vec2(EPS, 0.0);
|
||||
return normalize(vec3(
|
||||
sd(p + d.xyy).value - sd(p - d.xyy).value,
|
||||
sd(p + d.yxy).value - sd(p - d.yxy).value,
|
||||
sd(p + d.yyx).value - sd(p - d.yyx).value
|
||||
));
|
||||
}
|
||||
|
||||
vec4 materialColor(int obj_id) {
|
||||
<COLOR_BLOCK>
|
||||
return vec4(1.0);
|
||||
}
|
||||
|
||||
vec4 color(vec3 p, int obj_id) {
|
||||
vec3 normal = nrm(p);
|
||||
vec3 light_dir = normalize(vec3(0.5, 0.8, -0.6));
|
||||
float light = 0.2 + 0.8 * max(dot(normal, light_dir), 0.0);
|
||||
vec4 base = materialColor(obj_id);
|
||||
return vec4(base.rgb * light, base.a);
|
||||
}
|
||||
|
||||
vec4 march(vec3 p, vec3 r) {
|
||||
sdQuery qry;
|
||||
vec4 col = vec4(0.0);
|
||||
for(int i = 0; i < MAX_ITER; ++i) {
|
||||
qry = sd(p);
|
||||
if(qry.value < EPS){
|
||||
col = color(p, qry.obj_id);
|
||||
break;
|
||||
}
|
||||
p += qry.value * r;
|
||||
}
|
||||
return col;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = 2. * (gl_FragCoord.xy / u_resolution - .5) * vec2(u_resolution.x / u_resolution.y, 1.);
|
||||
vec3 c_p = vec3(<CAM_POS>);
|
||||
vec3 c_z = normalize(vec3(<CAM_DIR>));
|
||||
vec3 world_up = abs(c_z.y) > 0.999 ? vec3(0., 0., 1.) : vec3(0., 1., 0.);
|
||||
vec3 c_x = normalize(cross(c_z, world_up));
|
||||
vec3 c_y = normalize(cross(c_x, c_z));
|
||||
mat3 view = mat3(c_x, c_y, c_z);
|
||||
vec3 r = normalize(vec3(uv, <CAM_FOCUS>));
|
||||
fragColor = march(c_p, view * r);
|
||||
}
|
||||
@ -1,73 +0,0 @@
|
||||
uniform float2 u_resolution;
|
||||
|
||||
const float EPS = 0.001;
|
||||
const int MAX_ITER = 64;
|
||||
struct sdQuery {
|
||||
float value;
|
||||
int obj_id;
|
||||
};
|
||||
|
||||
float sdCube(float3 p, float3 b) {
|
||||
p = abs(p) - b;
|
||||
return length(max(p, 0.0)) + min(max(p.x, max(p.y, p.z)), 0.0);
|
||||
}
|
||||
|
||||
float sdSphere(float3 p, float r) {
|
||||
return length(p) - r;
|
||||
}
|
||||
|
||||
sdQuery sd(float3 p) {
|
||||
sdQuery qry;
|
||||
qry.value = 100000000.0;
|
||||
qry.obj_id = -1;
|
||||
<SDF_BLOCK>
|
||||
return qry;
|
||||
}
|
||||
|
||||
float3 nrm(float3 p) {
|
||||
float2 d = float2(EPS, 0.0);
|
||||
return normalize(float3(
|
||||
sd(p + d.xyy).value - sd(p - d.xyy).value,
|
||||
sd(p + d.yxy).value - sd(p - d.yxy).value,
|
||||
sd(p + d.yyx).value - sd(p - d.yyx).value
|
||||
));
|
||||
}
|
||||
|
||||
float4 materialColor(int obj_id) {
|
||||
<COLOR_BLOCK>
|
||||
return float4(1.0);
|
||||
}
|
||||
|
||||
float4 color(float3 p, int obj_id) {
|
||||
float3 normal = nrm(p);
|
||||
float3 light_dir = normalize(float3(0.5, 0.8, -0.6));
|
||||
float light = 0.2 + 0.8 * max(dot(normal, light_dir), 0.0);
|
||||
float4 base = materialColor(obj_id);
|
||||
return float4(base.rgb * light, base.a);
|
||||
}
|
||||
|
||||
float4 march(float3 p, float3 r) {
|
||||
sdQuery qry;
|
||||
float4 col = float4(0.0);
|
||||
for(int i = 0; i < MAX_ITER; ++i) {
|
||||
qry = sd(p);
|
||||
if(qry.value < EPS){
|
||||
col = color(p, qry.obj_id);
|
||||
break;
|
||||
}
|
||||
p += qry.value * r;
|
||||
}
|
||||
return col;
|
||||
}
|
||||
|
||||
half4 main(float2 fragCoord) {
|
||||
float2 uv = -2. * (fragCoord / u_resolution - .5) * float2(u_resolution.x / u_resolution.y, 1.);
|
||||
float3 c_p = float3(<CAM_POS>);
|
||||
float3 c_z = normalize(float3(<CAM_DIR>));
|
||||
float3 world_up = abs(c_z.y) > 0.999 ? float3(0., 0., 1.) : float3(0., 1., 0.);
|
||||
float3 c_x = normalize(cross(c_z, world_up));
|
||||
float3 c_y = normalize(cross(c_x, c_z));
|
||||
float3x3 view = float3x3(c_x, c_y, c_z);
|
||||
float3 r = normalize(float3(uv, <CAM_FOCUS>));
|
||||
return half4(march(c_p, view * r));
|
||||
}
|
||||
6
konabot/plugins/marchtoy/shaders/vert.glsl
Normal file
6
konabot/plugins/marchtoy/shaders/vert.glsl
Normal file
@ -0,0 +1,6 @@
|
||||
#version 330
|
||||
in vec2 in_position;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(in_position, 0.0, 1.0);
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
from konabot.plugins.marchtoy.command import Scene
|
||||
raise DeprecationWarning
|
||||
from command import Scene
|
||||
import skia
|
||||
import struct
|
||||
from PIL import Image
|
||||
@ -1,13 +1,54 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
COLORS = {
|
||||
"red": (1.0, 0.0, 0.0, 1.0),
|
||||
"green": (0.0, 1.0, 0.0, 1.0),
|
||||
"blue": (0.0, 0.0, 1.0, 1.0),
|
||||
"white": (1.0, 1.0, 1.0, 1.0),
|
||||
"black": (0.0, 0.0, 0.0, 1.0),
|
||||
"gray": (0.5, 0.5, 0.5, 1.0),
|
||||
"light_gray": (0.75, 0.75, 0.75, 1.0),
|
||||
"dark_gray": (0.25, 0.25, 0.25, 1.0),
|
||||
"dark_red": (0.5, 0.0, 0.0, 1.0),
|
||||
"crimson": (0.86, 0.08, 0.24, 1.0),
|
||||
"pink": (1.0, 0.75, 0.8, 1.0),
|
||||
"hot_pink": (1.0, 0.41, 0.71, 1.0),
|
||||
"orange_red": (1.0, 0.27, 0.0, 1.0),
|
||||
"orange": (1.0, 0.65, 0.0, 1.0),
|
||||
"gold": (1.0, 0.84, 0.0, 1.0),
|
||||
"yellow": (1.0, 1.0, 0.0, 1.0),
|
||||
"light_yellow": (1.0, 1.0, 0.88, 1.0),
|
||||
"khaki": (0.94, 0.90, 0.55, 1.0),
|
||||
"light_green": (0.56, 0.93, 0.56, 1.0),
|
||||
"lime": (0.0, 1.0, 0.0, 1.0),
|
||||
"forest_green": (0.13, 0.55, 0.13, 1.0),
|
||||
"dark_green": (0.0, 0.39, 0.0, 1.0),
|
||||
"olive": (0.5, 0.5, 0.0, 1.0),
|
||||
"teal": (0.0, 0.5, 0.5, 1.0),
|
||||
"light_blue": (0.68, 0.85, 0.9, 1.0),
|
||||
"sky_blue": (0.53, 0.81, 0.92, 1.0),
|
||||
"cyan": (0.0, 1.0, 1.0, 1.0),
|
||||
"navy": (0.0, 0.0, 0.5, 1.0),
|
||||
"royal_blue": (0.25, 0.41, 0.88, 1.0),
|
||||
"steel_blue": (0.27, 0.51, 0.71, 1.0),
|
||||
"purple": (0.5, 0.0, 0.5, 1.0),
|
||||
"magenta": (1.0, 0.0, 1.0, 1.0),
|
||||
"violet": (0.93, 0.51, 0.93, 1.0),
|
||||
"lavender": (0.90, 0.90, 0.98, 1.0),
|
||||
"indigo": (0.29, 0.0, 0.51, 1.0),
|
||||
"brown": (0.65, 0.16, 0.16, 1.0),
|
||||
"saddle_brown": (0.55, 0.27, 0.07, 1.0),
|
||||
"chocolate": (0.82, 0.41, 0.12, 1.0),
|
||||
"tan": (0.82, 0.71, 0.55, 1.0),
|
||||
"beige": (0.96, 0.96, 0.86, 1.0),
|
||||
"coral": (1.0, 0.5, 0.31, 1.0),
|
||||
"salmon": (0.98, 0.5, 0.45, 1.0),
|
||||
"turquoise": (0.25, 0.88, 0.82, 1.0),
|
||||
"aqua": (0.0, 1.0, 1.0, 1.0),
|
||||
"plum": (0.87, 0.63, 0.87, 1.0),
|
||||
"wheat": (0.96, 0.87, 0.70, 1.0),
|
||||
}
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Texture:
|
||||
color: tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0)
|
||||
|
||||
@ -1,17 +1,26 @@
|
||||
import numpy as np
|
||||
from konabot.plugins.marchtoy.texture import COLORS
|
||||
|
||||
|
||||
class SkslFormatter:
|
||||
class Formatter:
|
||||
@staticmethod
|
||||
def mat4(m: np.ndarray) -> str:
|
||||
def float4(m: np.ndarray) -> str:
|
||||
if m.shape != (4, 4):
|
||||
m = np.identity(4)
|
||||
v_0 = ", ".join([str(x) for x in m[0]])
|
||||
v_1 = ", ".join([str(x) for x in m[1]])
|
||||
v_2 = ", ".join([str(x) for x in m[2]])
|
||||
v_3 = ", ".join([str(x) for x in m[3]])
|
||||
v_0 = ", ".join([str(x) for x in m[:, 0]])
|
||||
v_1 = ", ".join([str(x) for x in m[:, 1]])
|
||||
v_2 = ", ".join([str(x) for x in m[:, 2]])
|
||||
v_3 = ", ".join([str(x) for x in m[:, 3]])
|
||||
return f"float4x4(float4({v_0}), float4({v_1}), float4({v_2}), float4({v_3}))"
|
||||
|
||||
@staticmethod
|
||||
def vec4(m: np.ndarray) -> str:
|
||||
if m.shape != (4, 4):
|
||||
m = np.identity(4)
|
||||
v_0 = ", ".join([str(x) for x in m[:, 0]])
|
||||
v_1 = ", ".join([str(x) for x in m[:, 1]])
|
||||
v_2 = ", ".join([str(x) for x in m[:, 2]])
|
||||
v_3 = ", ".join([str(x) for x in m[:, 3]])
|
||||
return f"mat4(vec4({v_0}), vec4({v_1}), vec4({v_2}), vec4({v_3}))"
|
||||
|
||||
"""
|
||||
TODO: 除零出现 nan 情况的单独处理
|
||||
@ -27,6 +36,22 @@ class ArgParser:
|
||||
raise Exception(f"cannot parse {args}")
|
||||
return default
|
||||
|
||||
@staticmethod
|
||||
def as_vec2(
|
||||
args: list[str], default: np.ndarray = np.array((0.0, 0.0))
|
||||
) -> np.ndarray:
|
||||
try:
|
||||
if len(args) == 1:
|
||||
x = float(args[0])
|
||||
return np.array((x, x))
|
||||
elif len(args) == 2:
|
||||
x = float(args[0])
|
||||
y = float(args[1])
|
||||
return np.array((x, y))
|
||||
except:
|
||||
raise Exception(f"cannot parse {args}")
|
||||
return default
|
||||
|
||||
@staticmethod
|
||||
def as_vec3(
|
||||
args: list[str], default: np.ndarray = np.array((0.0, 0.0, 0.0))
|
||||
|
||||
151
poetry.lock
generated
151
poetry.lock
generated
@ -1709,6 +1709,85 @@ type = "legacy"
|
||||
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
reference = "mirrors"
|
||||
|
||||
[[package]]
|
||||
name = "glcontext"
|
||||
version = "3.0.0"
|
||||
description = "Portable Headless OpenGL Context"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "glcontext-3.0.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b154c25a57e16dbb073478d0cbe2c0090649d135c4c9f87e753b6181b97ec848"},
|
||||
{file = "glcontext-3.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fa5a14778d13ecf4a0dd60a7825427bf6ac0383eacb3b8b1a9c23e4976aa0c8c"},
|
||||
{file = "glcontext-3.0.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7c229290a3a33004a59799b94a50bc5e6f8addd1b5bc5039ef9e78f86d888b31"},
|
||||
{file = "glcontext-3.0.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1445a03d8795113034e1f9ffa662f795df65ae69ee21b26ed3b1d66100ba3f8c"},
|
||||
{file = "glcontext-3.0.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:09247011c09c37b8d30eca9aa24659288de2febaeaa6a817b33b1498b5ef164c"},
|
||||
{file = "glcontext-3.0.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:c8c1223f1cbcfc0b88428e1717baca829ee863ed5d88e9b5574c7ed6598249cd"},
|
||||
{file = "glcontext-3.0.0-cp310-cp310-win32.whl", hash = "sha256:c13dedb3636328b133c4d53c047ce69040ae784095e8f239432ad74d6f921712"},
|
||||
{file = "glcontext-3.0.0-cp310-cp310-win_amd64.whl", hash = "sha256:4817f4cd52c7fe5410c92ca12b6712435548918719373882ade76f8f75d80abd"},
|
||||
{file = "glcontext-3.0.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3a9e56fa3597cc709cfd0fdf2ae682cda36510a13faac2b3142f401e823b64f4"},
|
||||
{file = "glcontext-3.0.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a0484308af75e04b0e56066dc2324a8fb9f1443b76ddb98833439982322b2a39"},
|
||||
{file = "glcontext-3.0.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:983231394396aa2a1e2b96df49404cc8f8aa729d462ed40e605a74b079c46342"},
|
||||
{file = "glcontext-3.0.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7fa413f4420abff2bbb5aa5770a3e1deffcdc13e0ef2f459b145fa79c36909e7"},
|
||||
{file = "glcontext-3.0.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:7d0ac35ac07fc91eccea093beb9d1c1a4eae250bc33836047deff01a3b5f4757"},
|
||||
{file = "glcontext-3.0.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:7145d17a70adc5784ca59ebbe19a56435ba21816070b8b433f43aa2dfb8be71a"},
|
||||
{file = "glcontext-3.0.0-cp311-cp311-win32.whl", hash = "sha256:b31808ca2517fedcac8ca5b296ff46c8af012911eaa2080889a1f244d329ef9a"},
|
||||
{file = "glcontext-3.0.0-cp311-cp311-win_amd64.whl", hash = "sha256:ef4b4ec35e2b720f4cd250bb92cf6417add445490bf780345596da5a796a0e6f"},
|
||||
{file = "glcontext-3.0.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:848f870a2bc72a29de7ab6756b9e8f2e6ce052e17873ebc6b3f25129b6e0d58a"},
|
||||
{file = "glcontext-3.0.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4b3b12a66f57379566dd4d36899ac265abdbe040f3fc3293f50cd6678a1dcc9b"},
|
||||
{file = "glcontext-3.0.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:449eaefd89c0519900715b8363ead59ac4aa32457722ca521ce01297441edb34"},
|
||||
{file = "glcontext-3.0.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:04921720740438ceea8fb8a38b5665963520c7c8f27bef03df8aeb3ea3cfbfb6"},
|
||||
{file = "glcontext-3.0.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:25538bdb106f673638d70e8a16a0c037a92a24c4cf40a05f0d3fa14b483d6194"},
|
||||
{file = "glcontext-3.0.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:d11f7701b900a5a34c994e1d91c547be1cc469b73f881471460fd905f69f9e4c"},
|
||||
{file = "glcontext-3.0.0-cp312-cp312-win32.whl", hash = "sha256:5d2b567eaf34adb016aadce81fd2f1d4c8e4a39e3d6f2a395ce528e2a350dd3f"},
|
||||
{file = "glcontext-3.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:e80bb37ba727bd20c192f2754aea40c437a7665005c1001c10752f91913964e9"},
|
||||
{file = "glcontext-3.0.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:5bd37089570d3cdb01c6c0b315c49ce8a4dcdab2c431f5ba9f37a8b633cebfdf"},
|
||||
{file = "glcontext-3.0.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:857fd83e60f15580afd369dfb651a10d84a70ec35995622d253551bfb3ff9477"},
|
||||
{file = "glcontext-3.0.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:93fda9b378ce6d91f366e83e71ebdafdd167280a9834d1d6341ce6457c4e42ed"},
|
||||
{file = "glcontext-3.0.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:89ad50d34aa62f03f6aaf6ae39fc27afd1b0eaefb0281aac51f686dc5672d473"},
|
||||
{file = "glcontext-3.0.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:2634d5e9647a6d7b0c5a5c0c57e91ac98aa79759bffb42459af4374b049fab01"},
|
||||
{file = "glcontext-3.0.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:0140c5df37cb48271527355062d35589dc3e1e7e73b51adf9962ed5048115f69"},
|
||||
{file = "glcontext-3.0.0-cp313-cp313-win32.whl", hash = "sha256:6678e0552b516fa8fe62f500ef2b953bec991e82a003be2a9840d16556d03d2e"},
|
||||
{file = "glcontext-3.0.0-cp313-cp313-win_amd64.whl", hash = "sha256:18aa4b1df50e8c8ea39bd0f775f39bcc987521f92c4ed019ec7d70078471354d"},
|
||||
{file = "glcontext-3.0.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:17a1339db9c1df55eb0b7341dd3da1e45c9992d59aa3a72afefd5bd43d588c92"},
|
||||
{file = "glcontext-3.0.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:9ca980d9ac22045ef2489cac8cf3800748b1baa716f74a53705003405664950c"},
|
||||
{file = "glcontext-3.0.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b5a7fb8ab69fc4f076282622e94284ea4cbf7022a1f6ed50938d076b982f653e"},
|
||||
{file = "glcontext-3.0.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5825e1df53bdf941c3a5ea5ff6d1869491dfeb9f2c30d97f45bbbcb12d91dc1f"},
|
||||
{file = "glcontext-3.0.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:f3be86fa6587eca16f3fe2b46ee72e2a188fdccedafff0de7515b1d5e72f265e"},
|
||||
{file = "glcontext-3.0.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:b4a06207c487f0aa79e49bf1c19d0f2633ff1e1889704196993d24b342763344"},
|
||||
{file = "glcontext-3.0.0-cp38-cp38-win32.whl", hash = "sha256:3eb55b653fc00a4ec415acacbbf1e8f03ee10b5a685f63fce43ad75b4cef5d4e"},
|
||||
{file = "glcontext-3.0.0-cp38-cp38-win_amd64.whl", hash = "sha256:7e51f04bb3a3a12147106036676a237c5405297a95b8209f7686d624f013bc17"},
|
||||
{file = "glcontext-3.0.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7043f59d126feb26896a6419ebfeecc78c07ffefced2a2f59104dd7a2f71ebb5"},
|
||||
{file = "glcontext-3.0.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4a2972f92da9a6fb06860e117de05f5b8adc2e2d827bbc0ccc7acbe7325acd1e"},
|
||||
{file = "glcontext-3.0.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fb2eb1c455d589005567b36642db8059b31bb1752f0525c6dbe70ceeeb0131d5"},
|
||||
{file = "glcontext-3.0.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cdd81e8b580e43c1fe1c48c0fc3909e6c1f37ee4cfd8c990c03b2df3b463bd37"},
|
||||
{file = "glcontext-3.0.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:64eb425f0f0c54c60527e1b112465d4d69b010af42a3b0e69f22317fffd8faea"},
|
||||
{file = "glcontext-3.0.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:def2b9956fbd3da94b4cadeb85d947a6321582ddfea2e58c4134178bfabce0f8"},
|
||||
{file = "glcontext-3.0.0-cp39-cp39-win32.whl", hash = "sha256:cfdc763adffcd20509b9e6ac964a9abf7b2a898bb32d7bd4efce9db8af2caaf5"},
|
||||
{file = "glcontext-3.0.0-cp39-cp39-win_amd64.whl", hash = "sha256:12c2abef8efabb8ab7e35d16785968de888ae7349d1b83c765080f35fcd3c6e5"},
|
||||
{file = "glcontext-3.0.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:f4e285e5d40e7a9bafeb0651c3d8f1a7c822525dec7091e97109ba87a70dbd1e"},
|
||||
{file = "glcontext-3.0.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:96d1bbe62c5bc5315ca2f84a2abae6fa7b7d645dd368415a0cd1ee5ba6f3f8f7"},
|
||||
{file = "glcontext-3.0.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3a190b1cdb39110c7b56c33857dbff493a364633bfd0ff402a1ce205956c94ca"},
|
||||
{file = "glcontext-3.0.0-pp310-pypy310_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d467cce2dac8c3928847e90310eb6bdfdfa69f8df39b76a74734046faa15e688"},
|
||||
{file = "glcontext-3.0.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:2b0c5240125d75498a8f14596484233e4effe98a6a035f566872dd2fdf472ceb"},
|
||||
{file = "glcontext-3.0.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:d89a6bcf0129f27594c07eb9aafc33389e9dd66f344fe1e255fe297bbc123317"},
|
||||
{file = "glcontext-3.0.0-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:d9b0bd64b01be0ecad521ca4869153893ed10f8c9043dcd8d1a81c8f686008c9"},
|
||||
{file = "glcontext-3.0.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1ba5af7ca9309bb42b89cf25f576cc28ae36671be01ecdfce264308a007880ac"},
|
||||
{file = "glcontext-3.0.0-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cbb413b6bf3b2ded2e5bf4235b75eb9ac9d36361af38393c53c689dfcc096eba"},
|
||||
{file = "glcontext-3.0.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:dfea7fc7b22afce49027d8470a84f9c7c6f06a09b43f6606030b53b3240df0d1"},
|
||||
{file = "glcontext-3.0.0-pp39-pypy39_pp73-macosx_10_15_x86_64.whl", hash = "sha256:cf5af894228b4357b088a6e26761438d799c2af907e33f17935072fe46903c2d"},
|
||||
{file = "glcontext-3.0.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:1712d7a7216b687b181291098e5117e5fae1f1df466583b4290dc2e80d9a72c8"},
|
||||
{file = "glcontext-3.0.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07980350ba2aac9f793185f90c4f561ae1aa03cc11b58cce4b51e20a70e8c6e3"},
|
||||
{file = "glcontext-3.0.0-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed5135fdb0da5e0decea1cb26ca10a279188aa0bc4462f1c77e214d6f956a710"},
|
||||
{file = "glcontext-3.0.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:c3648e13478d77128a74dd25baa98faf9ddb9cbcba5af39775ef3a496f71fd10"},
|
||||
{file = "glcontext-3.0.0.tar.gz", hash = "sha256:57168edcd38df2fc0d70c318edf6f7e59091fba1cd3dadb289d0aa50449211ef"},
|
||||
]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
reference = "mirrors"
|
||||
|
||||
[[package]]
|
||||
name = "greenlet"
|
||||
version = "3.4.0"
|
||||
@ -2534,6 +2613,76 @@ type = "legacy"
|
||||
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
reference = "mirrors"
|
||||
|
||||
[[package]]
|
||||
name = "moderngl"
|
||||
version = "5.12.0"
|
||||
description = "ModernGL: High performance rendering for Python 3"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "moderngl-5.12.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:105cdee2ee29a7e6ebbc76cf178941503656a185c6945933bc7ef395ba8e65a7"},
|
||||
{file = "moderngl-5.12.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:18deb8bebd0a4277d92c76dbedf8e4b4b68bf0a8a878404c6b26aed750890d3b"},
|
||||
{file = "moderngl-5.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f0c4f7c42425177168938386a4fabd734ca3bbb5de2d1fd1176cfa6f980fc13"},
|
||||
{file = "moderngl-5.12.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:878cdf593204d85c020305f21d306f979353a67c932b9df58ea936f6e5ad13e7"},
|
||||
{file = "moderngl-5.12.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:00d94f9cb485d87c85088edad624201e152d8ac401793a024b16cd9e2bc4dbf6"},
|
||||
{file = "moderngl-5.12.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:edd91057b8d76beebac0d7b0c741466ee8f37eaf3c07856785c2872afe0b35ac"},
|
||||
{file = "moderngl-5.12.0-cp310-cp310-win32.whl", hash = "sha256:3d066eae2eb44e81bd7addf565adebc041bdee119e7ac6e4f95831d6f327a938"},
|
||||
{file = "moderngl-5.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:76d966194d51852f48c42a6e786a4520f1e1be5f93e2626423d673663422d559"},
|
||||
{file = "moderngl-5.12.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:28cdba5dcf2d03c89bb25dc3b2f5770ac4104470ed5bbe680a15494fa52a537d"},
|
||||
{file = "moderngl-5.12.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:dad93893e3fcb2410bfd31e854f20e1370b4fbafa07a737f1046f5fbd29ba0f4"},
|
||||
{file = "moderngl-5.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7fc0f8788bc84433d2124e9a4893adbe40f93c7d213abb8ad7b909540cb0161f"},
|
||||
{file = "moderngl-5.12.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6efd3fe0d2c9652af21e2c1f5a936a2b971abac5bdd777da7182a54962466cab"},
|
||||
{file = "moderngl-5.12.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:6f3bd2d534fc081cde30545b84ebca63aef847ba8bd533217b9a37f565614ade"},
|
||||
{file = "moderngl-5.12.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:eaa3de9446c6febec4d5f888e6f1a4e9398bc5a5ea70b1570ea447213641d4a6"},
|
||||
{file = "moderngl-5.12.0-cp311-cp311-win32.whl", hash = "sha256:9fdb76f1fd890db67727c8cdee4db2ee6319068c7ce92be0308366f8745e28ab"},
|
||||
{file = "moderngl-5.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:0c210e8d52a60025f6586ca015c39feb1e57e6dc792c3ff44800f6493a541b1a"},
|
||||
{file = "moderngl-5.12.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:2750547707c1ec3790dfbeb9c90fb808672ff13f61cac392c706ba09fda10db0"},
|
||||
{file = "moderngl-5.12.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c5c2a5fe06c7021183d9274df798f25516409c8d55898c324dae8a0b2de10144"},
|
||||
{file = "moderngl-5.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b6c4972f3ddd10a3de6c30311da2c25bc493d023796e16c5d4e0f8bd6d5770be"},
|
||||
{file = "moderngl-5.12.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a4d497ec6a3f6afa9ebd0be816d9bfe2fe20fec2105acfb88d956619c3ed8eb4"},
|
||||
{file = "moderngl-5.12.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:2f3d240e9bc5d83257378bae59f8f35638b89d22bb003cf674b88fd7932161ce"},
|
||||
{file = "moderngl-5.12.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:6fa667d560d842e778e2a5968305fb78f9781616a11b1b93acd2562f97262ccf"},
|
||||
{file = "moderngl-5.12.0-cp312-cp312-win32.whl", hash = "sha256:0a02fddd54dccee1ca6060bfed75a2e6a17dd3ee06920fac418506d8a8233849"},
|
||||
{file = "moderngl-5.12.0-cp312-cp312-win_amd64.whl", hash = "sha256:8698a59ad03539a2982125b7998efc1c107ba31d5d03437b6fcd72cb2c226922"},
|
||||
{file = "moderngl-5.12.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f6efb432f5164f871471d1da36e3a4be9dc3efd7a1e48d0ac6b751e556af5d02"},
|
||||
{file = "moderngl-5.12.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:9b09d8d15b2eaab41c8646a664429ec86af225fa25096758497cd212489d2e1e"},
|
||||
{file = "moderngl-5.12.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:071042dd4846e58cbe204cf49341b62cd209fdcb6d48018feb5a61c66707fcb2"},
|
||||
{file = "moderngl-5.12.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:91db8302ac7f5d7a82a967388677e1378ff078f1e16d05da37ce77f4633b93b1"},
|
||||
{file = "moderngl-5.12.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:51971d65ec96a212a814350c8b324ae0754353e1b61826d1a06aa2d060df170e"},
|
||||
{file = "moderngl-5.12.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:d56827360c19e831e986243b5daaf6a51006f1ec0d5372084ad446308763d19f"},
|
||||
{file = "moderngl-5.12.0-cp313-cp313-win32.whl", hash = "sha256:caa432c12b138a6c9571719075c4d103bdc2504cd31aeda38a00ad10fcf268cb"},
|
||||
{file = "moderngl-5.12.0-cp313-cp313-win_amd64.whl", hash = "sha256:e34d1cd38f7998258f76a08bb5e87f351ec653b7ea1928b2711f8719c10cefd1"},
|
||||
{file = "moderngl-5.12.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b0712fcce0ebbee962f5e93628118aedcb568d56b5c59f2e9aac43ea57190219"},
|
||||
{file = "moderngl-5.12.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:861aae4a38da0f5d82dc2d5ece0f0a6d799809c362343cd1a447ab840a68370f"},
|
||||
{file = "moderngl-5.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:726a025ab9822c295369a9ddb1bfaf4930f9645b7a958b74dfcd6a969d7052cf"},
|
||||
{file = "moderngl-5.12.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:29a181bae8bde003016fee671b93c2faa3e1460033033e2a832ec9187aa73efb"},
|
||||
{file = "moderngl-5.12.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:8b35c17d5497f19c524068f9337cbe5e0e0e5662150b12fa95618665130bbf16"},
|
||||
{file = "moderngl-5.12.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:74e5b7df5614f3291d197139a888c967aa29c348e13ebd28ce2a55bf03baed3d"},
|
||||
{file = "moderngl-5.12.0-cp38-cp38-win32.whl", hash = "sha256:8dc1bacc24840e5bc562e79be65dc506d6c5a7d40ecac01a062f86d013c890af"},
|
||||
{file = "moderngl-5.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:cbd822cf3707fe955cfd940ec68b900519e2c43a5ef8085de5b0c983b4142c8b"},
|
||||
{file = "moderngl-5.12.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:49a6e27abafacef104c7ca336f6790f91c69617a1d752ead4a017b706d632b55"},
|
||||
{file = "moderngl-5.12.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7146c6fec3b2d7e8d11fa2504046b186d396520c0c2f7ef3aed40d8456dbebfc"},
|
||||
{file = "moderngl-5.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:28b9eb3574ffc6e303173ca0a419b63d8b12cd67f924289c02d127c4d17cdca5"},
|
||||
{file = "moderngl-5.12.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6948237626f9f0d9f931faa3b123d53613d5723679bc70b8db2590924795203f"},
|
||||
{file = "moderngl-5.12.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:3c6b4342b7508d75744f1091868cf184cae0be85d37be858fba32eb20d799695"},
|
||||
{file = "moderngl-5.12.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:13fec30855d346c4e69eff437e56f2bdd9953d22e80b7c5a319bccac7024e463"},
|
||||
{file = "moderngl-5.12.0-cp39-cp39-win32.whl", hash = "sha256:878f249505785cde8cc39d6016e62e74b46acbf3bb6d5a86341c86a7da7e7531"},
|
||||
{file = "moderngl-5.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:e801cd0d35b4e3e99fc6a6f15eb193ce907bfa78127afa5825f1fad24c700c0e"},
|
||||
{file = "moderngl-5.12.0.tar.gz", hash = "sha256:52936a98ccb2f2e1d6e3cb18528b2919f6831e7e3f924e788b5873badce5129b"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
glcontext = ">=3.0.0"
|
||||
|
||||
[package.extras]
|
||||
headless = ["glcontext (>=3.0.0)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
reference = "mirrors"
|
||||
|
||||
[[package]]
|
||||
name = "msgpack"
|
||||
version = "1.1.2"
|
||||
@ -5376,4 +5525,4 @@ reference = "mirrors"
|
||||
[metadata]
|
||||
lock-version = "2.1"
|
||||
python-versions = ">=3.12,<4.0"
|
||||
content-hash = "cb843d7ddb9458a0c0fd43f254b0362a05c0a017cf1df1d855d34caa98f4d10b"
|
||||
content-hash = "ce664db91fb8047d071f8d47890cd053412a961e594db41953345e87bc34c64a"
|
||||
|
||||
@ -39,6 +39,7 @@ dependencies = [
|
||||
"aiosignal (>=1.4.0,<2.0.0)",
|
||||
"pytest-mock (>=3.15.1,<4.0.0)",
|
||||
"skia-python (>=144.0.post2,<145.0)",
|
||||
"moderngl (>=5.12.0,<6.0.0)",
|
||||
]
|
||||
|
||||
[tool.poetry]
|
||||
|
||||
17
tests/test_marchtoy_transform.py
Normal file
17
tests/test_marchtoy_transform.py
Normal file
@ -0,0 +1,17 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PLUGIN_DIR = Path(__file__).resolve().parents[1] / "konabot" / "plugins" / "marchtoy"
|
||||
if str(PLUGIN_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(PLUGIN_DIR))
|
||||
|
||||
from obj import Transform
|
||||
|
||||
|
||||
def test_translate_expression_puts_offset_in_matrix_column():
|
||||
transform = Transform().translate(1.0, 2.0, 3.0)
|
||||
|
||||
expr = transform.p_expr()
|
||||
|
||||
assert "float4(-1.0, -2.0, -3.0, 1.0)" in expr
|
||||
Reference in New Issue
Block a user