/* GLTexture::loadImage * Loads SImage data to the texture. If the dimensions are invalid * for the system opengl implementation, the data will be split into * 128x128 squares. Returns false if the given data is invalid, true * otherwise *******************************************************************/ bool GLTexture::loadImage(SImage* image, Palette8bit* pal) { // Check image was given if (!image) return false; // Check image is valid if (!image->isValid()) return false; // Clear current texture clear(); // Check image dimensions if (OpenGL::validTexDimension(image->getWidth()) && OpenGL::validTexDimension(image->getHeight())) { // If the image dimensions are valid for OpenGL on this system, just load it as a single texture // Get RGBA image data MemChunk rgba; image->getRGBAData(rgba, pal); // Generate GL texture from rgba data return loadData(rgba.getData(), image->getWidth(), image->getHeight()); } else { // Otherwise split the image into 128x128 chunks int top = 0; while (top < image->getHeight()) { int left = 0; while (left < image->getWidth()) { // Load 128x128 portion of image loadImagePortion(image, rect_t(left, top, left + 128, top + 128), pal, true); // Move right 128px left += 128; } // Move down 128px top += 128; } // Update variables width = image->getWidth(); height = image->getHeight(); return true; } }
HRESULT __stdcall hooks::hooked_present(IDirect3DDevice9* m_device, const RECT* source_rect, const RECT* dest_rect, HWND dest_window_override, const RGNDATA* dirty_region) { static auto original_fn = directx_hook->get_func_address<PresentFn>(17); IDirect3DStateBlock9* state_block = nullptr; if (m_device->CreateStateBlock(D3DSBT_PIXELSTATE, &state_block) < 0) [m_device]() { if (!render::get().initalized) { render::get().initalize_objects(m_device); render::get().initalized = true; } else { render::get().setup_states(); // Sets up proper render states for our state block rect_t m_pos = rect_t( menu::get().area.x - 74, menu::get().area.y, menu::get().area.w + 74, 1 ); if (!menu::get().active()) { otheresp::get().spread_crosshair(m_device); } } }(); state_block->Apply(); state_block->Release(); return original_fn(m_device, source_rect, dest_rect, dest_window_override, dirty_region); }
void C_ColorSelector::update() { auto recalculate_color = [this]() -> void { float new_brightness = 2.0f - brightness; int new_colors[3] = { new_brightness * color.r(), new_brightness * color.g(), new_brightness * color.b() }; if (new_brightness > 1.0f) { new_colors[0] = color.r() + (new_brightness - 1.0f) * (255 - color.r()); new_colors[1] = color.g() + (new_brightness - 1.0f) * (255 - color.g()); new_colors[2] = color.b() + (new_brightness - 1.0f) * (255 - color.b()); } *preview_color = Color(new_colors[0], new_colors[1], new_colors[2]); }; if (!open) { return; } parent->focus_subcontrol(this); POINT mouse; GetCursorPos(&mouse); rect_t open_area = rect_t( area.x, area.y + area.h, 234, 254 ); if (menu::get().key_press(VK_LBUTTON) && !open_area.contains_point(mouse)) { open = false; parent->reset_block(); } open_area = rect_t( area.x + 9, area.y + area.h + 9, 216, 216 ); rect_t slider_area = rect_t( area.x + 9, area.y + area.h + 227, 216, 11 ); if (GetAsyncKeyState(VK_LBUTTON) && slider_area.contains_point(mouse)) { dragging = true; } if (dragging) { if (GetAsyncKeyState(VK_LBUTTON)) { float new_x, ratio; new_x = mouse.x - slider_area.x; if (new_x < 0) { new_x = 0; } if (new_x > slider_area.w) { new_x = 216; } ratio = new_x / float(slider_area.w); brightness = 2.0f * ratio; recalculate_color(); } else { dragging = false; } } if (GetAsyncKeyState(VK_LBUTTON) && open_area.contains_point(mouse) && !dragging) { color = color_from_pen(open_area.x, open_area.y, 216, 216, Vector2D(mouse.x - open_area.x, mouse.y - open_area.y)); recalculate_color(); } }
void C_ColorSelector::draw() { render::get().gradient(area.x, area.y, area.w, area.h, *preview_color, Color::Black, GRADIENT_VERTICAL); render::get().rect(area.x, area.y, area.w, area.h, Color::Black); rect_t n_area = rect_t( area.x, area.y + area.h, 234, 254 ); if (open) { render::get().gradient(n_area.x, n_area.y, n_area.w, n_area.h, Color{ 25, 25, 25 }, Color::Black, GRADIENT_VERTICAL); render::get().rect(n_area.x, n_area.y, n_area.w, n_area.h, Color::Black); n_area = rect_t( n_area.x + 5, n_area.y + 5, n_area.w - 10, n_area.h - 10 ); render::get().gradient(n_area.x, n_area.y, n_area.w, n_area.h, Color{ 35, 35, 35, 255 }, Color::Black, GRADIENT_VERTICAL); render::get().rect(n_area.x, n_area.y, n_area.w, n_area.h, Color::Black); n_area = rect_t( n_area.x + 4, n_area.y + 4, n_area.w - 8, n_area.h - 28 ); spectrum(n_area.x, n_area.y, 216, 216); render::get().rect(n_area.x, n_area.y, n_area.w, n_area.h, Color::Black); rect_t slider_area = rect_t( n_area.x, n_area.y + 218, 216, 11 ); render::get().gradient(slider_area.x, slider_area.y, 108, 11, Color::White, color, GRADIENT_HORIZONTAL); render::get().gradient(slider_area.x + 108, slider_area.y, 108, 11, color, Color::Black, GRADIENT_HORIZONTAL); render::get().rect(slider_area.x, slider_area.y, 216, 11, Color::Black); slider_area.y += 12; float ratio = (brightness - 0.0f) / (2.0f - 0.0f); float location = ratio * 216; int points[6] = { slider_area.x + location, slider_area.y, slider_area.x + location + 4, slider_area.y + 6, slider_area.x + location - 4, slider_area.y + 6, }; render::get().triangle(Vector2D(points[0], points[1]), Vector2D(points[2], points[3]), Vector2D(points[4], points[5]), Color(153, 153, 153)); } }
tensor_t model_t::make_input(const image_t& image, coord_t x, coord_t y) const { const rect_t region = rect_t(x, y, icols(), irows()); return image.to_tensor(region); }
void init(textformat_t& aSettings) { aSettings.sendfrompath = "sendfrom.txt"; aSettings.font = "IPAexMincho"; aSettings.fontpath = ""; aSettings.zipfont = "OCRB"; aSettings.outputpath = ""; aSettings.pagedelimiter = '|'; aSettings.drawnenga = false; aSettings.sendfrom_zipframe_offset = point_t(0.000000, 0.000000); aSettings.sendfrom.dlmt = ';'; aSettings.sendfrom.zipfontsize = 12.000000; aSettings.sendfrom.name.rect = rect_t(0.000000, 200.000000, 32.000000, 340.000000); aSettings.sendfrom.name.fontsize = 32.000000; aSettings.sendfrom.name.whitespace = 0.400000; aSettings.sendfrom.name.stretch = true ; aSettings.sendfrom.name.bottom = false; aSettings.sendfrom.name.linebreak = '\n'; aSettings.sendfrom.addr.rect = rect_t(32.000000, 160.000000, 80.000000, 340.000000); aSettings.sendfrom.addr.fontsize = 20.000000; aSettings.sendfrom.addr.whitespace = 0.000000; aSettings.sendfrom.addr.stretch = false; aSettings.sendfrom.addr.bottom = true ; aSettings.sendfrom.addr.linebreak = '\n'; aSettings.sendfrom.extra[0].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendfrom.extra[0].fontsize = 20.000000; aSettings.sendfrom.extra[0].whitespace = 0.000000; aSettings.sendfrom.extra[0].stretch = false; aSettings.sendfrom.extra[0].bottom = true ; aSettings.sendfrom.extra[0].linebreak = '\n'; aSettings.sendfrom.extra[1].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendfrom.extra[1].fontsize = 20.000000; aSettings.sendfrom.extra[1].whitespace = 0.000000; aSettings.sendfrom.extra[1].stretch = false; aSettings.sendfrom.extra[1].bottom = true ; aSettings.sendfrom.extra[1].linebreak = '\n'; aSettings.sendfrom.extra[2].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendfrom.extra[2].fontsize = 0.000000; aSettings.sendfrom.extra[2].whitespace = 0.000000; aSettings.sendfrom.extra[2].stretch = false; aSettings.sendfrom.extra[2].bottom = false; aSettings.sendfrom.extra[2].linebreak = '\n'; aSettings.sendfrom.extra[3].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendfrom.extra[3].fontsize = 0.000000; aSettings.sendfrom.extra[3].whitespace = 0.000000; aSettings.sendfrom.extra[3].stretch = true ; aSettings.sendfrom.extra[3].bottom = false; aSettings.sendfrom.extra[3].linebreak = '\n'; aSettings.sendfrom.extra[4].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendfrom.extra[4].fontsize = 0.000000; aSettings.sendfrom.extra[4].whitespace = 0.000000; aSettings.sendfrom.extra[4].stretch = true ; aSettings.sendfrom.extra[4].bottom = true ; aSettings.sendfrom.extra[4].linebreak = '\n'; aSettings.sendfrom.extra[5].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendfrom.extra[5].fontsize = 0.000000; aSettings.sendfrom.extra[5].whitespace = 0.000000; aSettings.sendfrom.extra[5].stretch = true ; aSettings.sendfrom.extra[5].bottom = true ; aSettings.sendfrom.extra[5].linebreak = '\n'; aSettings.sendfrom.drawzipframe = false; aSettings.sendto.dlmt = ';'; aSettings.sendto.zipfontsize = 16.000000; aSettings.sendto.name.rect = rect_t(117.732283, 80.000000, 165.732283, 360.000000); aSettings.sendto.name.fontsize = 32.000000; aSettings.sendto.name.whitespace = 0.400000; aSettings.sendto.name.stretch = true ; aSettings.sendto.name.bottom = false; aSettings.sendto.name.linebreak = '\n'; aSettings.sendto.addr.rect = rect_t(219.464567, 80.000000, 283.464567, 330.000000); aSettings.sendto.addr.fontsize = 20.000000; aSettings.sendto.addr.whitespace = 0.400000; aSettings.sendto.addr.stretch = false; aSettings.sendto.addr.bottom = true ; aSettings.sendto.addr.linebreak = '\n'; aSettings.sendto.extra[0].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendto.extra[0].fontsize = 0.000000; aSettings.sendto.extra[0].whitespace = 0.000000; aSettings.sendto.extra[0].stretch = false; aSettings.sendto.extra[0].bottom = false; aSettings.sendto.extra[0].linebreak = '\n'; aSettings.sendto.extra[1].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendto.extra[1].fontsize = 0.000000; aSettings.sendto.extra[1].whitespace = 0.000000; aSettings.sendto.extra[1].stretch = true ; aSettings.sendto.extra[1].bottom = true ; aSettings.sendto.extra[1].linebreak = '\n'; aSettings.sendto.extra[2].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendto.extra[2].fontsize = 0.000000; aSettings.sendto.extra[2].whitespace = 0.000000; aSettings.sendto.extra[2].stretch = true ; aSettings.sendto.extra[2].bottom = true ; aSettings.sendto.extra[2].linebreak = '\n'; aSettings.sendto.extra[3].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendto.extra[3].fontsize = 0.000000; aSettings.sendto.extra[3].whitespace = 0.000000; aSettings.sendto.extra[3].stretch = true ; aSettings.sendto.extra[3].bottom = true ; aSettings.sendto.extra[3].linebreak = '\n'; aSettings.sendto.extra[4].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendto.extra[4].fontsize = 0.000000; aSettings.sendto.extra[4].whitespace = 0.000000; aSettings.sendto.extra[4].stretch = true ; aSettings.sendto.extra[4].bottom = true ; aSettings.sendto.extra[4].linebreak = '\n'; aSettings.sendto.extra[5].rect = rect_t(0.000000, 0.000000, 0.000000, 0.000000); aSettings.sendto.extra[5].fontsize = 0.000000; aSettings.sendto.extra[5].whitespace = 0.000000; aSettings.sendto.extra[5].stretch = true ; aSettings.sendto.extra[5].bottom = true ; aSettings.sendto.extra[5].linebreak = '\n'; aSettings.sendto.drawzipframe = false; }
GridMSComplex::mscomplex_t * GridMSComplex::merge_up (const mscomplex_t& msc1, const mscomplex_t& msc2) { // form the intersection rect rect_t ixn; if (!msc2.m_rect.intersection (msc1.m_rect,ixn)) throw std::logic_error ("rects should intersect for merge"); if ( (ixn.left() != ixn.right()) && (ixn.top() != ixn.bottom())) throw std::logic_error ("rects must merge along a 1 manifold"); if (ixn.bottom_left() == ixn.top_right()) throw std::logic_error ("rects cannot merge along a point alone"); // TODO: ensure that the union of rects is not including anything extra rect_t r = rect_t (std::min (msc1.m_rect.bottom_left(),msc2.m_rect.bottom_left()), std::max (msc1.m_rect.top_right(),msc2.m_rect.top_right())); rect_t e = rect_t (std::min (msc1.m_ext_rect.bottom_left(),msc2.m_ext_rect.bottom_left()), std::max (msc1.m_ext_rect.top_right(),msc2.m_ext_rect.top_right())); mscomplex_t * out_msc = new mscomplex_t(r,e); const mscomplex_t* msc_arr[] = {&msc1,&msc2}; // make a union of the critical points in this for (uint i = 0 ; i <2;++i) { const mscomplex_t * msc = msc_arr[i]; for (uint j = 0 ; j <msc->m_cps.size();++j) { const critpt_t *src_cp = msc->m_cps[j]; // if it is contained or not if (i == 1 && (out_msc->m_id_cp_map.count(src_cp->cellid) == 1)) continue; if(src_cp->isCancelled) continue; shallow_replicate_cp(*out_msc,*src_cp); out_msc->m_cp_fns.push_back(msc->m_cp_fns[j]); } } for (uint i = 0 ; i <2;++i) { const mscomplex_t * msc = msc_arr[i]; // copy over connectivity information for (uint j = 0 ; j <msc->m_cps.size();++j) { const critpt_t *src_cp = msc->m_cps[j]; if(src_cp->isCancelled) continue; critpt_t *dest_cp = out_msc->m_cps[out_msc->m_id_cp_map[src_cp->cellid]]; if(src_cp->isBoundryCancelable) { critpt_t *src_pair_cp = msc->m_cps[src_cp->pair_idx]; dest_cp->pair_idx = out_msc->m_id_cp_map[src_pair_cp->cellid]; } const conn_t *acdc_src[] = {&src_cp->asc, &src_cp->des}; conn_t *acdc_dest[] = {&dest_cp->asc,&dest_cp->des}; bool is_src_cmn_bndry = (ixn.contains(src_cp->cellid) && i == 1); for (uint j = 0 ; j < 2; ++j) { for (const_conn_iter_t it = acdc_src[j]->begin(); it != acdc_src[j]->end();++it) { const critpt_t *conn_cp = msc->m_cps[*it]; // common boundry connections would have been found along the boundry if( is_src_cmn_bndry && ixn.contains(conn_cp->cellid)) continue; if (conn_cp->isCancelled) continue; acdc_dest[j]->insert (out_msc->m_id_cp_map[conn_cp->cellid]); } } } } // carry out the cancellation for(cell_coord_t y = ixn.bottom(); y <= ixn.top();++y) { for(cell_coord_t x = ixn.left(); x <= ixn.right();++x) { cellid_t c(x,y); if(out_msc->m_id_cp_map.count(c) != 1) throw std::logic_error("missing common bndry cp"); u_int src_idx = out_msc->m_id_cp_map[c]; critpt_t *src_cp = out_msc->m_cps[src_idx]; if(src_cp->isCancelled || !src_cp->isBoundryCancelable) continue; u_int pair_idx = src_cp->pair_idx; cellid_t p = out_msc->m_cps[pair_idx]->cellid; if(!out_msc->m_rect.isInInterior(c)&& !out_msc->m_ext_rect.isOnBoundry(c)) continue; if(!out_msc->m_rect.isInInterior(p)&& !out_msc->m_ext_rect.isOnBoundry(p)) continue; cancelPairs(out_msc,src_idx,pair_idx); } } return out_msc; }