-
Notifications
You must be signed in to change notification settings - Fork 710
[css-syntax][css-values] Add IEEE 754 float hex format SVG/CSS values #4564
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
Comments
Not sure you'll get much agreement on this, but I would like to see your example SVG files if possible to better understand the problem. Github won't accept SVG as attachments in the comments, but you could upload them to https://gist.github.com/ |
(I editted the original comment to properly put the example in a code block; it was being interpreted as (invalid) markup and not being displayed.) |
So it looks like you're just asking for a new way to write numbers, right? You want to write out numbers as the literal bit pattern of a 32-bit float. I feel pretty confident that we'll reject this without a very good reason otherwise.
You mention "high precision line screen/half tone for print for use SVG replace PDF" - what do you mean by this? Why do you need a 32-bit float syntax specifically to achieve this? |
To keep the discussion in one place, here's my reply from when this request was originally posted to the www-svg mailing list. Key points (beyond suggesting filing it here):
|
Small line screen SVG image I create from PNG file. I assume one SVG unit is 1/96 inch (1/37.8 cm) this line screen is 192 lines/inch (75.6 lines/cm), high resolution line screen. Format for float decimal number have 5 digit after decimal point. I can't load this use https://gist.github.com/ because "add file" button not work. I put image in MediaFire: |
I've taken the liberty of putting your image at https://gist.github.com/faceless2/042847e3675648dfbe4fe5a81000de02 - unchanged, although I added the SVG namespace. Mediafire tried to give me some dubious binary as well as your file. I see where you're going with this. Obviously the SVG is machine generated, it strikes me that scaling every dimension up by 1000 and set "viewBox="0 0 89000 95000" would avoid any issues you're having with float resolution. If you're converting these to/from PDF, be aware that the maximum recommended resolution of numbers in PDF is roughly 5 decimal places in PDF 1.4, roughly IEEE754 single precision in ISO 32000-1, slightly larger than IEEE754 single precision in PDF/A (which I am still very sore about) and essentially unlimited but IEEE754 single or double recommended in ISO 32000-2. However values are not stored in IEEE754 in PDF, they're serialised as text. My point is you're not going to get any more accuracy when converting to/from PDF with this suggestion. I would not expect more than 5 d.p. of resolution for any numbers stored in PDF, and if I wanted to generate a halftone pattern like yours, I would scale up by a factor of 1000 or so in both formats. |
I convert from PNG to SVG direct by program I create. I want new choice, use SVG replace PDF. When create that SVG picture, I change my program use 5 digits decimal precision. That seem work good. Multiply by 1000 and use viewBox is good idea. I will try it. If no more problem I will close this If multiply by 1000, should I remove three digits after decimal point for keep file size same? |
Here is same SVG image file with your scale 1000 idea and viewBox. It still have 5 digit precision after decimal point and file is only ≈15% larger. Please add it to https://gist.github.com/ (I think it not work because my browser is too old and I can't upgrade). Sorry about garbage file form MediaFire. If any other person have this problem in future, they can read this discussion. |
I have seen this sort of issue come up a few times; sometimes people are unaware of resolution limits, or they are but don't see how to maximize them. I know that SVG Tiny 1.2 had a precision requirement and SVG2 is moving towards deliberately not specifying one, but perhaps some authoring advice could be given. For example, consider
These progressively squander the available resolution of any implementation |
Importantly, the precision used by the underlying renderer implementation has nothing to do with the syntax used to input the number. Since the request is about implementation precision, not about an actual number input format, I'm gonna consider this issue properly closed. @SieuDoTia can you confirm this is okay with you? If you're having issues with browser precision, please file bugs on those browsers asking them to increase their internal precision. They've got their own reasons for the choices they've made, but might be amenable to changing. |
Goal is use SVG for printing line screen, print on paper, replace PDF. My software accept PNG image than convert it convert become 4 SVG files, one file for each printing plate: C Y M K. Software must save line screen use decimal format in SVG. Next stage software read SVG file and rasterize them for printer (if you can recommend good and modern file format for 1 bit raster image please tell me). I think about lose precision when convert IEEE float become decimal when save SVG file, then read decimal number and convert back to IEEE float format in rasterizer. But after discussion here with @faceless and his method, my experiments with 5 decimal digits after decimal point and experiments @faceless's method, and I remember ink flow paper on paper, I not really need IEEE float number in SVG file. Only Advantage of IEEE float number I suggest (0x--------) it is always 10 characters, file size not change if use @faceless's method. Use decimal numbers file size increase about 12% to 15%. Disadvantage is > 99.9% SVG users not understand IEEE float number and make standard more complex. That is why I close this idea. Thanks for every person's help! You guys very fast! |
Please add IEEE 754 float hex format SVG/CSS values. Need hex format for create high precision line screen/half tone for print for use SVG replace PDF.
• Only need single precision float (32 bit float IEEE 754)
• use format "0x--------" from C, no confuse with "#---" or "#------" hex use for color
• format need 10 characters maximum, hex number shorter than decimal number for same precision, smaller file size
• big endian (more easy for human read it)
• also float format for color important for high precision/color control in print industry
Example SVG file here use big endian IEEE float format for draw grey circle with radius 100 at (50; 50), fill opacity 1.0 (color here):
Example SVG file here use big endian IEEE float hex format for draw grey (50%) circle with radius 100 at (50; 50), fill opacity 1.0:
The text was updated successfully, but these errors were encountered: