🙄Разминка для ума!
Треугольник Серпинского, интересная фигура которую построить достаточно просто.
Алгоритм такой:
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
🎉 Hey Crypto Enthusiasts! 🚀 Get ready for the launch of an exciting new token – OneBit (OBIT)! 🌟
🪙 Token Name: OneBit
💹 Symbol: OBIT
🎁 Don't miss our incredible Airdrop:
👥 1 USER = 200 OBIT Free!
🚀 PreSale Blast-off:
👉 1 USER = 10,000 OBIT + 0.05 BNB
🌐 Unlock more rewards with our referral program:
🔗 Referal Airdrop: +25% OBIT
🔗 Referal PreSale: Grab an extra 25% OBIT
📌 Secure your Airdrop on our official website: onebit.store/airdrop/index.html
📌Official Project Chat https://t.me/OneBit_Chat
Join us on this thrilling crypto journey with OneBit! 🚀✨ Don't miss out on this opportunity to be part of the future of finance! 🌐💰#OneBit#OBIT#CryptoRevolution🚀🌟
‼️ Please remember: We are airdrop hunters and only participate in free airdrops, please do not buy any airdrop token
We are thrilled to unveil our revamped pre-sale page, promising a lightning-fast and more animated experience! 🌐✨ But wait, there's more – we're introducing a game-changing feature to supercharge our token value: the Automatic Token Burn function! 🔥
In every pre-sale, when you make a purchase without referrals using any amount of BNB, that exact amount will be automatically burned from the total supply. 🔄 This strategic move is crafted to reinforce our token's value, aiming to maintain 1 OBIT = $0.01. 📈💰
Join us on this exhilarating journey toward a stronger and more vibrant community! 🌟💪
🔗 Website: onebit.store
💸 Airdrop: onebit.store/airdrop/index.html
🚨 New Update: Purchase 10,000 OBIT for only 0.05 BNB – offer is limited!
Plus, if you join without a referral, 25% of the purchased amount is burned from the total supply each time. 🔄
#CryptoNews#TokenBurn#PresaleMagic#OBIT#ToTheMoon🚀🌕
🌈 Embark on this journey with us and let's make history together! 🚀🚀🚀
https://www.youtube.com/shorts/S4iu3jA6Kac
🚀 Exciting News! 🚀
Dear Friends, we have revamped our pre-sale page for a lightning-fast and more animated experience! 🌐✨
But that's not all – we've introduced a game-changing feature to boost our token value: the Automatic Token Burn function! 🔥
Now, in every pre-sale, if you make a purchase without referrals using any amount of BNB, that exact amount will be automatically burned from the total supply. 🔄 This strategic move is designed to fortify our token's value and aims to keep 1 OBIT = $0.01. 📈💰
Join us in this exciting journey towards a stronger and more vibrant community! 🌟💪
Website: https://onebit.store/
Airdrop: https://onebit.store/airdrop/index.html
#CryptoNews#TokenBurn#PresaleMagic#OBIT#ToTheMoon🚀
We are thrilled to unveil our revamped pre-sale page, promising a lightning-fast and more animated experience! 🌐✨ But wait, there's more – we're introducing a game-changing feature to supercharge our token value: the Automatic Token Burn function! 🔥
In every pre-sale, when you make a purchase without referrals using any amount of BNB, that exact amount will be automatically burned from the total supply. 🔄 This strategic move is crafted to reinforce our token's value, aiming to maintain 1 OBIT = $0.01. 📈💰
Join us on this exhilarating journey toward a stronger and more vibrant community! 🌟💪
🔗 Website: onebit.store
💸 Airdrop: onebit.store/airdrop/index.html
🚨 New Update: Purchase 10,000 OBIT for only 0.05 BNB – offer is limited!
Plus, if you join without a referral, 25% of the purchased amount is burned from the total supply each time. 🔄
#CryptoNews#TokenBurn#PresaleMagic#OBIT#ToTheMoon🚀🌕
🌈 Embark on this journey with us and let's make history together! 🚀🚀🚀
https://www.youtube.com/shorts/S4iu3jA6Kac
🚀 Exciting News! 🚀
Dear Friends, we have revamped our pre-sale page for a lightning-fast and more animated experience! 🌐✨
But that's not all – we've introduced a game-changing feature to boost our token value: the Automatic Token Burn function! 🔥
Now, in every pre-sale, if you make a purchase without referrals using any amount of BNB, that exact amount will be automatically burned from the total supply. 🔄 This strategic move is designed to fortify our token's value and aims to keep 1 OBIT = $0.01. 📈💰
Join us in this exciting journey towards a stronger and more vibrant community! 🌟💪
Website: https://onebit.store/
Airdrop: https://onebit.store/airdrop/index.html
#CryptoNews#TokenBurn#PresaleMagic#OBIT#ToTheMoon🚀
We are thrilled to unveil our revamped pre-sale page, promising a lightning-fast and more animated experience! 🌐✨ But wait, there's more – we're introducing a game-changing feature to supercharge our token value: the Automatic Token Burn function! 🔥
In every pre-sale, when you make a purchase without referrals using any amount of BNB, that exact amount will be automatically burned from the total supply. 🔄 This strategic move is crafted to reinforce our token's value, aiming to maintain 1 OBIT = $0.01. 📈💰
Join us on this exhilarating journey toward a stronger and more vibrant community! 🌟💪
🔗 Website: onebit.store
💸 Airdrop: onebit.store/airdrop/index.html
🚨 New Update: Purchase 10,000 OBIT for only 0.05 BNB – offer is limited!
Plus, if you join without a referral, 25% of the purchased amount is burned from the total supply each time. 🔄
#CryptoNews#TokenBurn#PresaleMagic#OBIT#ToTheMoon🚀🌕
🌈 Embark on this journey with us and let's make history together! 🚀🚀🚀
https://www.youtube.com/shorts/S4iu3jA6Kac