🙄Разминка для ума!
Треугольник Серпинского, интересная фигура которую построить достаточно просто.
Алгоритм такой:
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
#vlog
Forgot to share the vlog here! With exams approaching days are going even faster and tomorrow is already December!
While trying to study hard, I am also working on my skills and my side projects. Love college, love life, love my family and friends. And of course love you!
~ 🤓~
↬@jastm1🐰
#vlog
New week, new vlog🍎😁
Did u miss me? I was away during the weekends…
Courses are getting harder and it’s getting harder to film vlogs but I am trying to make them as good as possible 😬
~🐈~
↬@jastm1🌊
#vlog
✨ Another little glimpse into my day ✨
Yesterday was packed with challenges - from a dentist appointment to preparing for upcoming quizzes. It was long, it was busy, and yes, I ended the day completely exhausted. 💗
But here’s the thing: every busy day is also a step forward. Each challenge we push through is shaping us, teaching us resilience, and bringing us closer to our goals. 🎀
So if you’re also feeling tired from studying, working, or just managing life, remember, it’s all part of the journey. Keep going, because the effort you’re putting in today will turn into tomorrow’s growth. 🍵🤩
Let me know if you want more vlogs like this🤎
~🐈~
↬@jastm1🌊
#vlog
Yesterday was a very colorful, interesting, and tiring day. The first day of September turned out pretty productive! I woke up early and prepared for my classes (Algorithms, to be exact
😶). We had a very challenging Algorithms class — I could literally feel my brain frying 😀. Our professor is really funny though, with a Russian accent.
Then I had another class - a core course called Chance. Honestly, I’d call it “a chance for a good sleep.” We have a lovely French professor who’s over 70 and speaks very quietly and slowly
🥲. And since the class is at 2 p.m., you can imagine…
After that class, I was ready to go to my Jiu Jitsu training, but it got canceled. So instead, I helped out at the Student Fest, where all the clubs at our uni gathered to present themselves. Our Central Asian Student Association was there too, and it was so much fun! Everyone waited for somsa and chebureki... I got to meet many new freshmen, and they were super friendly. One of them even turned out to be subscribed to my channel - such an honor honestly
⭐.
So yeah, the day was so tiring it felt like Friday. My roommate and I couldn’t even wake up early today :)
~🐈~
↬@jastm1🌊
#vlog
I am back with another cute vlog 🥰
It was filmed like a week ago. Hope you will enjoy it.
These weeks are very busy and I am filming another long and funny vlog for you! Hopefully I will have time to edit it 🥲
#vlog
My daily routine at university. Everyday is the same :wake up -> eat ->study and that's on repeat.
Right now I am trying to learn and apply as much knowledge as I can, building the necessary foundation for the future internships (hopefully).
Also watching anime about pharmacy girl in ancient times, I LOVE IT 😊.
Yesterday I freaked out and had a good cry because of my cs assignment, but then managed to somehow finish it by 2 am. Now the most challenging part is left - DEBUGGING.
Alhamdullilah for such stability 🍵
~🍋~
↬@jastm1🌊