function varargout = mandel120(varargin)
% MANDEL120 M-file for mandel120.fig
% MANDEL120, by itself, creates a new MANDEL120 or raises the existing
% singleton*.
%
% H = MANDEL120 returns the handle to a new MANDEL120 or the handle to
% the existing singleton*.
%
% MANDEL120('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MANDEL120.M with the given input arguments.
%
% MANDEL120('Property','Value',...) creates a new MANDEL120 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before mandel120_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to mandel120_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% This program uses a vecorised mandelbrot algorithm (a pretty fast algorithm from
% Lucio Andrade-Cetto which worked great for me.) I tried before the
% Fractal Explorer from Laurant Cavin, but that program was not
% running on my computer.
%% Usage
% Example: type mandel120 and the program will start it does not
% require any parameters and the GUI transfers all parameters
% automaically to its sub routines.
% Examples: The program starts by loading the mandelbrot set which is stored as
% mat files x.mat, y.mat and Zvalues.mat
%% The program lets you zoom easily into the Mandelbrot Set by just
% selecting a subset of the currently displayed graph and then press
% the Command Button "Apply Zoom to MandelBrot set" and the new
% calcualtion will be performed.
% 3D views of the Mandelbrot set are easily created by clicked the 3D
% pushbutton, 3D Rotate, or one of the 2 sliders that allow to alter
% the view ing point of the Mandelbrot set.
% The Mandelbrot set contains 2 custom colormaps that will generally
% suit mandelbrot set more than the existing standard repertoir of
% colormaps.
% Changes since the last version:
% Textboxes are now udated in the textbox update_function, which
% reduces the amount redundant code in the main script.
% I will try to add more functions to the GUI and to improve the
% code.
% Enjoy
% Any questions or suggestions than drop me a line: jens.koopmann "at" live.com
%% See also: GUIDE, GUIDATA, GUIHANDLES
%%
% Edit the above text to modify the response to help mandel120
% Last Modified by GUIDE v2.5 30-Oct-2008 08:49:58
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mandel120_OpeningFcn, ...
'gui_OutputFcn', @mandel120_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before mandel120 is made visible.
function mandel120_OpeningFcn(hObject, eventdata, handles, varargin)
%function mandel120_OpeningFcn(hObject, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to mandel120 (see VARARGIN)
% Choose default command line output for mandel120
handles.output = hObject;
handles.col=15;
handles.view=3;
handles.res=500;
handles.x_view=29;
handles.y_view=76;
handles.MaxIter=112;
handles.stepsI=500;
handles.stepsR=700;
handles.light=3;
%Load saved mandelbrot set
%Loading works out faster than calculating the set
load x;load y;load Zvalues;
handles.x=x; handles.y=y; handles.Zvalues=Zvalues;
%Update all Textbox in the GUI with the current inforamtion.
textbox_update(handles.text1,handles.text2,handles.text3,handles.text4,handles.text5,handles.text12,handles.text13,handles.text14,handles.text15,-1.9,0.8,-1.3,1.28,51,29,76,500,700);
color_change(handles.col,handles.view,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = mandel120_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject,eventdata,handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
h = pan;
dx=xlim;
dy=ylim;
lowerR=dx(1,1)
higherR=dx(1,2)
%Make sure that the aspect ratio maintains the same.
if lowerR <0
if higherR <0
ddx=abs(lowerR-higherR);
elseif higherR >0
ddx=abs(-lowerR+higherR);
end
elseif lowerR >0
ddx=abs(lowerR-higherR);
end
lowerI=dy(1,1);
%higherI=dy(1,2);
higherI=lowerI+ddx;
%Update all Textbox in the GUI with the current information.
textbox_update(handles.text1,handles.text2,handles.text3,handles.text4,handles.text5,handles.text12,handles.text13,handles.text14,handles.text15,lowerR,higherR,lowerI,higherI,handles.MaxIter,handles.x_view,handles.y_view,handles.stepsR,handles.stepsI);
[x, y, Zvalues ]=dummy2 (lowerR, higherR,lowerI,higherI,handles.stepsR,handles.stepsI,handles.MaxIter,handles.col,3,handles.x_view,handles.y_view,handles.light);
handles.x=x; handles.y=y; handles.Zvalues=Zvalues;
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%Hier werden die Startwerte fur das Apfelmannchen eingegeben und spater
%konnen sie durch ein Zoom ersetzt werden.
load x; load y; load Zvalues
handles.x=x;
handles.y=y;
handles.Zvalues=Zvalues;
%Update all Textbox in the GUI with the current information.
textbox_update(handles.text1,handles.text2,handles.text3,handles.text4,handles.text5,handles.text12,handles.text13,handles.text14,handles.text15,-1.9,0.8,-1.3,1.28,51,29,76,500,700);
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
% Update handles structure
guidata(hObject, handles);
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.col=get(hObject,'Value');
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.view=2;
color_change(handles.col,handles.view,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
zoom on;
guidata(hObject, handles);
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.view=3;
color_change(handles.col,handles.view,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light)
zoom off;
guidata(hObject, handles);
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.MaxIter=get(hObject,'Value');
handles.MaxIter=round(handles.MaxIter*1000);
set(handles.text5,'String',handles.MaxIter);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
%if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
% set(hObject,'BackgroundColor',[.9 .9 .9]);
%end
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.5 .5 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.stepsRes=get(hObject,'Value');
handles.stepsRes=round(40+handles.stepsR*3000);
handles.stepsR=round(40+handles.stepsI*4000);
set(handles.text7,'String',handles.stepsR);
set(handles.text8,'String',handles.stepsR);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function slider3_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light)
rotate3d
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[x, y, Zvalues ]=dummy2(-2, 2,-2,2,200,300,30,handles.col,handles.view,handles.x_view,handles.y_view,handles.light);
handles.x=x;
handles.y=y;
handles.Zvalues=Zvalues;
guidata(hObject, handles);
% --- Executes on slider movement.
function slider6_Callback(hObject, eventdata, handles)
% hObject handle to slider6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.x_view=get(hObject,'Value');
handles.x_view=round(handles.x_view*90);
set(handles.text10,'String',handles.x_view);
handles.view
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function slider6_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function slider7_Callback(hObject, eventdata, handles)
% hObject handle to slider7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.y_view=get(hObject,'Value');
handles.y_view=round(handles.y_view*90);
set(handles.text11,'String',handles.y_view);
handles.view
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function slider7_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function slider8_Callback(hObject, eventdata, handles)
% hObject handle to slider8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.x_view=get(hObject,'Value');
handles.x_view=round(handles.x_view*360);
set(handles.text12,'String',handles.x_view);
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function slider8_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function slider9_Callback(hObject, eventdata, handles)
% hObject handle to slider9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.y_view=get(hObject,'Value');
handles.y_view=round(handles.y_view*360);
set(handles.text13,'String',handles.y_view);
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function slider9_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function slider12_Callback(hObject, eventdata, handles)
% hObject handle to slider12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.stepsRes=get(hObject,'Value');
handles.stepsR=round(30+handles.stepsRes*1500);
handles.stepsI=round(40+handles.stepsRes*2000);
set(handles.text14,'String',handles.stepsR);
set(handles.text15,'String',handles.stepsI);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function slider12_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.light=1;
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
guidata(hObject, handles);
% --- Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.light=2;
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
guidata(hObject, handles);
% --- Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.light=3;
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
guidata(hObject, handles);
% --- Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.light=4;
color_change(handles.col,3,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
guidata(hObject, handles);
% --- Executes on button press in pushbutton18.
function pushbutton18_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
colormapeditor;
% --- Executes on button press in pushbutton19.
function pushbutton19_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fig=gcf;
Mandelcmap3 = get(fig,'Colormap')
save('MyColormaps3','Mandelcmap3')
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
handles.col=get(hObject,'Value');
load x1;load y1;load Zvalues1;
handles.x=x; handles.y=y; handles.Zvalues=Zvalues;
%Update all Textbox in the GUI with the current inforamtion.
textbox_update(handles.text1,handles.text2,handles.text3,handles.text4,handles.text5,handles.text12,handles.text13,handles.text14,handles.text15,-1.9,0.8,-1.3,1.28,51,29,76,500,700);
color_change(handles.col,handles.view,handles.x,handles.y,handles.Zvalues,handles.x_view,handles.y_view,handles.MaxIter,handles.light);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end