bookCollapseSection | weight | draft | title |
---|---|---|---|
true |
8 |
false |
Visual Algorithms |
The visual algorithms suite comprises methods that manipulate and visually represent data within quadrille
cells. Functions such as [filter]({{< relref "filter" >}}) for image convolutions, [rasterize]({{< relref "rasterize" >}}) for software-based barycentric interpolations, and [sort]({{< relref "sort" >}}) for arranging cells based on visual criteria enable the creation of dynamic and interactive visualizations. These methods collectively transform the quadrille into an interactive canvas for illustrating and navigating visual computing concepts, offering an intuitive way to explore algorithms for rasterization, image processing, and data sorting.
{{< callout type="info" >}}
The methods in this section support method chaining. For example:
quadrille.filter(mask).rasterize(shader, array);
is equivalent to:
quadrille.filter(mask);
quadrille.rasterize(shader, array);
This approach enhances readability and streamlines the application of multiple operations. {{< /callout >}}
- [filter(mask)]({{< relref "filter" >}}): Applies a convolution filter to the quadrille using a specified
mask
for image processing operations. - [sort(comparator)]({{< relref "sort" >}}): Rearranges the quadrille’s cells based on visual criteria defined by a
comparator
function. - [sample()]({{< relref "sample" >}}): Samples the quadrille’s cells to create a new quadrille based on specified sampling criteria.
- [rasterize(shader, array)]({{< relref "rasterize" >}}): Performs software-based barycentric interpolations, transforming the quadrille's cells based on the provided
shader
function andarray
. - [colorize(color0, color1, color2, color3)]({{< relref "colorize" >}}): Colors the entire
quadrille
by interpolating between the colors specified for each corner—color0
(upper-left),color1
(bottom-left),color2
(upper-right), andcolor3
(bottom-right). - [rasterizeTriangle(row0, col0, row1, col1, row2, col2, shader, array0, array1 = array0, array2 = array0)]({{< relref "rasterize_triangle" >}}): Rasterizes a triangle within the
quadrille
defined by the vertices at (row0
,col0
), (row1
,col1
), and (row2
,col2
). It utilizes barycentric coordinates to interpolate attributes specified inarray0
,array1
, andarray2
across the triangle's surface. Theshader
function, parameterized with an object{ array: interpolated_data_array, row: i, col: j }
, processes the interpolated data and returns ap5.Color
for each cell within the triangle. - [colorizeTriangle(row0, col0, row1, col1, row2, col2, color0, color1 = color0, color2 = color0)]({{< relref "colorize_triangle" >}}): Colors the triangle within the
quadrille
defined by the vertices at (row0
,col0
), (row1
,col1
), and (row2
,col2
). It uses barycentric coordinates to interpolate between the specified colors—color0
,color1
, andcolor2
—assigned to each vertex, creating a smooth gradient effect across the triangle.
The visual algorithms suite provides essential tools for working with rasterization, image filtering, sampling, and sorting, allowing you to manipulate cell content dynamically and create visually expressive quadrilles.