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

Add 2 modules #13665

Closed
wants to merge 1 commit into from
Closed

Add 2 modules #13665

wants to merge 1 commit into from

Conversation

juancarlospaco
Copy link
Collaborator

  • Add 2 new modules, xpm.nim and netpbm.nim.
  • Half the code is Tests approx, all functions are asserted.
  • Only uses system.nim, no imports, does not use std lib, easy to maintain.
  • runnableExamples with static: and doAssert.
  • Documentation with Examples and Links. changelog.md entry.
  • Works at compile-time and JavaScript.
  • All functions are func, except 1 that does the I/O.
  • Tiny func of 3 ~ 5 lines, simple code, simple API.
  • Functionality can be extended with sequtils by the user.
  • Examples render 6 small fractals at compile-time to mimic a real-world like usage.
  • Only adds ~300 lines where half are test, adding 5 image formats, so I think it worth it.

Random example use cases

  • Generate Icons of arbitrary sizes instead of bundling them in binaries and installers.
  • Generate patterns on client-side browser instead of transferring them over internet.
  • Render QR codes, Bar codes, Icons, visual reports, simple diagrams for documentation, etc.
  • Plot charts with data of any kind on any target.
  • Anything image related, good addition to SVG and HTML that std lib already can do.

Format

Image format is loss-less and human-readable, UTF-8 but fits ASCII,
is also valid C source code, can be embedded in C, supports millions of colors and transparency.

Links

Examples with Std Lib only

fractalito

fractalito_hexaflake

fractals

@krux02
Copy link
Contributor

krux02 commented Mar 16, 2020

  • You don't need var for ref types (unless you want to set the pointer itself). Also the var prefix binds stronger than |, so the ast for your arguments looks like this: (Infix (Infix (Ident "|") (VarTy (Ident "PBM")) (Ident "PGM"))), not as you might think(VarTy (Infix (Ident "|") (Ident "PBM") (Ident "PGM"))).
  • Using types composed with | makes the proc implicitly generic with code instantiation per type, even though the implementation is completely identical, no generic code instantiation needed, except for the $ and the writeFile proc. Please don't use generics for this module.
  • Please don't use ref types if you don't need to, and I don't see the need for ref types here.
  • Please don't use seq[seq[byte]] for image data. This has too much allocation overhead. Use one flat seq[byte] and compute the indices. This is also the format that for example OpenGL needs when you pass image data to it.

I Didn't even start yet to look into the procedures and question if they are worth to be added to the standard library. Why don't you make this just a nimble package?

Copy link
Contributor

@dom96 dom96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this belongs to the stdlib.

@dom96 dom96 closed this Mar 16, 2020
@timotheecour timotheecour mentioned this pull request Mar 30, 2020
1 task
@juancarlospaco juancarlospaco deleted the image-rendering branch April 1, 2020 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants