I have some partial proof of concept results to show regarding rendering patterns in SVG in a WebViewer.
(I hit my complexity limit fitting your global variables to my solution.)
A SVG graphic in a Web Viewer:
The SVG generated from a matrix of stitches:
Source:
movePatternTrial_SVG.aia (218.0 KB)
The steps taken to generate the matrix and render it:
(This is where I lost track of some global variable dimensions and intentions)
The matrix generator:
Two service routines for that procedure:
The set_table procedure allows setting of any location in a table, padding as needed to jump gaps.
This is a test bed.
Generating SVG and sending it into the WebViewer:
I switched to a global variable for input, to enable Do It testing.
I don't know what I was thinking, adding that size parameter. The matrix and the WebViewer dimensions were all I needed, given that I wanted to fill the WebViewer from the matrix.
Wrapping the SVG shell with size information:
To generate the rectangles in the pattern, I needed to pass the total dimensions, and the matrix. Again, I lost track of what the size was supposed to mean.
This is where I loop over the matrix, by row and column index, generating individual colored rectangles in the proper positions in the SVG region. Each rectangle has to know where it should appear, its dimensions, and its color (style).
This is where the text for an SVG rectangle is built up, piece by piece.
This code translates matrix values (0/1) into SVG colors. A slight optimization is done at global init time, translating AI2 color blocks into SVG CSS colors.
Forgive me if I don't know my warp from my weft.
More info on SVG rectangles:












