int ScopeGUI::resize_event(int w, int h) { clear_box(0, 0, w, h); this->w = w; this->h = h; calculate_sizes(w, h); if(waveform) { waveform->reposition_window(wave_x, wave_y, wave_w, wave_h); waveform->clear_box(0, 0, wave_w, wave_h); } if(histogram) { histogram->reposition_window(hist_x, hist_y, hist_w, hist_h); histogram->clear_box(0, 0, hist_w, hist_h); } if(vectorscope) { vectorscope->reposition_window(vector_x, vector_y, vector_w, vector_h); vectorscope->clear_box(0, 0, vector_w, vector_h); } allocate_bitmaps(); clear_points(0); draw_overlays(1, 1, 1); return 1; }
void Scene::clear_internal_data() { m_facet_tree.clear(); m_edge_tree.clear(); clear_points(); clear_segments(); clear_cutting_plane(); }
void Funct::reset() { if (r2-r1<=0) error("bad graphing range"); if (count <=0) error("non-positive graphing count"); double dist = (r2-r1)/count; double r = r1; clear_points(); for (int i = 0; i<count; ++i) { add(Point(orig.x+round(int(int(r*xscale)/prec)*prec),orig.y-round(int(int(f(r)*yscale)/prec)*prec))); r += dist; } }
void particles_render::draw_heat(const explosion &e) const { const float life_time = 5.0f; clear_points(); auto atc = tc(1920, 1664, 128, 128); auto nt = e.m_time / life_time; auto t = nya_math::min(e.m_time, 1.0f) + nt * 0.1f; auto r = e.m_radius * t * 3.0f; add_point(e.m_pos, r, atc, false, atc, false, color(1.0f, 1.0f, 1.0f, 1.0f) * 0.2f); draw_points(); }
void KMData::sample_centers(KMPointArray *sample, int k, double offset, bool allow_duplicate) { clear_points(sample); IMP_LOG_VERBOSE("KMData::sample_centers size: " << sample->size() << std::endl); if (!allow_duplicate) { IMP_INTERNAL_CHECK(((unsigned int)k) <= points_->size(), "not enough points to sample from"); } Ints sampled_ind; for (int i = 0; i < k; i++) { int ri = internal::random_int(points_->size()); if (!allow_duplicate) { bool dup_found; do { dup_found = false; // search for duplicates for (int j = 0; j < i; j++) { if (sampled_ind[j] == ri) { dup_found = true; ri = internal::random_int(points_->size()); break; } } } while (dup_found); } sampled_ind.push_back(ri); KMPoint *p = new KMPoint(); KMPoint *copied_p = (*points_)[ri]; for (int j = 0; j < dim_; j++) { p->push_back((*copied_p)[j] + internal::random_uniform(-1., 1) * offset); } sample->push_back(p); } IMP_LOG_VERBOSE("KMData::sampled centers : " << std::endl); for (int i = 0; i < k; i++) { IMP_LOG_WRITE(VERBOSE, print_point(*((*sample)[i]))); } IMP_LOG_VERBOSE("\nKMData::sample_centers end size : " << sample->size() << std::endl); }
void particles_render::draw(const fire_trail &t) const { clear_points(); for (size_t fi = 0; fi < t.m_count; ++fi) { const int i = (fi + t.m_offset) % t.max_count; const int tc_w_count = 16; //const int tc_h_count = 2; const int tc_idx = t.m_tci[i];//(tc_w_count * tc_h_count + 1) * nya_math::min(t.m_time / 5.0f, 1.0f); bool fire = fi + 7 >= t.m_count; color c = color(1.0f, 1.0f, 1.0f, 0.1 + 0.5f * fi / t.max_count); if (fire) c.xyz() *= hdr_coeff; add_point(t.m_pos[i].xyz(), t.m_pos[i].w, tc((tc_idx % tc_w_count) * 128, (fire ? 0 : 128) + (tc_idx / tc_w_count) * 128, 128, 128), !fire, tc(640 + t.m_tcia[i], 1280 + 128, 128, 128), true, c, nya_math::vec2(), t.m_rot[i]); } draw_points(); }
void ScopeGUI::create_panels() { calculate_sizes(get_w(), get_h()); if((use_wave || use_wave_parade)) { if(!waveform) { add_subwindow(waveform = new ScopeWaveform(this, wave_x, wave_y, wave_w, wave_h)); waveform->create_objects(); } else { waveform->reposition_window(wave_x, wave_y, wave_w, wave_h); waveform->clear_box(0, 0, wave_w, wave_h); } } else if(!(use_wave || use_wave_parade) && waveform) { delete waveform; waveform = 0; } if(use_vector) { if(!vectorscope) { add_subwindow(vectorscope = new ScopeVectorscope(this, vector_x, vector_y, vector_w, vector_h)); vectorscope->create_objects(); } else { vectorscope->reposition_window(vector_x, vector_y, vector_w, vector_h); vectorscope->clear_box(0, 0, vector_w, vector_h); } } else if(!use_vector && vectorscope) { delete vectorscope; vectorscope = 0; } if((use_hist || use_hist_parade)) { if(!histogram) { // printf("ScopeGUI::create_panels %d %d %d %d %d\n", __LINE__, hist_x, // hist_y, // hist_w, // hist_h); add_subwindow(histogram = new ScopeHistogram(this, hist_x, hist_y, hist_w, hist_h)); histogram->create_objects(); } else { histogram->reposition_window(hist_x, hist_y, hist_w, hist_h); histogram->clear_box(0, 0, hist_w, hist_h); } } else if(!(use_hist || use_hist_parade)) { delete histogram; histogram = 0; } allocate_bitmaps(); clear_points(0); draw_overlays(1, 1, 0); }
void particles_render::draw(const explosion &e) const { clear_points(); const float life_time = 5.0f; for (int i = 0; i < 2; ++i) { auto &rots = i == 0 ? e.m_shrapnel_rots : e.m_shrapnel2_rots; auto &tis = i == 0 ? e.m_shrapnel_alpha_tc_idx : e.m_shrapnel2_alpha_tc_idx; for (size_t j = 0; j < rots.size(); ++j) { auto &r = rots[j]; auto &ti = tis[j]; auto nt = e.m_time / life_time; const int tc_w_count = 16; const int tc_h_count = 2; const int tc_idx = (tc_w_count * tc_h_count + 1) * nt; float l = nya_math::min(e.m_time / 2.0f, 1.0f) * e.m_radius * 1.6f; auto ctc = tc(0, 512, 128, 128); ctc.x += ctc.z * (tc_idx % tc_w_count); ctc.y += ctc.w * (tc_idx / tc_w_count); auto atc = i == 0 ? tc(1920, 768, 64, 256) : tc(1664, 768, 128, 256); atc.x += atc.z * ti; auto c = color(1.0f, 1.0f, 1.0f, 1.0f); if (e.m_time > 1.0) c.w -= (e.m_time - 1.0); add_point(e.m_pos, l, ctc, true, atc, false, c, nya_math::vec2(0.0f, -0.9f), r, i == 0 ? 0.4f : 0.2f); } // } //fire for (size_t i = 0; i < e.m_fire_dirs.size(); ++i) { auto &d = e.m_fire_dirs[i]; auto &ti = e.m_fire_alpha_tc_idx[i]; auto nt = e.m_time / life_time; auto t = nya_math::min(e.m_time, 1.0f) + nt * 0.1f; auto p = e.m_pos + d * t * e.m_radius * 0.25f; auto r = e.m_radius * t * 0.75f; const int tc_w_count = 16; const int tc_h_count = 2; const int tc_idx = (tc_w_count * tc_h_count + 1) * nya_math::min(e.m_time / 2.0f, 1.0f); auto ctc = tc(0, 0, 128, 128); ctc.x += ctc.z * (tc_idx % tc_w_count); ctc.y += ctc.w * (tc_idx / tc_w_count); auto atc = tc(0, 1920, 128, 128); atc.x += atc.z * ti; auto c = color(hdr_coeff, hdr_coeff, hdr_coeff, 0.7f); if (e.m_time > 1.5) c.w -= (e.m_time - 1.5); add_point(p, r, ctc, false, atc, true, c, nya_math::vec2(), e.m_fire_rots[i]); } draw_points(); }