2011-11-03Mixing HTML and TeX in a StyledTextCtrl in wxPythonI have written my very own editor with syntax highlighting to write these sketches. This is far less impressive than it might appear on a first glance: wxWidgets, and therefore also wxPython, provide access to the Scintilla library via the StyledTextCtrl element, and this element can display HTML source code and style the different elements in different colors. Scintilla provides “lexers” for different languages, parsers which are able to determine which fragments of a document are keywords, identifiers, string literals, numerical literals, operators, comments and so on, and tokens from different categories can be styled differently. So “writing my own editor” in fact just means “gluing together some standard pieces”. It looks like this: …
2011-10-23The girl version of the “On the population dynamics of “Puella Magi Madoka Magica”” essayI’m not completely content with the appearance of the preceding sketch, and so I decided to try to prettify it a bit. I replaced all the equations generated by mimetex as GIF images with texts I pipe through MathJax, so if you have Javascript disabled, you’ll see all equations as \(\LaTeX\) plaintext. Furthermore, I replaced all the screencaps I took from OpenOffice or Excel and replaced them with with pretty matplotlib plots; and I also re-did all the previous matplotlib plots. And I tried to enhance the layout of the page a bit, and added more stills from the series. So this is my second take, the content remains unchanged, but I attempted to make the appearance more fitting for a series about cute girls. …
2011-10-16On the population dynamics of “Puella Magi Madoka Magica”This sketch is devoted to the population dynamics of the fictional world depicted by the Japanese animated TV series “Puella Magi Madoka Magica”. As such, it is inevitable going to reveal at least one major plot point. So if you are planning to watch this show, I suggest that you postpone reading this sketch until you are done watching it. You have been warned: there will be spoilers. …
2011-05-10Why I won’t update Orbit Classic for Firefox 4I hesitated updating Firefox to version 4.0, since I feared it might break a lot of extensions I use. Well, it certainly broke my theme Orbit Classic. But now that I made the transition, I decided that I won’t maintain Orbit Classic any longer. With Firefox 4.0, I’m happy with the default theme – all the more since it’s possible to cram all the chrome tightly together, so there isn’t much left to style anyway. It’s the compactness of Google Chrome combined with the awesome extensibility and flexibility of Firefox. …
2011-05-04Cascading Drop-ShadowsIn chapter 4 of “Interferences”, I’m using several layers stacked on top of each other with cumulative drop shadows. Of course I have written a Python extension for Inkscape to generate such cascading shadows automatically. Let’s start with a simple example: five rounded rectangles stacked upon each other. …
2011-04-22Two-step text to path transformationIn the previous sketch, I presented an Inkscape extension which converted texts to paths, replacing duplicate paths with use elements. This extension did call Inkscape itself, requiring a somewhat dubious hack. It is possible to avoid this hack, although the alternative version (which I am going to present in this sketch) is slightly more roundabout: the altnernative extension needs to be called two times. …
2011-04-21Fonts, Texts, Paths and UsesUsing fancy fonts with SVG faces some pitfalls. One problem is that font foundries are not fond of seeing their font data exposed for everyone to fetch across the pond. Until recently, using commercial fonts on the web was next to impossible, and the support for fonts is still in its infancy, and usually requires some model where fonts are provided in a heavily encrypted and protected way, incompatible with SVG. It is hard to imagine any font foundry would allow their valuable fonts to be published as font formats compatible with SVG. It’s possible to circumvent this problem by sticking to free fonts. But we immediately run into the next problem: lacking SVG font support in many browsers. An obvious solution is to replace all textual data within a SVG file with paths. If a user agent can display SVG at all, it will be able to display path data, so that’s a fallback that will always work (if SVG works at all). Unfortunately, we loose the textual information. That’s bad for searching, it’s bad for indexing, it’s unfriendly towards disabled users, and it might cause problems down the road if we want to modify files later on. It’s therefore advisable to duplicate text elements and to put one copy into a hidden layer, while the other copy is transformed into path data. But there is another drawback: replacing text with paths increases the file size considerably. Part of this increase in size in unavoidable: after all, we are storing glyphs as paths, and this glyph data inevitably somehow must be transported to the user, whether it is in the form of an auxiliary OTF file or some additional paths increasing the size of the main SVG file. But another part of this increase in file size is perfectly avoidable. A font file contains the glyph definition for the letter, say, LATIN SMALL LETTER E, just once. A text converted to a group of paths may contain the corresponding data several times, one copy for each occurrence of the letter “e”. Even if we accept the necessity of the first occurrence of this data, all subsequent occurrences are superfluous. We can substantially compress our file if we replace all later occurrences of this letter with references to the path definition of the first occurrence, by replacing the subsequent path elements with use elements; or, using the terminology of Inkscape: by replacing them with linked clones. I have written an Inkscape extensions which does exactly this. …
2011-04-20Inkscape calling InkscapeThe capabilities of Inkscape can be extended with user scripts, but in a rather peculiar way: unlike other programs which allow user scripts, Inkscape doesn’t expose an API to a script environment. Instead, it pipes the content of the current SVG file to any arbitrary user program registered with an INX file, and this program is free to do with said file whatever it wants, after which it should spew the file back via stdout to Inkscape. This means that an Inkscape extension has the most amount of freedom imaginable in what it can do to the SVG file in question: it can do whatever a Turing machine can do, and transform the input in arbitrary and completely outlandish ways. On the other hand, the extension can’t access any of the internals of Inkscape and is completely on its own. Well, almost. Inkscape at least provides the ids of the currently selected objects as additional input options, and the file itself contains some hints about the current state of Inkscape (for example, which layer is currently active). But an extension can’t use some of Inkscape’s effects. An extension might call other extensions, but otherwise, all effects and methods and tricks and procedures it wants to use, it has to provide itself. Which is sometimes kind of annoying, since Inkscape ships with a lot of useful tools an extension might want to utilize. For example, an extension might want to split a path into its components as one step within a larger procedure. Such a splitting of a path into components isn’t too complicated: take the path data, scan for occurrences of "M" or "m", and split along them. But you also have to take into consideration that in the case of a lower case "m", the relative coordinates of the first vertex must be replaced with absolute coordinates, which means you have to scan the path data backwards until you reach an absolute coordinate, and compute your current position forward from there. Not terribly hard to do, but annoying enough if you know that somebody else already did it before. Or perhaps you want to transform a text into a path, as the extension does we’ll discuss in the following entry. That requires reading the appropriate font, transforming glyphs to paths, dealing with kerning and a lot of complicated and advanced stuff, and stuff somebody already solved in a completely satisfactory manner, since Inkscape itself already has a command to transform texts to paths. So it is desirable if we somehow could call Inkscape commands from within an Inkscape extension. I wrote a Python module which extends the Effect class of the standard inkex module in such a way that this is, indeed, possible. …
« previous page
(Page 1 of 2, totaling 11 entries)
next page »
| QuicksearchRecent Entries
Latest Skizzenblog Entry |