使用WatchFaceKotlin佩戴OS样品分别绘制并发症
首先,我使用的是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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在调用渲染时添加条件,在哪里检查ID或插槽的类型,并在绘制插槽后绘制暗色。
这是可以帮助您使其正常工作的条件:
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: