🙄Разминка для ума!
Треугольник Серпинского, интересная фигура которую построить достаточно просто.
Алгоритм такой:
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
Live: Dazzling nightscape at Shanghai's Yangpu Riverside
As APEC's host again after a 12-year interval, China is holding the Second Senior Officials' Meeting and related #APEC meetings in Shanghai. As night falls, the Yangpu Riverside in Shanghai comes alive with dazzling lights. The shimmering river reflects rows of towering skyscrapers, blending waterfront tranquility with the bustling glamour of a global metropolis. Bright neon lights glimmer along the bank, and gentle river breezes brush past the promenade, painting a picture of Shanghai's modern prosperity and timeless elegance.
via CGTN
#APEC 2024 : les point clés de la dernière journée du sommet
Le sommet de l'APEC s’achève par une ultime réunion dans la capitale du #Pérou. Une déclaration finale doit être adoptée à l'issue du sommet. Les détails avec notre envoyé spécial sur place, Igor Kourachenko.
RT en français • Osez questionner !
#APEC 2024 : les points clés de la deuxième journée du sommet
La deuxième journée du sommet de l’APEC a commencé au #Pérou. Plus de détails avec notre envoyé spécial Igor Kourachenko, qui est sur place.
RT en français • Osez questionner !
🌐APEC Ministers Commit to Trusted AI and Inclusive Digital Growth
APEC digital and AI ministers convened for the first time in Incheon, Republic of Korea, issuing a joint statement that redefines regional priorities for AI governance. The meeting underscored a united commitment to responsible digital transformation and the development of trusted AI systems aligned with economic and societal needs.
The ministers identified three focal points: accelerating AI innovation to solve socio-economic challenges, expanding equitable digital connectivity, and building a secure, transparent AI ecosystem. Korea’s initiative to launch a dedicated APEC AI program by the end of 2025 was met with strong support, positioning the region to lead on practical, multilateral AI governance.
#AIandLaw#APEC#AIRegulation#AsiaPacificAI
🎙 Foreign Minister Sergey Lavrov’s video address to the 9th international conference "Russia and China: Cooperation in a New Era" (May 30, 2024)
💬 I am delighted to welcome the organisers of and participants in the 9th international conference "Russia and China: Cooperation in a New Era".
Most recently, Russia's President Vladimir Putin paid a state visit to China, which definitely became the centerpiece of bilateral exchanges this year. <...>
🇷🇺🇨🇳 The bond of comprehensive partnership and strategic cooperation between Russia and China has grown unprecedentedly strong thanks to the personal efforts of both heads of state. The Beijing summit sealed the two countries’ firm commitment to further deepen and expand it. This commitment was documented in the two leaders’ joint final statement.
This year, Russia and China celebrate 75 years of diplomatic relations. We mark this significant anniversary with achieving a new quality of relations – today, Russia and China view each other as priority partners and invariably adhere to the principles of mutually respectful, equal and trustful cooperation. We support each other with regard to key issues affecting the respective fundamental interests.
<...>
Strategic coordination in the international arena remains a key component of the Russian-Chinese partnership amid the growing international tensions. Our foreign policy tandem, held together by a broad commonality of interests as well as coinciding or similar approaches to key issues on the present-day agenda, plays a major stabilising role in global affairs.
☝️ The two countries are strengthening cooperation on multilateral platforms, primarily the Unite Nations and the UN Security Council, as well as #BRICS, #SCO, #G20, and #APEC.
<...>
The Russian-Chinese strategic tandem is gaining status, and this opens up new horizons for us in terms of stronger sovereignty, economic growth, and prosperity of both countries.
Read in full