https://nibblestew.blogspot.com/2023/09/circles-do-not-exist.html Nibble Stew A gathering of development thoughts of Jussi Pakkanen. Some of you may know him as the creator of the Meson build system. jpakkane at gmail dot com Tuesday, September 19, 2023 Circles do not exist Many logos, drawings and other graphical designs have the following shape in it. What is this shape? [circle] If you thought: "Ah-ha! I'm smart and read the title of this blog post so I know that this is most definitely not a circle." Well it is. Specifically it is a raster image of a circle that I created with the Gimp just for this use. However almost every "circle" you can see in printed media (and most purely digital ones) are not, in fact, circles. Why is this? Since roughly the mid 80s all "high quality" print jobs have been done either in PostScript or, nowadays almost exclusively, in PDF. They use the same basic drawing model, which does not have a primitive for circles (or circle arcs). The only primitives they have are straight line segments, rectangles and Bezier curves. None of these can be used to express a circle accurately. You can only do an approximation of a circle but it is always slightly eccentric. The only way to create a proper circle is to have a raster image like the one above. Does this matter in the real world? For printing probably not. Almost nobody can tell the difference between a real circle and one that has been approximated with a Bezier curve with just four points. Furthermore, the human vision system is a bit weird and perfect circles look vertically elongated. You have to make them non-circular for people to consider them properly circular. But suppose you want to use one of these things: [797] This is a laser cutter that takes its "print jobs" as a PDF file and uses its vector drawing commands to drive the cutting head. This means that it is impossible to use it to print a wheel. You'd need to attach the output to a lathe and sand it down to be round so it actually functions as a wheel rather than as a vibration source. Again one might ask whether this has any practical impact. For this case, again, probably not. But did you know that one of the cases PDF is being considered (and, based on Internet rumors, is already being used) is as an interchange format for CAD drawings? Now it suddenly starts mattering. If you have any component where getting a really accurate circle shape is vital (like pistons and their holes), suddenly all your components are slightly misshaped. Which would not be fun. Extra bonus information Even though it is impossible to construct a path that is perfectly circular, PDF does provide a way to draw a filled circle. Here is the relevant snippet from the PDF 2.0 spec, subsection 8.5.3.2: If a subpath is degenerate (consists of a single-point closed path or of two or more points at the same coordinates), the S operator shall paint it only if round line caps have been specified, producing a filled circle centred at the single point. Who is willing to put money on the line that every PDF rendering implementation actually uses circles rather than doing the simple thing of approximating it with Beziers? Posted by Jussi at 3:57 PM # Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest No comments: Post a Comment Older Post Home Subscribe to: Post Comments (Atom) About Me Jussi View my complete profile Blog Archive * V 2023 (32) + V September (3) o Circles do not exist o A logo for CapyPDF o CapyPDF 0.5 is out + > August (1) + > July (3) + > June (4) + > May (4) + > April (4) + > March (6) + > February (5) + > January (2) * > 2022 (34) + > December (4) + > November (3) + > October (2) + > September (4) + > August (2) + > July (3) + > June (2) + > May (2) + > April (4) + > February (5) + > January (3) * > 2021 (29) + > December (1) + > November (1) + > October (1) + > September (2) + > August (1) + > July (5) + > June (3) + > May (5) + > April (2) + > March (4) + > February (3) + > January (1) * > 2020 (42) + > December (1) + > November (5) + > October (5) + > September (2) + > August (4) + > July (5) + > June (2) + > May (4) + > April (3) + > March (4) + > February (5) + > January (2) * > 2019 (27) + > December (4) + > November (3) + > October (1) + > September (2) + > August (3) + > July (2) + > June (2) + > May (3) + > April (1) + > February (6) * > 2018 (24) + > November (4) + > October (1) + > September (1) + > August (3) + > July (3) + > June (1) + > April (3) + > March (4) + > February (4) * > 2017 (35) + > December (4) + > November (1) + > September (1) + > August (3) + > July (3) + > June (3) + > May (5) + > April (4) + > March (3) + > February (2) + > January (6) * > 2016 (20) + > December (4) + > November (2) + > October (1) + > September (2) + > August (1) + > July (1) + > June (2) + > May (2) + > April (4) + > March (1) * > 2015 (19) + > December (2) + > November (3) + > October (3) + > September (2) + > August (3) + > July (5) + > June (1) Simple theme. Powered by Blogger.