
% Homework 4
% radioButtonCallback.m
% CS 1109, Summer 2011
% July 18

% This script implements the callback routine for when the radio button
% selection changes.

% What did the user select?
selectedPattern = get(radioHandle, 'SelectedObject');

% Based on the new selection, determine the new initial pattern
switch selectedPattern
    case pattern(1)
        startingPattern = 'glider';
    case pattern(2)
        startingPattern = 'crab';
    case pattern(3)
        startingPattern = 'die_hard';
    case pattern(4)
        startingPattern = 'switch_engine';
    case pattern(5)
        startingPattern = 'glider_gun';
    case pattern(6)
        startingPattern = 'random';
end

% Draw the new initial pattern
[blueCells redCells] = initPattern(startingPattern);

% Refresh the image and reset generation count
set(imageHandle, imgType, cat(3,redCells,z,blueCells));
generation = 0;
