9front - general discussion about 9front
 help / color / mirror / Atom feed
From: umbraticus@prosimetrum.com
To: 9front@9front.org
Subject: Re: [9front] mothra: proposal
Date: Fri, 20 Mar 2020 18:04:05 +1300	[thread overview]
Message-ID: <4BD638D767606C3EA7FA4A65D8F4EB1D@prosimetrum.com> (raw)
In-Reply-To: <86C8667F-F6B5-4941-809F-57B504CBD69B@stanleylieber.com>

Default colours work for me, and I haven't checked out how libtheme
works, but it occured to me that programs often have an array of
colours, which you could prime with an rc list thus:

; colours = (ff aaaaaaff ffffffff) myprog	# -b

Sure, you need to look at the source to work out which colour is
which, but you don't have to edit it and recompile, just put your
weird preferences in a script.  If that's what you're into.
envcolours() could go in the lib... eg: (excuse my spelling)

#include <u.h>
#include <libc.h>
#include <draw.h>
enum{ONE, TWO, THREE, NCOL};
ulong rgb[NCOL] = {[ONE] 0xff0000ff, [TWO] 0x00ff00ff, [THREE] 0x0000ffff};
void envcolours(Image **a, int n){
	char *s;
	int i;
	if(s = getenv("colours"))
		for(i = 0, s = strtok(s, " "); i < n && s != nil; i++, s = strtok(nil, " "))
			rgb[i] = strtoul(s, nil, 16);
}
void main(int, char**){
	Image *col[NCOL];
	Rectangle r;
	int i;
	if(initdraw(nil, nil, "colours") < 0) sysfatal("initdraw: %r");
	r = Rect(0, 0, 1, 1);
	envcolours(col, NCOL);
	for(i = 0; i < NCOL; i++)
		if((col[i] = allocimage(display, Rect(0,0,1,1), RGBA32, 1, rgb[i])) == nil)
			sysfatal("allocimage: %r");
	r = screen->r;
	i = Dy(r) / 6;
	draw(screen, r, col[ONE], nil, ZP);
	r = insetrect(r, i);
	draw(screen, r, col[TWO], nil, ZP);
	r = insetrect(r, i);
	draw(screen, r, col[THREE], nil, ZP);
	flushimage(display, 1);
	sleep(5000);
}

umbraticus


  reply	other threads:[~2020-03-20  5:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <C85FC655E82FCBE5B94289CB1073F9CC@ewsd.inri.net>
2020-03-20  3:00 ` ori
2020-03-20  3:21   ` Stanley Lieber
2020-03-20  5:04     ` umbraticus [this message]
     [not found] <42A469F0BBA88991B13EB7B76C0079B3@ewsd.inri.net>
2020-04-12 19:16 ` ori
2020-04-12 19:21 ` ori
2020-04-12 19:42   ` Stanley Lieber
2020-04-13  0:43   ` sl
     [not found] <F33C8113101B37111E4E412220D1377D@ewsd.inri.net>
2020-03-21 11:27 ` Ethan Gardener
2020-03-19 13:24 Stanley Lieber
2020-03-19 22:48 ` ori
2020-03-20  1:27   ` sl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BD638D767606C3EA7FA4A65D8F4EB1D@prosimetrum.com \
    --to=umbraticus@prosimetrum.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).