Comments (2)
Doesn't look like it's implemented (really should be though).
Possible workarounds include:
- A bunch of parallel line segments really close together
- A polygon
https://docs.rs/imageproc/latest/imageproc/drawing/fn.draw_polygon.html
https://docs.rs/imageproc/latest/imageproc/drawing/fn.draw_line_segment.html
https://docs.rs/imageproc/latest/imageproc/drawing/fn.draw_antialiased_line_segment.html
from imageproc.
I agree that it is something that I would expect from a shape drawing function. It is an option in most tools, programmatic or GUIs.
I could try submitting a PR for it, but what would be the API? Would it be adding new functions suffixed by _with_thickness
, or adding a parameter to the currently available functions (i.e. a breaking change)?
What about the offset of the thickness, should it always be a on a single side of the shape? If yes which side? Should it be on both side? If yes what side should thicker when the thickness
is an odd number?
Assuming the addition of new functions suffixed by _with_thickness
, with a one sided offset, a naive implementation for the hollow rectangle would look something like this
fn draw_hollow_rect_with_thichness<I>(
image: &I,
rect: Rect,
color: I::Pixel,
thickness: u16,
) -> Image<I::Pixel>
where
I: GenericImage,
{
let rect_x = rect.left();
let rect_y = rect.top();
let rect_width = rect.width();
let rect_height = rect.height();
let mut image_with_rectangle = drawing::draw_hollow_rect(image, rect, color);
for offset in 0..thickness {
let thickness_rect = Rect::at(rect_x - i32::from(offset), rect_y - i32::from(offset))
.of_size(
rect_width + 2 * u32::from(offset),
rect_height + 2 * u32::from(offset),
);
drawing::draw_hollow_rect_mut(&mut image_with_rectangle, thickness_rect, color);
}
image_with_rectangle
}
WDYT?
from imageproc.
Related Issues (20)
- Try using doc_auto_cfg to automate addition of docrs attributes
- Rename `imageproc::map::map_colors()` to `map_pixels()` HOT 2
- Another doc-macro for parallel variations of functions?
- `Rect` refactors HOT 2
- Add filter benchmarks for kernels larger than 3x3
- Add hardcoded filter3x3 function to benchmark current generic filter function against HOT 19
- Switch `imageproc::Rect` to `image::Rect` HOT 3
- `Laplacian` from `master` is wrong HOT 4
- Check for any functions missing tests
- Use `Kernel` by `ref` HOT 2
- Document release process
- Agree a sensible API for filtering so we can reduce the risk of frequent breaking changes to signatures HOT 3
- Fix filter performance vs simple hardcoded implementation
- Add Tags for all previous releases where possible HOT 2
- Decide module layout for new imageops functions HOT 1
- how encode drawed image to [u8] ? HOT 6
- Rounded corners on rectangles and images HOT 4
- Projection matrix for rotation is weird
- Add `#[must_use]` to all non-mut image processing functions
- Broken links in docs.rs documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imageproc.