Bound C++ line function to python... idk why I forgot to do this.
This commit is contained in:
parent
29e3ba208e
commit
bbb1b3dfa9
@ -29,6 +29,7 @@ class ThreeD(Scene):
|
|||||||
self.points = []
|
self.points = []
|
||||||
|
|
||||||
self.gradient = [4, 8, 6, 15, 18, 19, 26, 25, 24, 23, 16, 23, 22, 7, 5]
|
self.gradient = [4, 8, 6, 15, 18, 19, 26, 25, 24, 23, 16, 23, 22, 7, 5]
|
||||||
|
self.gradient = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.t += 0.00002
|
self.t += 0.00002
|
||||||
@ -122,8 +123,13 @@ class ThreeD(Scene):
|
|||||||
screen_x1, screen_y1 = self.project_point(x1, y1, z1, focal_length, screen_width, screen_height, angle_x, angle_y, angle_z, translate_x, translate_y, translate_z)
|
screen_x1, screen_y1 = self.project_point(x1, y1, z1, focal_length, screen_width, screen_height, angle_x, angle_y, angle_z, translate_x, translate_y, translate_z)
|
||||||
screen_x2, screen_y2 = self.project_point(x2, y2, z2, focal_length, screen_width, screen_height, angle_x, angle_y, angle_z, translate_x, translate_y, translate_z)
|
screen_x2, screen_y2 = self.project_point(x2, y2, z2, focal_length, screen_width, screen_height, angle_x, angle_y, angle_z, translate_x, translate_y, translate_z)
|
||||||
|
|
||||||
|
screen_x12, screen_y12 = self.project_point(x1 + 5, y1, z1, focal_length, screen_width, screen_height, angle_x, angle_y, angle_z, translate_x, translate_y, translate_z)
|
||||||
|
screen_x22, screen_y22 = self.project_point(x2 + 5, y2, z2, focal_length, screen_width, screen_height, angle_x, angle_y, angle_z, translate_x, translate_y, translate_z)
|
||||||
|
|
||||||
# Use the renderer to draw the line on the screen
|
# Use the renderer to draw the line on the screen
|
||||||
draw_line(int(screen_x1) / 4, int(screen_y1) / 4, int(screen_x2) / 4, int(screen_y2) / 4, color)
|
|
||||||
|
line(screen_x1 / 4, screen_y1 / 4, screen_x2 / 4, screen_y2 / 4, color)
|
||||||
|
|
||||||
|
|
||||||
def render_scene(self, focal_length, screen_width, screen_height, angle_x, angle_y, angle_z, translate_x, translate_y, translate_z):
|
def render_scene(self, focal_length, screen_width, screen_height, angle_x, angle_y, angle_z, translate_x, translate_y, translate_z):
|
||||||
"""Renders the 3D lines in the scene with perspective projection and Z-sorting."""
|
"""Renders the 3D lines in the scene with perspective projection and Z-sorting."""
|
||||||
|
|||||||
@ -245,6 +245,16 @@ void Graphics::bindMethods(pkpy::VM *vm) {
|
|||||||
return vm->None;
|
return vm->None;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
vm->bind(vm->builtins, "line(x1: int, y1: int, x2: int, y2: int, color: int)", [this](pkpy::VM* vm, pkpy::ArgsView args){
|
||||||
|
float x1 = pkpy::py_cast<float>(vm, args[0]);
|
||||||
|
float y1 = pkpy::py_cast<float>(vm, args[1]);
|
||||||
|
float x2 = pkpy::py_cast<float>(vm, args[2]);
|
||||||
|
float y2 = pkpy::py_cast<float>(vm, args[3]);
|
||||||
|
float paletteIndex = pkpy::py_cast<float>(vm, args[4]);
|
||||||
|
this->Line(x1, y1, x2, y2, paletteIndex);
|
||||||
|
return vm->None;
|
||||||
|
});
|
||||||
|
|
||||||
vm->bind(vm->builtins, "text(t: string, x: int, y: int, color: int)", [this](pkpy::VM* vm, pkpy::ArgsView args){
|
vm->bind(vm->builtins, "text(t: string, x: int, y: int, color: int)", [this](pkpy::VM* vm, pkpy::ArgsView args){
|
||||||
pkpy::PyObject* func_str = vm->builtins->attr("str");
|
pkpy::PyObject* func_str = vm->builtins->attr("str");
|
||||||
pkpy::PyObject* result = vm->call(func_str, args[0]);
|
pkpy::PyObject* result = vm->call(func_str, args[0]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user