graphics: support shear operation on transformation matrices
This commit is contained in:
parent
f9ef88ffc0
commit
d7c64d7e56
@ -133,6 +133,7 @@ extern void gfx_matrix_identity(gfx_matrix_t);
|
||||
extern void gfx_matrix_scale(gfx_matrix_t, double x, double y);
|
||||
extern void gfx_matrix_translate(gfx_matrix_t, double x, double y);
|
||||
extern void gfx_matrix_rotate(gfx_matrix_t, double rotation);
|
||||
extern void gfx_matrix_shear(gfx_matrix_t matrix, double x, double y);
|
||||
extern void gfx_apply_matrix(double x, double y, gfx_matrix_t matrix, double *out_x, double *out_y);
|
||||
|
||||
|
||||
|
@ -896,6 +896,13 @@ void gfx_matrix_scale(gfx_matrix_t matrix, double x, double y) {
|
||||
});
|
||||
}
|
||||
|
||||
void gfx_matrix_shear(gfx_matrix_t matrix, double x, double y) {
|
||||
multiply_matrix(matrix, (gfx_matrix_t){
|
||||
{1.0, x, 0.0},
|
||||
{y, 1.0, 0.0},
|
||||
});
|
||||
}
|
||||
|
||||
void gfx_matrix_rotate(gfx_matrix_t matrix, double r) {
|
||||
multiply_matrix(matrix, (gfx_matrix_t){
|
||||
{ cos(r), -sin(r), 0.0},
|
||||
|
@ -903,6 +903,13 @@ KRK_Method(TransformMatrix,rotate) {
|
||||
return NONE_VAL();
|
||||
}
|
||||
|
||||
KRK_Method(TransformMatrix,shear) {
|
||||
double x, y;
|
||||
if (!krk_parseArgs(".dd", (const char*[]){"x","y"}, &x, &y)) return NONE_VAL();
|
||||
gfx_matrix_shear(self->matrix,x,y);
|
||||
return NONE_VAL();
|
||||
}
|
||||
|
||||
KRK_Method(TransformMatrix,apply) {
|
||||
double x, y;
|
||||
if (!krk_parseArgs(".dd", (const char*[]){"x","y"}, &x, &y)) return NONE_VAL();
|
||||
@ -2113,6 +2120,7 @@ KrkValue krk_module_onload__yutani2(void) {
|
||||
BIND_METHOD(TransformMatrix,scale);
|
||||
BIND_METHOD(TransformMatrix,translate);
|
||||
BIND_METHOD(TransformMatrix,rotate);
|
||||
BIND_METHOD(TransformMatrix,shear);
|
||||
BIND_METHOD(TransformMatrix,apply);
|
||||
krk_finalizeClass(TransformMatrix);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user