使用WatchFaceKotlin佩戴OS样品分别绘制并发症

发布于 2025-01-29 07:09:54 字数 956 浏览 2 评论 0原文

首先,我使用的是Google Wear OS样品,称为 watchfacekotkotkotkotkotkotkotkotkotlin

提供的样本一次绘制所有并发症。 我添加了背景复杂性,以便用户可以使用天气图像或更个人化的东西自定义背景。问题在于,背景并发症是如此明亮,以至于无法再看到图像前面的并发症。我想在背景并发症的前面使用drawargb(),并让用户在设置中使用滑块来决定背景亮度。 我似乎找不到这样做的地方,因为所有并发症都会立即绘制,并在所有并发症变暗之后添加drawargb()。有没有办法使用新API分裂并发症,以便我可以绘制背景,然后可以绘制drawargb(),然后是较小的并发症? 是我认为可以做的事情的

地方

    // ----- All drawing functions -----
private fun drawComplications(canvas: Canvas, zonedDateTime: ZonedDateTime) {
    for ((_, complication) in complicationSlotsManager.complicationSlots) {
        if (complication.enabled) {
            complication.render(canvas, zonedDateTime, renderParameters)
            canvas.drawARGB(watchFaceData.brightnessFractionDefault.brightnessFraction.toInt(),0,0,0)
        }
    }
}

这 一次绘制它们。有什么想法吗?感谢您的任何帮助。

First off, I am using the Google Wear OS sample called WatchFaceKotlin.

The sample provided draws all of the complications at once.
I have added a background complication so that users can customize the background with perhaps a weather image or something more personal. Problem is that the background complication is drawn so bright that the complications in front of the image can no longer be seen. I want to use drawARGB() in front of the background complication and let the user decide on the background brightness with a slider in the settings.
I cant seem to find a place to do this since all complications are drawn at once and adding the drawARGB() after that darkens all complications. Is there a way to split the complications using the new API's so that I can draw the background, then the drawARGB(), and then the smaller complications? Here is where I am thinking that something could possibly be done but there is something that I am missing since this way does not work correctly

In the AnalogWatchCanvasRenderer.kt

    // ----- All drawing functions -----
private fun drawComplications(canvas: Canvas, zonedDateTime: ZonedDateTime) {
    for ((_, complication) in complicationSlotsManager.complicationSlots) {
        if (complication.enabled) {
            complication.render(canvas, zonedDateTime, renderParameters)
            canvas.drawARGB(watchFaceData.brightnessFractionDefault.brightnessFraction.toInt(),0,0,0)
        }
    }
}

There must be a way to only draw a specific complication instead of using complication.render and drawing them all at once. Any thoughts? Thanks for any attempt to help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴情 2025-02-05 07:09:54

您可以在调用渲染时添加条件,在哪里检查ID或插槽的类型,并在绘制插槽后绘制暗色。

这是可以帮助您使其正常工作的条件:

if (complication.boundsType == ComplicationSlotBoundsType.BACKGROUND) {
    ...
} else {
    ...
}

You can add a condition when calling render, where you check the id or the type of the slot, and draw a darkening color just after drawing the slot.

This is the kind of condition that can help you make it work:

if (complication.boundsType == ComplicationSlotBoundsType.BACKGROUND) {
    ...
} else {
    ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文