🙄Разминка для ума!
Треугольник Серпинского, интересная фигура которую построить достаточно просто.
Алгоритм такой:
1. создаём любые 3 точки на плоскости
2. из этих точек случайно выбираем любую, как начальную
3. случайно выбираем любую точку из этих же трёх точек как цель
4. перемещаемся в сторону цели на половину расстояния
5. повторяем бесконечно с пункта 3
Если сделать достаточно много итераций то вырисовывается интересная фигура. Треугольник, в который вписаны более мелкие треугольники. Это самый настоящий фрактал!
Я собрал пример построения такой фигуры на базе Qt.
🌎 Код можно посмотреть здесь.
С помощью paintEvent я рисую точки по озвученному алгоритму. Каждые 10 секунд либо по клику на виджете строится следующий треугольник.
Особенности примера:
🔸 Атрибут Qt.WA_OpaquePaintEvent позволяет сохранить то, что было нарисовано в прошлой итерации. Таким образом мы видим постепенное наполнение точек а не мелькающую одну точку.
🔸QTimer позволяет создавать отложенные вызовы один раз или с повторением через интервал.
🔸QColor.fromHsv() позволяет создать рандомный но предсказуемый цвет с помощью HSV схемы. Не слишком светлый и не слишком тёмный но всегда с разный. Рандомизации подвергается только смещение по цветовому кругу (Hue), яркость (Value) и насыщенность (Saturation) можно контролировать отдельно в своих пределах или оставить статичными. Обычный рандом цвета по RGB не даёт такой предсказуемый результат.
🔸 Каждый новый цикл с новым треугольником предварительно затемняет предыдущие через этот вызов
painter.fillRect(rec, QColor(0, 0, 0, 100))
То есть полупрозрачный цвет. Таким образом, чем старше треугольник, тем он темней.
Если сделать виджет фулскрин, то у нас получится некий ScreenSaver)))
🔸 Да, я знаю, что рисование в Qt не самый лучший способ сделать этот пример) Скорее всего самый НЕподходящий. Попробуйте сделать тоже самое но другими средствами.
#qt#source#tricks
#zig
TigerBeetle is a powerful, highly reliable database built specifically for financial transactions, designed to handle huge volumes with safety and speed. It ensures that once a transaction is confirmed, it cannot be lost, even if hardware fails or data gets corrupted. It uses advanced techniques like replication, checksums, and fault-tolerant consensus to keep data safe and available. TigerBeetle is much faster and more efficient than traditional databases, making it ideal for mission-critical financial systems that need to process thousands of transactions per second without errors or downtime. This means you get a secure, fast, and stable platform for managing money transfers and accounts reliably.
https://github.com/tigerbeetle/tigerbeetle
#zig
Ghostty is a fast, feature-rich terminal emulator that combines speed, native platform integration, and modern features without compromise. It supports multi-window, tabs, and split panes, with GPU-accelerated rendering using Metal on macOS and OpenGL on Linux for smooth performance. Ghostty is highly compatible with existing shells and software, making it a drop-in replacement. It offers rich theming, ligature support, and advanced developer features that enable more interactive command-line applications. Its native UI and cross-platform design provide a polished, efficient terminal experience that enhances productivity and usability for both users and developers.
https://github.com/ghostty-org/ghostty
🔥GEM ANNOUNCEMENT🔥
#ZIG/USDT:
Spot Signal (Exchange: Bybit, Bitget, MEXC, Gate.Io)
Technical Analysis:
#ZIG is pumping exactly from the support zone and now breaking a resistance trendline. We can see bullish momentum in it right now because technically this coin looks very strong. You people can buy and hold it now because bull run is going on and we can get good profits in it
📢BURN INCOMING📢
It's time to buyback & burn #ZIG🔥🔥!
8th Monthly #ZIG buyback & burn will take place on 6th January and It will be the biggest monthly burn to date!
#Zignaly#ZIG#Burn
#zig#3d_game#cubyz#game#procedural_generation#sandbox#sandbox_game#voxel#voxel_game#zig
Cubyz is a 3D voxel sandbox game like Minecraft, letting you explore unlimited height and depth with far view distances. It has a unique crafting system where you can try making any tool, and the game figures out what it is. It runs on Windows and Linux, written in the Zig programming language for better performance. You can easily download and run it or compile it yourself if you want the latest version. The game is open-source, so you can contribute by adding code, gameplay features, or textures following simple guidelines. This means you get a flexible, creative game with ongoing improvements and community support.
https://github.com/PixelGuys/Cubyz