Create colours module with colour definitions
This commit is contained in:
1 parent
7f29c5abbb
commit
f25e9a00a8
4 files changed
+25
-23
No files matched your search
+2
-15
@@ -2,27 +2,14 @@ mod common;
|
||||
|
||||
use ccvl::*;
|
||||
|
||||
const OUTER: image::SRGBA = image::SRGBA {
|
||||
r: 0.0,
|
||||
g: 1.0,
|
||||
b: 0.0,
|
||||
a: 1.0,
|
||||
};
|
||||
const INNER: image::SRGBA = image::SRGBA {
|
||||
r: 0.0,
|
||||
g: 0.0,
|
||||
b: 1.0,
|
||||
a: 1.0,
|
||||
};
|
||||
|
||||
fn draw(contour: &contour::Contour, img: &mut image::Image<image::SRGBA>) {
|
||||
let n = contour.vertices.len();
|
||||
for i in 0..n {
|
||||
let (x0, y0) = contour.vertices[i];
|
||||
let (x1, y1) = contour.vertices[(i + 1) % n];
|
||||
let colour = match contour.kind {
|
||||
contour::Kind::Outer => OUTER,
|
||||
contour::Kind::Inner => INNER,
|
||||
contour::Kind::Outer => colours::GREEN,
|
||||
contour::Kind::Inner => colours::BLUE,
|
||||
};
|
||||
draw::line(x0, y0, x1, y1, img, colour);
|
||||
}
|
||||
|
||||
+1
-8
@@ -2,20 +2,13 @@ mod common;
|
||||
|
||||
use ccvl::*;
|
||||
|
||||
const LINE: image::SRGBA = image::SRGBA {
|
||||
r: 1.0,
|
||||
g: 0.0,
|
||||
b: 0.0,
|
||||
a: 1.0,
|
||||
};
|
||||
|
||||
fn main() -> std::process::ExitCode {
|
||||
common::process_image(|mut img| {
|
||||
let greyscale = img.map(|p| image::Luminance::from(p));
|
||||
let edges = filter::canny(greyscale);
|
||||
for line in hough::lines(10.0, edges) {
|
||||
let ((x0, y0), (x1, y1)) = endpoints(line, img.extent);
|
||||
draw::line(x0, y0, x1, y1, &mut img, LINE);
|
||||
draw::line(x0, y0, x1, y1, &mut img, colours::RED);
|
||||
}
|
||||
img
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user