% function plot_chars(GLYPHS)
%
% ---- Preconditions ----
% GLYPHS: a matrix with labelled characters in the rows
%
% ---- Postconditions ----
% A new figure is created, and the glyphs are plotted left
% to right, top to bottom, in roughly a 3/4 width to height
% aspect ratio. Glyphs with labels are labelled, and 
% unlabelled glyphs are given no label and assumed to be
% single stroke.

function plot_chars(GLYPHS)

N = size(GLYPHS, 1);
b = ceil(sqrt(4/3*N));
a = ceil(3/4*b);
figure;
for n=1:N,
    current = GLYPHS(n,:);
    name = labels(current);      % Extract the name of the character
    strokes = number_strokes(current); %Extract the number of strokes
    current = unlabel(current);
    subplot(b, a, n),
    switch strokes,
        case 1,
            plot(current(1:36),current(37:72));
        case 2,
            plot(current(1:18),current(19:36)); hold on;
            plot(current(37:54), current(55:72));
        case 3,
            plot(current(1:12),current(13:24)); hold on;
            plot(current(25:36), current(37:48));
            plot(current(49:60), current(61:72));
        case 4,
            plot(current(1:9),current(10:18)); hold on;
            plot(current(19:27), current(28:36));
            plot(current(37:45), current(46:54));
            plot(current(55:63), current(64:72));
        otherwise,
            plot(current(1:36),current(37:72));
    end;
    text(-10,-10, name);
    axis ij equal off;
end;