void JuliaTool::sizeEvent(bool toolIsActive) { stop_rendering(&j_pre); int xw,yw; if ((JPRE_SIZE / img->ratio) < JPRE_SIZE) { xw = JPRE_SIZE; yw = int(JPRE_SIZE / img->ratio); if (yw == 0) yw = 1; } else { xw = int(JPRE_SIZE * img->ratio); if (xw == 0) xw = 1; yw = JPRE_SIZE; } j_pre.setSize(xw, yw, JPRE_AA_FACTOR); gtk_widget_set_size_request(j_pre.drawing_area, xw, yw); if (toolIsActive) { gtk_widget_hide(j_pre_window); gtk_widget_show(j_pre_window); start_rendering(&j_pre); } }
void CropTool::crop(void) { GdkRectangle r = getRect(); double oldW = img->finfo.xmax - img->finfo.xmin; double oldH = img->finfo.ymax - img->ymin(); double xmin = img->getX(r.x); double xmax = img->getX(r.x + r.width); double ymax = img->getY(r.y); double ymin = img->getY(r.y + r.height); img->finfo.xmin = xmin; img->finfo.xmax = xmax; img->finfo.ymax = ymax; double newW = img->finfo.xmax - img->finfo.xmin; double newH = img->finfo.ymax - ymin; tool_deactivate(); stop_rendering(img); img->setSize(std::max(1, int(img->user_width * (newW / oldW))), std::max(1, int(img->user_height * (newH / oldH))), img->aa_factor); image_size_changed(); start_rendering(img); }
void JuliaTool::moveEvent(int x, int y) { j_pre.finfo.u.julia.c_re = img->getX(x); j_pre.finfo.u.julia.c_im = img->getY(y); start_rendering(&j_pre); }
int render(t_data *data) { if (!data->itfc.rendering && !data->itfc.rendered && data->rt.img) { data->itfc.rendering = true; data->rt.live = false; if (start_rendering(data) == 1) return (1); } return (0); }
bool JuliaTool::activate() { if (img->finfo.type == MANDELBROT) { gtk_widget_show(j_pre_window); start_rendering(&j_pre); return true; } else { img->finfo.xmin = old_xmin; img->finfo.xmax = old_xmax; img->finfo.ymax = old_ymax; img->finfo.type = MANDELBROT; start_rendering(img); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbarButton), FALSE); return false; } }
void ZoomInTool::zoom(void) { double xmin = img->getX(rect.x); double xmax = img->getX(rect.x + rect.width); double ymax = img->getY(rect.y); img->finfo.xmin = xmin; img->finfo.xmax = xmax; img->finfo.ymax = ymax; tool_deactivate(); start_rendering(img); }
bool ZoomOutTool::activate() { double half_w, half_h; half_w = (img->finfo.xmax - img->finfo.xmin) / 2.0; half_h = (img->finfo.ymax - img->ymin()) / 2.0; img->finfo.ymax += half_h; img->finfo.xmin -= half_w; img->finfo.xmax += half_w; start_rendering(img); return false; }
int main(int argc, char **argv) #endif { #ifdef MEMORY_DEBUG elm_init(); #endif //MEMORY_DEBUG gargc=argc; gargv=argv; // do basic initialization #ifdef OLC olc_init(); #endif //OLC init_logging("log"); check_log_level_on_command_line(); create_tcp_out_mutex(); init_translatables(); #ifdef FSAA init_fsaa_modes(); #endif /* FSAA */ init_vars(); ENTER_DEBUG_MARK("init stuff"); init_stuff(); LEAVE_DEBUG_MARK("init stuff"); start_rendering(); #ifdef MEMORY_DEBUG elm_cleanup(); #endif //MEMORY_DEBUG #ifdef OLC olc_shutdown(); #endif //OLC #ifndef WINDOWS // attempt to restart if requested if(restart_required > 0){ LOG_INFO("Restarting %s\n", *argv); execv(*argv, argv); } #endif //WINDOWS return 0; }
void JuliaTool::buttonEvent(ButtonType type, bool isPress, int x, int y) { if ((type != LEFT) || !isPress) { return; } img->finfo.u.julia.c_re = img->getX(x); img->finfo.u.julia.c_im = img->getY(y); old_xmin = img->finfo.xmin; old_xmax = img->finfo.xmax; old_ymax = img->finfo.ymax; img->finfo.xmin = j_pre.finfo.xmin; img->finfo.xmax = j_pre.finfo.xmax; img->finfo.ymax = j_pre.finfo.ymax; img->finfo.type = JULIA; tool_deactivate(); start_rendering(img); }
int main( int argc, char *argv[] ) { int quit = 0; pthread_t render_loop_thread = -1; IDirectFBSurface *primary; IDirectFBEventBuffer *buffer; DFBSurfaceDescription dsc; srand((long)time(0)); DFBCHECK(DirectFBInit( &argc, &argv )); /* create the super interface */ DFBCHECK(DirectFBCreate( &dfb )); /* get an interface to the primary keyboard and create an input buffer for it */ DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_ALL, DFB_FALSE, &buffer )); /* set our cooperative level to DFSCL_FULLSCREEN for exclusive access to the primary layer */ dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN ); /* get the primary surface, i.e. the surface of the primary layer we have exclusive access to */ dsc.flags = DSDESC_CAPS; dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE; DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary )); DFBCHECK(primary->GetSize( primary, &xres, &yres )); /* load font */ { DFBFontDescription desc; desc.flags = DFDESC_HEIGHT; desc.height = yres/10; DFBCHECK(dfb->CreateFont( dfb, FONT, &desc, &font )); DFBCHECK(primary->SetFont( primary, font )); } projection = matrix_new_perspective( 400 ); camera = matrix_new_identity(); load_stars(); generate_starfield(); pthread_mutex_lock( &render_start ); pthread_mutex_lock( &render_finish ); pthread_create( &render_loop_thread, NULL, render_loop, (void*)primary ); /* main loop */ while (!quit) { static float translation[3] = { 0, 0, 0 }; DFBInputEvent evt; /* transform world to screen coordinates */ transform_starfield(); /* start rendering before waiting for events */ start_rendering(); buffer->WaitForEvent( buffer ); /* process event buffer */ while (buffer->GetEvent( buffer, DFB_EVENT(&evt)) == DFB_OK) { if (evt.type == DIET_KEYPRESS) { switch (evt.key_id) { case DIKI_ESCAPE: /* quit main loop */ quit = 1; break; case DIKI_LEFT: translation[0] = 10; break; case DIKI_RIGHT: translation[0] = -10; break; case DIKI_UP: translation[2] = -10; break; case DIKI_DOWN: translation[2] = 10; break; default: break; } } else if (evt.type == DIET_KEYRELEASE) { switch (evt.key_id) { case DIKI_LEFT: case DIKI_RIGHT: translation[0] = 0; break; case DIKI_UP: case DIKI_DOWN: translation[2] = 0; break; default: break; } } else if (evt.type == DIET_AXISMOTION && (evt.flags & DIEF_AXISREL)) { switch (evt.axis) { case DIAI_X: matrix_rotate( camera, Y, -evt.axisrel/80.0f ); break; case DIAI_Y: matrix_rotate( camera, X, evt.axisrel/80.0f ); break; default: break; } } } matrix_translate( camera, translation[0], translation[1], translation[2] ); /* finish rendering before retransforming the world */ finish_rendering(); } pthread_cancel( render_loop_thread ); pthread_mutex_unlock( &render_start ); pthread_join( render_loop_thread, NULL ); render_loop_thread = -1; unload_stars(); free( camera ); free( projection ); buffer->Release( buffer ); primary->Release( primary ); dfb->Release( dfb ); return 0; }