-
Notifications
You must be signed in to change notification settings - Fork 66
Include VG in Toplevel and exercices #352
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(* This file is part of Learn-OCaml. | ||
* | ||
* Copyright (C) 2019 OCaml Software Foundation. | ||
* Copyright (C) 2016-2018 OCamlPro. | ||
* | ||
* Learn-OCaml is distributed under the terms of the MIT license. See the | ||
* included LICENSE file for details. *) | ||
|
||
|
||
(** [construct_image img] renders an image as a svg code string. This code is | ||
used to display the image in the toplevel, using the toplevel directive | ||
"#install_printer". | ||
|
||
The size isn't taken into account in this function because a pretty printer | ||
doesn't take one. *) | ||
let construct_image i = | ||
let coeff = 1.0 in | ||
let b = Buffer.create 2048 in | ||
let size = Gg.Size2.v (coeff *. 100.) (coeff *. 100.) in | ||
let view = Gg.Box2.v Gg.P2.o (Gg.Size2.v coeff coeff) in | ||
let r = Vg.Vgr.create (Vgr_svg.target ()) (`Buffer b) in | ||
ignore (Vg.Vgr.render r (`Image (size, view, i))); | ||
ignore (Vg.Vgr.render r `End); | ||
Buffer.contents b | ||
|
||
(* Prelude for pretty printers *) | ||
let prelude_pp = "let pp_svg _ i = construct_image i |> print_svg;;" | ||
|
||
|
||
(* List of pretty printers to deploy in toplevel *) | ||
let pp_list = [ | ||
"pp_svg"; | ||
] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.