00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _IMAGEPOINTSGENERATOR_H_
00022 #define _IMAGEPOINTSGENERATOR_H_
00023
00024 #include "../pointsgenerator.h"
00025
00029 class ImagePointsGenerator : public PointsGenerator
00030 {
00031 private:
00032 unsigned int m_progress;
00033 qreal m_x, m_y;
00034 qreal m_x_step, m_y_step;
00035
00036 public:
00037 ImagePointsGenerator( const FractalParameters * _fractal_parameters )
00038 : PointsGenerator( _fractal_parameters )
00039 {
00040 m_progress = 0;
00041 }
00042
00043 qreal progress() const
00044 {
00045 return m_progress / (qreal)( m_fractal_parameters->imageSize().width() * m_fractal_parameters->imageSize().height() );
00046 }
00047
00048 void init()
00049 {
00050 m_x_step = m_fractal_parameters->zone().width() / (qreal)( m_fractal_parameters->imageSize().width() );
00051 m_y_step = m_fractal_parameters->zone().height() / (qreal)( m_fractal_parameters->imageSize().height() );
00052
00053
00054 m_x = m_fractal_parameters->zone().x() + m_x_step * 0.5;
00055 m_y = m_fractal_parameters->zone().y() + m_y_step * 0.5;
00056
00057 m_progress = 0;
00058 }
00059
00060 Point next()
00061 {
00062 Point point( m_x , m_y );
00063
00064 m_x += m_x_step;
00065 if( m_x > m_fractal_parameters->zone().x() + m_fractal_parameters->zone().width() )
00066 {
00067 m_x = m_fractal_parameters->zone().x() + m_x_step * 0.5;
00068 m_y += m_y_step;
00069 }
00070
00071 m_progress++;
00072
00073 return point;
00074 }
00075
00076 bool end()
00077 {
00078 return m_y > m_fractal_parameters->zone().y() + m_fractal_parameters->zone().height();
00079 }
00080 };
00081
00082 #endif //_IMAGEPOINTSGENERATOR_H_