# subpixel

Published articles for subpixel.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Subpixel GUI

DevFeed: [Subpixel GUI](<https://devfeed.tech/articles/subpixel-gui-22384.md>)

Original publisher: [Read original article](<https://www.red-lang.org/2023/08/subpixel-gui.html>)

Author: Nenad Rakocevic (noreply@blogger.com)

Published: 2023-08-09T13:32:00Z

Content type: article

Language: en

Sources: [Red](<https://devfeed.tech/sources/red.md>)

Topics: [Red](<https://devfeed.tech/topics/red.md>), [GUI](<https://devfeed.tech/topics/gui.md>), [floating-point](<https://devfeed.tech/topics/floating-point.md>), [API](<https://devfeed.tech/topics/api.md>), [test](<https://devfeed.tech/topics/test.md>)

Tags: [3d](<https://devfeed.tech/tags/3d.md>), [4k](<https://devfeed.tech/tags/4k.md>), [components](<https://devfeed.tech/tags/components.md>), [floating-point](<https://devfeed.tech/tags/floating-point.md>), [gui](<https://devfeed.tech/tags/gui.md>), [pairs](<https://devfeed.tech/tags/pairs.md>), [points](<https://devfeed.tech/tags/points.md>), [precision](<https://devfeed.tech/tags/precision.md>), [scale](<https://devfeed.tech/tags/scale.md>), [subpixel](<https://devfeed.tech/tags/subpixel.md>)

### AI overview

The article explains how Red/View addressed a GUI dragging glitch caused by converting integer coordinates to floating-point values on displays using scaling above 100%. It introduces point2D! and point3D! datatypes to represent decimal positions and sizes.

### Source excerpt

Maybe you didn't notice, but Red/View, our GUI engine, has subpixel precision from the beginning! Unfortunately, that level of precision was not directly accessible to end users, until now. Actually, it would be more accurate to say that we had subpixel resolution only so far. The guilty part is the pair! datatype being limited to integer components only, while subpixel precison requires decimal numbers. So we have recently introduced new datatypes to cope with that. What urged us to make those changes now was a very peculiar visual glitch caused by that dissonance. That glitch happens during face dragging operations. Here is an example using our View test script: As you can see, on some positions, the face starts shaking while the mouse cursor remains still. This affects any type of face. The shaking is about ±2 pixels. It is caused by the difference in precision between the /offset facet expressed in integer numbers and the backend API, which only deals with floating point numbers. The accumulated error when converting integer->float->integer gives a 2 pixels difference. Such error happens on displays where the scaling factor is different from 100%. With the rise of 2K, 3K and 4K displays, a scaling factor > 100% has become the norm, making this glitch more frequent. You might think that this is not a big issue until you start building custom scrollbars and see your entire scrolled content shaking massively... New point datatypes In order to provide decimal positions and sizes for View faces, extending the existing pair! datatype was considered, though, the pair syntax can hardly scale up for such needs: 2343.122x54239.44 2343.122x54239.44x6309.332 2343.122x54239.44x6309.332x442.3321 2.33487e9x54239.44 2.33487e9x54239.44x9.83242e17 2.33487e9x54239.44x9.83242e17x5223.112 1.#infx1.#infx1.#inf As you can notice there, it quickly becomes difficult to read and identify the individual components. So we opted for adding a new literal form (hence a new datatype) that matc

## Animated line drawings with OpenCV

DevFeed: [Animated line drawings with OpenCV](<https://devfeed.tech/articles/animated-line-drawings-with-opencv-21653.md>)

Original publisher: [Read original article](<https://www.windytan.com/2017/12/animated-line-drawings-with-opencv.html>)

Author: Oona Räisänen (noreply@blogger.com)

Published: 2017-12-30T12:15:00Z

Content type: tutorial

Language: en

Sources: [Oona Räisänen](<https://devfeed.tech/sources/oona-raisanen.md>)

Topics: [OpenCV](<https://devfeed.tech/topics/opencv.md>), [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Computer vision](<https://devfeed.tech/topics/computer-vision.md>), [CMake](<https://devfeed.tech/topics/cmake.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>)

Tags: [art](<https://devfeed.tech/tags/art.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [canvas](<https://devfeed.tech/tags/canvas.md>), [cmake](<https://devfeed.tech/tags/cmake.md>), [compiler-flags](<https://devfeed.tech/tags/compiler-flags.md>), [computer-vision](<https://devfeed.tech/tags/computer-vision.md>), [gaussian](<https://devfeed.tech/tags/gaussian.md>), [graphics](<https://devfeed.tech/tags/graphics.md>), [gui](<https://devfeed.tech/tags/gui.md>), [make](<https://devfeed.tech/tags/make.md>), [music](<https://devfeed.tech/tags/music.md>), [plotting](<https://devfeed.tech/tags/plotting.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rgb](<https://devfeed.tech/tags/rgb.md>), [rotation](<https://devfeed.tech/tags/rotation.md>), [subpixel](<https://devfeed.tech/tags/subpixel.md>), [terminal](<https://devfeed.tech/tags/terminal.md>), [vector](<https://devfeed.tech/tags/vector.md>), [video](<https://devfeed.tech/tags/video.md>)

### AI overview

This tutorial shows how to use OpenCV and C++ to create pixel-level animated graphics and save them as video. It covers project setup with CMake, drawing rotating concentric rings on an RGB canvas, subpixel antialiasing, and a Gaussian blur glow effect.

### Source excerpt

OpenCV is a pretty versatile C++ computer vision library. Because I use it every day it has also become my go-to tool for creating simple animations at pixel level, for fun, and saving them as video files. This is not one of its core functions but happens to be possible using its GUI drawing tools. Below we'll take a look at some video art I wrote for a music project. It goes a bit further than just line drawings but the rest is pretty much just flavouring. As you'll see, creating images in OpenCV has a lot in common with how you would work with layers and filters in an image editor like GIMP or Photoshop. Setting it up It doesn't take a lot of boilerplate to initialize an OpenCV project. Here's my minimal CMakeLists.txt: cmake_minimum_required (VERSION 2.8) project (marmalade) find_package (OpenCV REQUIRED) add_executable (marmalade marmalade.cc) target_link_libraries (marmalade ${OpenCV_LIBS}) I also like to set compiler flags to enforce the C++11 standard, but this is not necessary. In the main .cc file I have: #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" Now you can build the project by just typing cmake . && make in the terminal. Basic shapes First, we'll need an empty canvas. It will be a matrix (cv::Mat) with three unsigned char channels for RGB at Full HD resolution: const cv::Size video_size(1920, 1080); cv::Mat mat_frame = cv::Mat::zeros(video_size, CV_8UC3); This will also initialize everything to zero, i.e. black. Now we can draw our graphics! I had an initial idea of an endless cascade of concentric rings each rotating at a different speed. There might be color and brightness variations as well but otherwise it would stay static the whole time. You can't see a circle's rotation around its center, so we'll add some features to them as well, maybe some kind of bars or spokes. A simplified render method for a ring would look like this: void Ring::RenderTo(cv::Mat& mat_output) const { cv::circle(mat_output, 8 * center_, 8 *