From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/38007 Path: news.gmane.org!not-for-mail From: Peter Rolf Newsgroups: gmane.comp.tex.context Subject: Re: color expansion at runtime Date: Sat, 15 Dec 2007 15:07:11 +0100 Message-ID: <4763DF8F.4050109@gmx.net> References: <4762B608.1010107@gmx.net> <115224fb0712150217r779279ddo9b264c4fafa00c8d@mail.gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1197727652 12875 80.91.229.12 (15 Dec 2007 14:07:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Dec 2007 14:07:32 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat Dec 15 15:07:44 2007 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1J3Xg7-0003B5-Vv for gctc-ntg-context-518@m.gmane.org; Sat, 15 Dec 2007 15:07:44 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 085601FAE4; Sat, 15 Dec 2007 15:07:24 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 30558-01-7; Sat, 15 Dec 2007 15:07:19 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id E5C3C1FA93; Sat, 15 Dec 2007 15:07:18 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C39191FA93 for ; Sat, 15 Dec 2007 15:07:16 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 30558-01-6 for ; Sat, 15 Dec 2007 15:07:12 +0100 (CET) Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by ronja.ntg.nl (Postfix) with SMTP id DF8B61FA63 for ; Sat, 15 Dec 2007 15:07:12 +0100 (CET) Original-Received: (qmail invoked by alias); 15 Dec 2007 14:07:12 -0000 Original-Received: from i5387C795.versanet.de (EHLO [192.168.1.3]) [83.135.199.149] by mail.gmx.net (mp010) with SMTP; 15 Dec 2007 15:07:12 +0100 X-Authenticated: #24293357 X-Provags-ID: V01U2FsdGVkX18evkVQr/geoknM+dCvj0+JXiNx299IXCCmOb485N ff4kQ76/gH6S7g User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) In-Reply-To: <115224fb0712150217r779279ddo9b264c4fafa00c8d@mail.gmail.com> X-Enigmail-Version: 0.95.5 X-Y-GMX-Trusted: 0 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:38007 Archived-At: Wolfgang Schuster schrieb: > 2007/12/14, Peter Rolf : >> Hi, >> >> I desperately need runtime defined colors (state dependent) for my >> macros. The macros are used with different graphic styles, which is the >> reason why I want to avoid any style dependent part inside them. >> >> To give you an example. I need something like this >> >> \color[{\StateDependentColor[stateA=green,stateC=blue,whatever=yellow,...]}] >> >> If flag 'stateA' is true at runtime, then color 'green' is used (and so >> on; order is significant). >> >> I have written such a macro, but sadly it crashes when used inside >> \color or \definecolor. Tried to debug it, but this is my first >> experience with the trace commands (probably not the best example to >> start with). Sigh, still so much to learn.. :) >> >> Any hints are welcome. >> >> Regards, Peter > > Hi Peter, > > can you try this (untested), Hi Wolfgang, your idea works pretty good (I haven't thought about \ifcase 'til now). Still the problem is, that - currentstate must be set somehow - the colors and the number of used states vary from macro to macro So I have to define individual variants of \statecolor (with non fixed state=number pairs), or add an entry for every single state (currently 9). The later method is too ugly (imagine the case that you only need states 0 and 8) and will be hard to maintain if new states arise. I end up with 60 macros and that is what I want to avoid. Anyhow thanks for your help. I will try to trace my color macro while listening the right music for such problems (Yo La Tengo - I am not afraid of you and will beat your ass). Hopefully it works. ;) Greetings, Peter > > \chardef\stateA\zerocount > \chardef\stateB\plusone > \chardef\stateC\plustwo > > \let\currentstate\stateA > > \def\statecolor{\ifcase\currentstate red\or green\or blue\fi} > > \starttext > > \color[\statecolor]{Currentstate} > > \let\currentstate\stateB > > \color[\statecolor]{Currentstate} > > \let\currentstate\stateC > > \color[\statecolor]{Currentstate} > > \stoptext > > > Wolfgang > ___________________________________________________________________________________ > If your question is of interest to others as well, please add an entry to the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : https://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ > ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________