// Splits the image in pieces and calls the corresponding algorithm void *thread_launcher(void *arguments) { piece_args *args; args = (piece_args *) arguments; int x,y, small_res_x, small_res_y, init_x, init_y, limit_x, limit_y; int split, piece_x, piece_y; if(args->total_threads > 2) { split = sqrt(args->total_threads); } else if (args->total_threads == 2) { split = 2; } else { split = 1; } if (args->thread_number > 0) { piece_x = args->thread_number % split; piece_y = floor((float)args->thread_number / (float)split); } else { piece_x = 0; piece_y = 0; } small_res_x = floor((float)args->res_x / (float)split); small_res_y = floor((float)args->res_y / (float)split); init_x = small_res_x * piece_x; init_y = small_res_y * piece_y; limit_x = init_x + small_res_x; limit_y = init_y + small_res_y; for (y = init_y; y < limit_y; y++) { for (x = init_x; x < limit_x; x++) { if(args->julia_mode == 0) iteration_pixels[x + (y * args->res_x)] = mandelbrot_point(args->res_x, args->res_y, x, y, args->zoom, args->max_iteration); else iteration_pixels[x + (y * args->res_x)] = julia_point(args->res_x, args->res_y, x, y, args->zoom, args->max_iteration); } } }
void MandelbrotShower::mouseReleaseEvent(QMouseEvent *e){ moving = false; update(); move_now = e->pos(); QPointF start(xmin + move_start.x()*xres, ymax - move_start.y()*yres); QPointF stop(xmin + move_now.x()*xres, ymax - move_now.y()*yres); QRectF new_rect(start, stop); QSize new_size; if (!lock_proportions){ new_size = size; if (size.width() < size.height()) new_size.setHeight(size.width()*fabs(new_rect.height()/new_rect.width())); else new_size.setWidth(size.height()*fabs(new_rect.width()/new_rect.height())); } if (!new_rect.isNull()) emit region_selected(new_rect, new_size); else if (!julia) emit julia_point(stop); }