implement Rgb2tkcol; include "sys.m"; sys: Sys; include "draw.m"; include "bufio.m"; bufio: Bufio; Iobuf: import bufio; Rgb2tkcol: module { init: fn(nil: ref Draw->Context, argv: list of string); }; init(nil: ref Draw->Context, nil: list of string) { sys = load Sys Sys->PATH; stderr := sys->fildes(2); bufio = load Bufio Bufio->PATH; stdin := bufio->fopen(sys->fildes(0), Bufio->OREAD); while ((s := stdin.gets('\n')) != nil) { (n, toks) := sys->tokenize(s, " \n"); if (n != 3) { sys->fprint(stderr, "bad rgb line: %q", s); } else { (r, g, b) := (int hd toks, int hd tl toks, int hd tl tl toks); sys->print("#%.2x%.2x%.2x\n", r, g, b); } } }