Can control page text change color based on a value?

Posted on
Mon Aug 08, 2022 10:29 am
SearchCz offline
Posts: 172
Joined: Sep 18, 2019

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

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?

Posted on
Mon Aug 08, 2022 1:25 pm
DaveL17 offline
User avatar
Posts: 6751
Joined: Aug 20, 2013
Location: Chicago, IL, USA

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

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

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Aug 09, 2022 7:52 am
DaveL17 offline
User avatar
Posts: 6751
Joined: Aug 20, 2013
Location: Chicago, IL, USA

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

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 1121 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Who is online

Users browsing this forum: No registered users and 6 guests

cron