Page 2 of 2

Re: Can control page text change color based on a value?

PostPosted: Mon Aug 08, 2022 10:29 am
by SearchCz
DaveL17 wrote:
SearchCz wrote:
My text values are extra Ed fro the devices and placed into variables via Python. I think that makes it well suited to “infinite” possible values?


The way I think about it, I think so. One of my links above shows how to create an image with scrolling text; might this be something that could be adapted to your situation? In other words, not scrolling--but flashing?


Would any of these give the ability to create a small .png (circle or rectangle) of whatever RGB (or Hue) I specify?

Re: Can control page text change color based on a value?

PostPosted: Mon Aug 08, 2022 1:25 pm
by DaveL17
This one does. One caveat is that I haven't looked at it in a long time, so it might not work with Python 3 without some revisions.

https://github.com/DaveL17/indigo-scrip ... ted_gif.py

Re: Can control page text change color based on a value?

PostPosted: Tue Aug 09, 2022 7:52 am
by DaveL17
I had a moment so I threw together an extremely simple example using a Python library that ships with the latest version of Indigo (Pillow). There's lots of room for refinement, but it shows the nuts and bolts. Not sure it's exactly what you were looking for, but maybe it'll serve as a jumping off point.

Code: Select all
# #! /usr/bin/env python
# # -*- coding: utf-8 -*-

from PIL import Image, ImageDraw

images = []
save_file = "/Library/Application Support/Perceptive Automation/Indigo 2022.1/Web Assets/images/controls/static/anim.gif"
text = "Hello World"
height = 50
width = 100
color_1 = ("#FFFFFF", "#FFFFFF", "#FFFFFF", "#000000")
color_2 = ("#FF0000", "#FF6666", "#FF9999", "#FFFFFF")
step = 4

for i in range(0, step):
    im = Image.new('RGB', (width, height), color_2[i])
    draw = ImageDraw.Draw(im)
    draw.text((18, 18), text, color_1[i])
    images.append(im)

images[0].save(save_file, save_all=True, append_images=images[1:], optimize=True, duration=1000)

If you view it in Preview, it will continually rotate. But if you view it in Safari, it will only cycle once.

anim.gif
anim.gif (3.96 KiB) Viewed 1231 times