🙄Разминка для ума!
Треугольник Серпинского, интересная фигура которую построить достаточно просто.
Алгоритм такой:
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
📰New UI for Calls
The only change that can be seen in the first release of the 10.5.0 beta version for Android is the Updated Telegram Calls interface.
Although its interface has been updated, some items are still not added in the calls (for example, Rate the Call or Choose the Speaker)
#Calls | #Beta v10.5
👉The TG Times
https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens
When someone connects with an app using #Facebook Login, the app will be able to obtain an access token which provides temporary, secure access to Facebook APIs.
An access #token is an opaque string that identifies a user, app, or Page and can be used by the app to make graph API #calls. Access tokens are obtained via a number of methods, each of which are covered later in this document. The token includes information about when the token will expire and which app generated the token. Because of privacy checks, the majority of #API calls on Facebook need to include an access token.
Channel: SMS Activation Updates
Members: ~5.32K
💢 Username: @virtualnumbersforverification
Description:
Your source for news and updates on virtual numbers for SMS and Calls. Keep up with trends and get exclusive offers from PrivatePhoneBot.
🏷 Tags: #other
#virtual_numbers#sms#calls#voip#sms_activation
https://telegramchannels.me/channels/virtualnumbersforverification
https://docs.python.org/3/library/asyncio-eventloop.html
#Calls
Most #asyncio functions don’t accept keywords. If you want to pass #keywords to your callback, use #functools.partial(). For example, #loop.#call_soon(functools.partial(print, "Hello", flush=True)) will call print("Hello", flush=True).
#Note
functools.partial() is better than lambda functions, because asyncio can inspect functools.partial() object to display parameters in debug mode, whereas lambda functions have a poor representation.
BaseEventLoop.call_soon(callback, *args)
Arrange for a callback to be called as soon as possible. The callback is called after call_soon() returns, when control returns to the event loop.
This operates as a FIFO queue, callbacks are called in the order in which they are registered. Each callback will be called exactly once.
Any positional arguments after the callback will be passed to the callback when it is called.
An instance of asyncio.Handle is returned, which can be used to cancel the callback.
Use functools.partial to pass keywords to the callback.
BaseEventLoop.call_soon_threadsafe(callback, *args)
Like call_soon(), but thread safe.
See the concurrency and multithreading section of the documentation.