Slightly faster version of value-of-values
This commit is contained in:
parent
313fcb3f3e
commit
be2204af7e
1 changed files with 4 additions and 7 deletions
|
|
@ -59,8 +59,8 @@ fn view(app: &App, model: &Model, frame: Frame) {
|
|||
|
||||
// extract colors from current rect
|
||||
let mut cols: Vec<Hsv> = Vec::new();
|
||||
for px_x in img_x1..img_x2 {
|
||||
for px_y in img_y1..img_y2 {
|
||||
for px_y in img_y1..img_y2 {
|
||||
for px_x in img_x1..img_x2 {
|
||||
let px = model.image.get_pixel(px_x, px_y);
|
||||
let col = rgb(
|
||||
px[0] as f32 / 255.0,
|
||||
|
|
@ -81,12 +81,9 @@ fn view(app: &App, model: &Model, frame: Frame) {
|
|||
});
|
||||
|
||||
// draw sorted colors
|
||||
for px_x in img_x1..img_x2 {
|
||||
for px_y in img_y1..img_y2 {
|
||||
let x = px_x - img_x1;
|
||||
let y = px_y - img_y1;
|
||||
for y in 0..(img_y2 - img_y1) {
|
||||
for x in 0..(img_x2 - img_x1) {
|
||||
let i = (x * (rect_size as u32) + y) as usize;
|
||||
|
||||
let pos_x = pos_x + (rect_size * (x as f32 / rect_size));
|
||||
let pos_y = pos_y + (rect_size * (y as f32 / rect_size));
|
||||
draw.rect()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue