Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCaml bug with out of the box coordinates #7174

Closed
vicuna opened this Issue Mar 11, 2016 · 5 comments

Comments

Projects
None yet
1 participant
@vicuna
Copy link
Collaborator

vicuna commented Mar 11, 2016

Original bug ID: 7174
Reporter: MonsieurPi
Status: resolved (set by @xavierleroy on 2017-02-17T15:13:18Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.3
Target version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: documentation

Bug description

I found a "bug" in the Graphics library in OCaml :

If you write

let () =
let open Graphics in
open_graph " 800x800";
draw_segments [|200,0,200,33567|];
ignore (read_key ())

No problem.

But if you write

let () =
let open Graphics in
open_graph " 800x800";
draw_segments [|200,0,200,33568|];
ignore (read_key ())

(I just changed 33567 to 33568.)

You have no line.

Strange, no ?

Well, actually, no. The coordinates are coded on 16 bits signed integers which corresponds to a range between [-32768, 32767] and if you add to it the size of my graph (here, 800) + 1 it goes out (which corresponds to 33568)

This behaviour is normal but the documentation of Graphics should add a remark about it because in the OCaml manual (http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual040.html) it's specified that "Drawing is clipped to the screen."

Regards

Steps to reproduce

let () =
let open Graphics in
open_graph " 800x800";
draw_segments [|200,0,200,33568|];
ignore (read_key ())

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Mar 11, 2016

Comment author: goswin

shouldn't Graphics be fixed to use ints? Physical displays are not even one magnitue below the limit for int16 and virtual displays can easily be larger than int16 allows.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Mar 12, 2016

Comment author: MonsieurPi

I'm not sure I understand what you're saying. From what I read, Graphics is implemented under the X11 windows system.

What you're saying is that Graphics should manipulate unsigned integers or the 64 bits integers of OCaml ?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Mar 14, 2016

Comment author: goswin

I'm saying draw_segments [|200,0,200,33568|]; should work. One might have a window that large soon.

Are you saying the problem is X11 window system using int16 and not ocaml?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Mar 14, 2016

Comment author: MonsieurPi

Yes, exactly. That's why I think it would be better to document it in the Graphics documentation since Graphics functions use int64 (or int32) and this can lead to errors hardly understandable.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Feb 17, 2017

Comment author: @xavierleroy

Brief mention added to documentation. In version 4.05.

@vicuna vicuna closed this Feb 17, 2017

@vicuna vicuna added this to the 4.05.0 milestone Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.