Posts

JavaScript: How to serialize maps of maps of maps of ...

Recently I had to serialize a map in JavaScript. On the Internet I found code similar to this: /* json-map.js */ export const replacer = (key, value) => {   if(value instanceof Map) {     return {       dataType: 'Map',       value: Array.from(value.entries()),     };   } else {     return value;   } } export const reviver = (key, value) => {   if(typeof value === 'object' && value !== null) {     if (value.dataType === 'Map') {       return new Map(value.value);     }   }   return value; }   Now I had the problem that this works for maps of arrays, but not for maps of maps. I pondered over it for a while and then came up with a recursive solution that does not only work for maps of maps, but also for maps of maps of maps, maps of maps of maps of maps, and so on: /* json-map.js */ export const replacer = (key, value) => {   if(value inst...

Demos for Dummies

Gargaj wrote a tutorial for newbies who want to code demos. It shows how to make a simple demo in less than 400 lines of C++ code. Link: https://gargaj.github.io/demos-for-dummies/

Diskmag Engine in C# / WPF

The repo https://github.com/adokhugi/diskmagenginewpf contains a simple but good diskmag engine made with C# / WPF.

Volko Hull - An Alternative to Convex Hull

When you have a point cloud and want to obtain the shape, you can use the convex hull or the alpha shape algorithm. In the computational geometry library I am using in my projects, CGAL, these algorithms are built-in, but they have a disadvantage: the points are not output in the correct order. I first tried to solve this problem by implementing a convex hull algorithm myself that outputs the points in the correct order, but this did not always help since it ignored concave corners. Therefore I wrote my own algorithm to replace it. My algorithm divides the rectangular area of the given cluster into four triangles and computes the points belonging to the outer border of each triangle. Thus it also includes concave corners. Imagine this to be the rectangle: -------- |\    /| | \ A/ | | C\/  | |  /\D | | /B \ | |/    \| -------- If it is a square, we can assume that its sides have a length of 2a. The coordinates of the mid point are always (0, 0). Th...

Tiny Code Christmas

Every day until christmas, the organizers of Lovebyte post a new video with tutorials on creating size-limited intros for fantasy consoles. The first video can be watched here . The official website is located here .

Sol's Graphics Tutorial

Sol writes on Pouet : About a couple decades back I wrote a graphics/game programming tutorial based on SDL 1.2. It used to be a major driver of traffic to my site, so one or two of you may have come across it. Time has passed and because of the old SDL (and old compiler suites) the tutorial has been more or less obsolete. I've started to revamp it - not completely rewrite, as it still uses much of the old material (as basics don't really change). I'm basing it on SDL3, so it should be relevant for a while again. Well, as relevant as plotting pixels goes. As of this writing the first 10 chapters are here: solhsa.com/gp2/index.html  Go check it out!

Mesh Voxelizer in C#

Author: Adok A mesh voxelizer is an algorithm that converts arbitrary three-dimensional objects, usually specified as polygons, into voxels (vector objects), that is a collection of small rectangular objects. Such an algorithm is sometimes needed for processing and visualizing 3D objects. Some theoretical background on how a mesh voxelizer works is provided by the paper "An Accurate Method for Voxelizing Polygon Meshes" . In this article I would like to present you my solution in C#. My solution uses a simple data structure called Vert that can be defined as:     public class Vert     {         public double x, y, z;     } Moreover, it uses Verts, which is a list of elements of the Vert data type: using Verts = System.Collections.Generic.List<Vert>; The core of the mesh voxelizer is the following method:         public bool IsVoxelOnFace(double[] vc, double L, double...