static void gezira_snowflake_render (gezira_snowflake_t *flake) { nile_Process_t *pipeline, *gate_, *COI; Matrix_t M = Matrix (); if (gezira_snowflake_offscreen (flake)) return; M = Matrix_translate (M, WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2); M = Matrix_scale (M, zoom, zoom); M = Matrix_translate (M, -WINDOW_WIDTH / 2, -WINDOW_HEIGHT / 2); M = Matrix_translate (M, flake->x, flake->y); M = Matrix_rotate (M, flake->angle); M = Matrix_scale (M, flake->scale, flake->scale); COI = gezira_CompositeUniformColorOverImage_ARGB32 (init, FLAKE_ALPHA, FLAKE_RED, FLAKE_GREEN, FLAKE_BLUE, window.pixels, window.width, window.height, window.width); gate_ = nile_Identity (init, 8); nile_Process_gate (COI, gate_); pipeline = nile_Process_pipe ( gezira_TransformBeziers (init, M.a, M.b, M.c, M.d, M.e, M.f), gezira_ClipBeziers (init, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT), gezira_Rasterize (init), gate, COI, NILE_NULL); nile_Process_feed (pipeline, snowflake_path, snowflake_path_n); gate = gate_; }
// Matrix operand to add a 3D scale to the Module. void Module_scale(Module *md, double sx, double sy, double sz) { Matrix m; Element *e; Matrix_identity(&m); Matrix_scale(&m, sx, sy, sz); e = Element_init(ObjMatrix, &m); Module_insert(md, e); }
static void testScale() { Matrix matrix; matrix = Matrix_scaled(Matrix_identity(), 2.0f, -1.0f, 0.5f); assertMatrixApproximate(matrix, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, EPSILON); matrix = Matrix_scaled(Matrix_init(0.0f, 0.0f, -1.0f, 1.0f, 2.0f, 0.0f, 0.0f, 2.0f, 0.0f, 1.5f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 1.0f), 3.0f, 1.5f, -0.5f); assertMatrixApproximate(matrix, 0.0f, 0.0f, 0.5f, 1.0f, 6.0f, 0.0f, 0.0f, 2.0f, 0.0f, 2.25f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 1.0f, EPSILON); matrix = Matrix_identity(); Matrix_scale(&matrix, 2.0f, -1.0f, 0.5f); assertMatrixApproximate(matrix, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, EPSILON); matrix = Matrix_init(0.0f, 0.0f, -1.0f, 1.0f, 2.0f, 0.0f, 0.0f, 2.0f, 0.0f, 1.5f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 1.0f); Matrix_scale(&matrix, 3.0f, 1.5f, -0.5f); assertMatrixApproximate(matrix, 0.0f, 0.0f, 0.5f, 1.0f, 6.0f, 0.0f, 0.0f, 2.0f, 0.0f, 2.25f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 1.0f, EPSILON); }
static void gezira_snowflake_render (gezira_snowflake_t *flake, gezira_Window_t *window, nile_Process_t *init) { nile_Process_t *pipeline; Matrix_t M = Matrix (); if (gezira_snowflake_offscreen (flake)) return; M = Matrix_translate (M, WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2); M = Matrix_scale (M, zoom, zoom); M = Matrix_translate (M, -WINDOW_WIDTH / 2, -WINDOW_HEIGHT / 2); M = Matrix_translate (M, flake->x, flake->y); M = Matrix_rotate (M, flake->angle); M = Matrix_scale (M, flake->scale, flake->scale); pipeline = nile_Process_pipe ( gezira_TransformBeziers (init, M.a, M.b, M.c, M.d, M.e, M.f), gezira_ClipBeziers (init, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT), gezira_Rasterize (init), gezira_CompositeUniformColorOverImage_ARGB32 (init, &window->image, FLAKE_ALPHA, FLAKE_RED, FLAKE_GREEN, FLAKE_BLUE), NILE_NULL); nile_Process_feed (pipeline, snowflake_path, snowflake_path_n); }
/* This routine is deprecated since praat-4.2.4 20040422 and will be removed in the future. */ void FFNet_drawWeightsToLayer (FFNet me, Graphics g, int layer, int scaling, int garnish) { if (layer < 1 || layer > my nLayers) { Melder_throw (U"Layer must be in [1,", my nLayers, U"]."); } autoMatrix weights = FFNet_weightsToMatrix (me, layer, 0); Matrix_scale (weights.peek(), scaling); Matrix_drawAsSquares (weights.peek(), g, 0.0, 0.0, 0.0, 0.0, 0); if (garnish) { double x1WC, x2WC, y1WC, y2WC; Graphics_inqWindow (g, & x1WC, & x2WC, & y1WC, & y2WC); Graphics_textBottom (g, false, Melder_cat (U"Units in layer ", layer, U" ->")); if (layer == 1) { Graphics_textLeft (g, false, U"Input units ->"); } else { Graphics_textLeft (g, false, Melder_cat (U"Units in layer ", layer - 1, U" ->")); } /* how do I find out the current settings ??? */ Graphics_setTextAlignment (g, Graphics_RIGHT, Graphics_HALF); Graphics_setInner (g); Graphics_text (g, 0.5, weights->ny, U"bias"); Graphics_unsetInner (g); } }
Matrix Matrix_scaled(Matrix matrix, float x, float y, float z) { Matrix_scale(&matrix, x, y, z); return matrix; }