nlfiedler / magick-rust

Rust bindings for ImageMagick
https://crates.io/crates/magick_rust
Apache License 2.0
254 stars 68 forks source link

How can I use drawing functions? #69

Open TonalidadeHidrica opened 4 years ago

TonalidadeHidrica commented 4 years ago

What is the equivalent functions of --draw , --fill or --stroke commands and so on? I looked up the source code but didn't understand how can I use it.

nlfiedler commented 4 years ago

I did not add the functions, and I have not tried using them, but there are whole bunch defined (using macros) in src/wand/drawing.rs that might be what you are looking for. These map directly to functions within MagickWand that have similar names. Sorry there is no example to speak of, but if you are familiar with the MagickWand API, then it should be reasonably straightforward to use the magick-rust API.

TonalidadeHidrica commented 4 years ago

Thank you for your reply. After I posted this I looked up by myself and found a MagicWand example in C that draws shapes. Seems that I can use set_fill_color and set_stroke_color, which correspond to DrawSetFillColor and DrawSetStrokeColor respectively. However I couldn't find how to draw a rectangle, since there were no binding defined in drawing.rs. The corresponding function seems to be DrawRectangle, which I couldn't find this string in the source code at all. Maybe I should make an unsafe call to this function, or make a safe wrapper by myself?

nlfiedler commented 4 years ago

For now, I would say write your own unsafe call and if that proves to work, paste a code snippet here and we can try to work it into this library. I imagine the best place for it would be in wand/magick.rs as another wrapper function on the MagickWand type.