Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write highlights over the rasterized image #547

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/algorithms/atomic_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ std::ostream& operator<<(std::ostream& out, const color_t& c) {
return out;
}

bool operator==(const color_t& a, const color_t& b) {
return a.c.r == b.c.r && a.c.g == b.c.g && a.c.b == b.c.b && a.c.a == b.c.a;
}

color_t lighten(const color_t& c, const double& f) {
return layer(c, COLOR_WHITE, f);
}
Expand Down
1 change: 1 addition & 0 deletions src/algorithms/atomic_image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ typedef union rgb_t {
} color_t;

std::ostream& operator<<(std::ostream& out, const color_t& c);
bool operator==(const color_t& a, const color_t& b);

color_t hash_color(const std::string& s);
color_t lighten(const color_t& c, const double& f);
Expand Down
20 changes: 18 additions & 2 deletions src/algorithms/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,18 @@ std::vector<uint8_t> rasterize(const std::vector<double> &X,
source_min_x, source_min_y);

auto range_itr = component_ranges.begin();
struct draw_target_t {
xy_d_t xy0;
xy_d_t xy1;
algorithms::color_t color;
};

for (auto& component : weak_components) {
auto& range = *range_itr++;
auto& x_off = range.x_offset;
auto& y_off = range.y_offset;
#pragma omp parallel for
std::vector<draw_target_t> highlights;
//#pragma omp parallel for
for (uint64_t i = 0; i < component.size(); ++i) {
const handle_t& handle = component[i];
uint64_t a = 2 * number_bool_packing::unpack_number(handle);
Expand Down Expand Up @@ -252,9 +259,18 @@ std::vector<uint8_t> rasterize(const std::vector<double> &X,
*/
const algorithms::color_t node_color = !node_id_to_color.empty() ? node_id_to_color[graph.get_id(handle)] : COLOR_BLACK;

wu_calc_wide_line(xy0, xy1, node_color, image, line_width);
// if gray or black color, otherwise save for later
if (node_color == COLOR_BLACK || node_color == COLOR_LIGHTGRAY) {
wu_calc_wide_line(xy0, xy1, node_color, image, line_width);
} else {
highlights.push_back({xy0, xy1, node_color});
}
}
}
// color highlights
for (auto& highlight : highlights) {
wu_calc_wide_line(highlight.xy0, highlight.xy1, highlight.color, image, line_width);
}
}

// todo, edges, paths, coverage, bins
Expand Down
Loading