offset \ˈȯf-ˌset\ noun

a force or influence that makes an opposing force ineffective or less effective

GIMP and Leaflet

I needed to run the Leaflet library in JavaScript using a custom tileset for a small video game Vesna and I are working on. Leaflet's usage is pretty straightforward and the details on using it can be seen in the official documentation. The bare minimum is just to create a new map, assign it some custom tiles and point it to an element in the webpage (a div with an id "map"), for example like this:

var map ='map').setView([0.0, -0.0], 4);
L.tileLayer('./{z}/{x}/{y}.jpeg', {
    maxZoom: 4

You need to have a custom tileset in the proper location for this to work and the tileset needs to be created from an image. Every tile is placed in specific x and y coordinates on the 2d plane and the zoom level it is in. Preparing an image for this to work requires slicing it and copying the tiles to their respective locations. I decided to automate the process.

Considering I dabble with various 2D imaging applications and program in Python, GIMP seemed like the perfect choice here since it has a mechanism for creating plug-ins with Python. Some people will create the image in GIMP itself and just run the plug-in.

To start off, you want to have the biggest resolution of the initial image. Mine is a square image 4096 pixels in width and height. Using tiles of 256 pixels width and height it can achieve 4 zoom levels. When you go down, 3 is 2048, 2 is 1024, 1 is 512 and zoom level 0 is 256, just like the original tile size. Because it's exponential, it quickly drains the resources so you might want to go small.

The algorithm for this prepares the image for usage in the resolution required for the chosen zoom level just in case. The output is a JPEG quality image of 90%. After that, it goes from the set zoom level, makes the tiles for it in the specified x and y coordinates using loops, scales the original image down and loops again until it reaches zoom level 0.

This algorithm runs on my system for quite some time if the zoom level is big. I tried to parallelize it, but I had problems:

  1. You cannot pickle the image in GIMP and pass it to another process. It ends up being of "None" type and you cannot pass a reference to the worker with GIMP.
  2. If you skip GIMP altogether and use PIL or Pillow, you can parallelize it on multiple cores, but heavy disk I/O just kills it as far as I can see. Accessing an image from a temporary folder is slower in this case so I tried the third option.
  3. Pickling with PIL or Pillow works. However, pickling an object of 16384x16384 pixels and distributing it to workers brings my system to a crawl. It just exhausts the RAM completely, starts consuming the swap and exhausts it as well.

In the end, I just gave up and decided that half an hour (or less, if the image is not that big) is not so bad. I committed the resulting GIMP plug-in for exporting the Leaflet tiles in the repository on Bitbucket. You can contribute, if you'd like, but if not, installing it is not a problem. I tested it on Ubuntu, GIMP versions 2.8 and 2.9 for now. You need to put the .py file in your plug-ins directory, which is usually in your home folder, under .config/GIMP/2.9/plug-ins (if you're on 2.9 version). After copying the file, make sure it's executable and run GIMP. It will show in the filters section, under Leaflet submenu. Open an image first and activate the plug-in. Using it is a pretty straightforward process.


As you are already aware, I started the "a-sketch-a-day" 365 challenge on the 7th of September last year. I can now say that the challenge is completed and I didn't miss a day no matter how difficult it was sometimes. I can recall drawing at 4 AM because for one reason or another I happened to be awake still and there was that one more thing to do that day. There were good and bad moments and you can see the progress on my DeviantArt scraps page.

Here is one of the more representative works I did:


Considering I have to balance the everyday life commitments and the mandatory day job, I realize that it has to be enough. I cannot say that I've become proficient, but there's an improvement. After the challenge I can finally engage in creating some different artworks. I plan to continue more or less the same habit, but instead of a sketch per day, I'd try doing artwork that takes several days to complete. Proper lines and colors and all.

I am currently enrolled in the Painter club by Karen Bonaker and I follow the lessons almost immediately after they're posted but I still haven't put anything up for critique. I don't feel ready. Mostly because I don't experiment enough. My art priorities are not perfectly aligned with the course, but I still enjoy it.

People say that it takes about three weeks of doing something non-stop to make a habit of it. I think it's three weeks before you stop whining and obsessing over what you're doing. You just do it and don't stop. Even though I'm not as strict with myself anymore, like I was during the challenge, I retained the need, so to speak, to do something every day.

I made a list of things to work on after the challenge. Some of it is art, some of it is programming. I felt the need to have a structured approach to things. I will probably detail some of the things I've learned from the challenge, art-wise, in the future. For now, I'm focused on one GIMP plug-in I'm working on, but more about that in the next post.

No subject

I was thinking what to write about but lately I'm out of ideas. That's why this post comes now and it's basically a continuation of Rest (not REST). I'd rather not write about politics even though there's been a lot going on: the UBI referendum in Switzerland, Brexit and the EU, upcoming elections in the US, TTIP and TPP, coup in Brazil, ongoing situation in Syria, Russia and NATO, troubles in Europe, coup attempt in Turkey... So yes, I'm in the loop as much as I can be, just stirring clear of becoming too engaged in all the discussions.

Programming: Not much has been happening on this front. Vesna is still working on her portfolio. We finished a game development course on Udemy using Unity, but still haven't really plunged into it in practice. Other priorities have come up, but once we settle them we'll have free hands to do something about it. I keep my fingers crossed for this year. I'm really interested in 2d game development. Hopefully becoming proficient in digital art will yield interesting results in this department as well.

Art: Speaking of art, I've been doing things digitally for a month or two. Most of the work has been concentrated on getting familiar with Painter application, but I plan on using Krita alongside it. It's still one sketch per day and focused mostly on simple tools like pencils and pens. However, I enrolled a course on digital watercolor. So far it seems like it's pushing me in the right direction. I'm less afraid of tackling it which is good. The transition from drawing to painting is proving to be a difficult one. All my work comes down to a single sketchy painting a day.

Social concerns: Still the same old here. Aside from the Great Barrier Reef and biodiversity loss, air pollution in big cities has become a growing problem. In Croatia, Plomin C power plant faced public backlash in form of a petition that stopped the project from going further. The country wanted to build a coal power plant without any regards to the carbon footprint. One of the interesting things I've stumbled upon is the Scubo water drone. Seems like I'll have to brush up on my Arduino skills as well. Also, two new things came up as an interesting read. One is a scientific article about how a vegan diet can reduce the global mortality by 6-10% alongside reducing the greenhouse gas emissions by 29-70% by 2050. The other is a piece about how we must change our economic system because switching to clean energy is not enough. There is a number of other factors that influence the climate change that we must address.

Everything else: I've read The Spirit Level. It's shows how inequality correlates with social and health problems in a society. I.e. for "physical health, mental health, drug abuse, education, imprisonment, obesity, social mobility, trust and community life, violence, teenage pregnancies, and child well-being, outcomes are significantly worse in more unequal rich countries". Right now I'm back to fiction again. We were in Croatia briefly and I had to go back to traditional drawing during that period, which is my comfort zone. But I often get impatient so I'm just scribbling instead of thinking. This is a problem more often than not. Drawing/painting is like an exercise in patience. Also, my phone decided to finally die after a few attempts at fixing it. I ordered Fairphone2. It arrived today.

On drawing

It's been a while since I last assembled my thoughts regarding artwork. The 365 challenge is progressing nicely. The sketchbook I mentioned was filled and closed some weeks ago. I bought a new one and am over two thirds into the challenge now. I used that opportunity to get some felt tip pens so I started inking as well. I did a small motivational post about art on my deviantArt account. I try to upload images weekly in the scrapbook so there's a rhythm to it. Right now I'm trying to relax as much as I can so it becomes a second nature to me.

Reading up on the last art post, here's what I've learned so far. Go small and don't be afraid of doing thumbnails. It is good to create a composition this way. For detailed work, go big. It's easier to scale down digitally when needed. Drawing from observation is very different from drawing from imagination. Having something displayed in front of you makes it that much easier to depict it on paper. You still have to construct and you know by comparison if what you're drawing is wrong. When doing things from imagination, it's that much harder because you have to keep an image in your mind. The concentration is crucial in this because it helps you become more observant. Although, when you do get something of the imagined object on paper it becomes easier. There's something to hold on to. This leads me to the reference lines.

Aside from the vertical and horizontal lines on your paper of choice, it is possible to help yourself by drawing vertical and horizontal lines where needed. They help angle the subject and keep it vertical or tilt it if needed so when you do it it's on purpose and not accidentally skewed. Having those, and having the construction lines helps a lot.

People traverse through various stages of drawing. First is capturing the gesture. You don't have to be careful here and can be as messy as you want. The point is that you should be quick because in this way your mind doesn't get the time to overthink things. Only to feel. You can practice this. It gets something quickly on the paper so you can use it as a reference and it gives a natural energy to the result of the drawing process.

The second is constructing the object. Depending on whether imagination is used, which requires knowledge (anatomy for instance), or whether observation is used, which requires a keen eye, the object can be measured and constructed. Take your time here. Use construction lines. This is like building foundations. A good construction is the key to a successful image. Ignore all the other aspects like values, color, texture. Focus only on the shape and the form.

Taking your time is crucial because people usually focus on speed. Speed will come with experience. Even though you can set up the pomodoro technique alarms for yourself and work with constraints to achieve creativity, you don't want to stress yourself. You will want to enjoy the making of the art. This is what will keep you pushing. If you want to digress here, you can check out the Maslow's hierarchy of needs.

Back on track. If you are satisfied with the drawing, you are free to clean up the mess. Either with an eraser, with a new tracing paper or with a new layer if you're working digitally. You might get frustrated with erasing here because the paper cannot take erasing anymore or cannot absorb graphite. These are common problems that don't happen digitally. It has happened to me and here are some things that helped me. For one, you can do everything digitally. Or you can ignore that there's a mess and clean it up after scanning it. There are non-photo blue pencils that you can use and eliminate them after the scanning process as well. The most important thing that you must come to terms with is not taking it as a failure. You can always throw it away and start anew. It's not like you lost time. You learned something while doing it. Count your blessings.

In the line drawing, depending on the light source, the lines in shadow can be fat, and the ones in light thin or broken. You can further emphasize that in your work.

The method can diverge from now on. I tend not to bother myself with texture and color at this stage and instead focus only on values. The key is representing the object simply enough to get the mind of the observer to fill in the blanks. I lightly draw the outlines of the shapes that represent the values here. The values can be simple enough to be represented with three to five shades. You can ignore the transition and group together what you can. They say squint your eyes. This just bugged me to no end every time I encountered it. When I contract the lenses in my eyes it just puts the entire image out of focus and blurs it. You can also take a photo of the thing you're drawing. Convert it to grayscale, blur and posterize to get the shapes to appear.

You can start thinking about the texture information before doing the values. Metal has a high falloff so the values are separated more than on skin. If the material is smooth, maybe you want to blend and if it's not, maybe you just want to hatch or stipple. The last two techniques are mandatory when inking because ink is binary. It's either there or not. I find that the hatching with the lines following the form of the object works for me. The end result is not that flat.

When doing the texture you need to know two things. You can emphasize the texture on the contour and the texture is only a repeating pattern. You can put dots, lines, circles, hatch, i.e. do whatever pattern you think of and just repeat it. The texture, for example, scales of a fish, can just be hinted and you let the observer fill in the blanks. Draw a few of them and that's usually enough.

Depending on how your mind works, you can jump from technique to technique without thinking too much. Speaking of which, think in layers. It's easier to put the value in first and then texture over it. Also think of layers as the distance in depth between objects. The distant objects can be drawn thin, light and broken, but the close objects are using bolder strokes. Depending where the focus is, right?

Nowadays I tend to finish a sketch by using an inking pen over a pencil and I have to be careful in that part of work. That's why I allow myself to be messy with a pencil. Remember the binary thing? I have to use heavy texturing work where needed here. Of course, some things I fill in with black because I simplify it that way and it makes that distinct effect that the ink has. You can also go wild with the texture. When the ink is dry, I clean up with an eraser and all that I'm left with is the inked drawing.

With the detail work in the end you can make the things pop. The devil is in the details so make sure that you emphasize the things that matter and obscure the ones that are not important to the image. We tend to focus only on one thing. Don't make the background of the composition important because you'll distract the viewer's attention from the main object. Of course, if that is your intention, then ignore what I said. The rules can also be broken.

You can always fix the mistakes in the post processing on a PC. Keep that in mind, but don't use it as a crutch. In the following artsy posts, I'll probably talk about color if I manage to feel confident using it. Anyway, remember to have fun.

Solar Projector 2

In the wake of the announcement of Breakthrough Starshot where the humanity plans to scale the distance between our star system and the Alpha Centauri, we're also publishing the new Solar Projector. The majority of it is only a cosmetic makeover, but a new satellite source has been added. It is the DSCOVR, which is currently publishing data in the experimental phase.

Vesna played around with ES6 here, but the general concept is still the same: learn the fundamentals first and move on from there. I updated the back-end and created some bugs with it. They should be fixed now, but since there likely aren't many visitors coming to this site, things occasionally being broken should not be a big deal. As far as hobby projects go, this one might eventually be ready for other eyes as well, but we'll think about putting it out there more once we feel satisfied with it.

For the reference, this is the old version:


and this is the new version:


We still have some plans with it, but these should be implemented in the coming months with yet another new version.