Is there a bug in graphics?

Hi !
I’m a newbie in ocaml.
I tried to use graphics.

plot 0 0 plots a pixel in 0 0 as expected.

But fill_rect 0 0 10 10 fills a square starting at 0 1 instead of 0 0 !?

I couldn’t imagine such a bug could remain in ocaml, so I thought I was doing something wrong, but a friend of mine got exactly the same pb !

Could someone please explain to me what’s going on ?

Thanks in advance.

Not what I observe with graphics v5.1.2
What version are you using, and how are you testing ?

Which OS are you using it on?

Thanks for your responses.
I’m using Windows 10.
I don’t know how to get Graphics’ version, but I see that graphics.cma file was last modified at 2015-12-09.
I test with these commands :
#load “graphics.cma” ;;
open Graphics ;;
open_graph " 1200x800" ;;

and then plot or fill_rect

The Graphics library was removed from OCaml in 4.09, and it became a normal package in opam, with its version bumped to 5.0.0. 5.1.2 is the current released version.

However, the fact you’re starting graphics with #load "graphics.cma" says you’re (probably) using OCaml 4.08 or older, in which case the version of graphics is the same as the version of OCaml.

All of which is by-the-by…

That’s a very kind way to approach it, but there is indeed a bug in the Windows implementation of Graphics. :slightly_smiling_face:

fill_rect is implemented using FillRect which states that it doesn’t include the right and bottom edge, so we should be increasing the width and height passed to it to compensate for that. Would you be able to open an issue on ocaml/graphics, please?

1 Like

Thanks for your quick answer.
Issue opened on GitHub.