ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* strange behaviour of colors
@ 2005-09-06 12:59 Mojca Miklavec
  2005-09-06 13:18 ` Filling forms luigi.scarso
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mojca Miklavec @ 2005-09-06 12:59 UTC (permalink / raw)


Hello,

In the following example, the title color changes on the second page. 
How can I avoid that? I can probably switch the cmyk/rgb colors off, but 
I would like to keep them as rgb/cmyk if possible.

\setupcolors[state=start]
\setuphead[title][page=yes,color=blue]
\starttext

\title{first page}
some text

\title{second page}
The title color has changed.

\definecolor [transparentred]  [r=1,t=.5,a=1]
\blackrule[width=2cm,height=2cm,color=transparentred]
\stoptext

Thank you,
	Mojca

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Filling forms
  2005-09-06 12:59 strange behaviour of colors Mojca Miklavec
@ 2005-09-06 13:18 ` luigi.scarso
  2005-09-06 14:47   ` Taco Hoekwater
  2005-09-06 13:46 ` strange behaviour of colors luigi.scarso
  2005-09-06 16:11 ` Hans Hagen
  2 siblings, 1 reply; 7+ messages in thread
From: luigi.scarso @ 2005-09-06 13:18 UTC (permalink / raw)


Hi, I'm working on a project that require filling forms.
Every field has  (x,y,width,height) dimension and
ui=(barcode,texEdit) type (textEdit has some attributes too)
I wrote this

%--------------
\unprotect
\definelayer[BackLayer]%
\setupbackgrounds[page][background={BackLayer}]

\setuplayout[topspace=0pt,backspace=0pt,margin=0pt,leftmargin=0pt,location=middle, 

 rightmargin=0pt,header=0pt,footer=0pt,top=0pt,bottom=0pt,
 leftedge=0pt,rightedge=0pt,headerdistance=0pt,footerdistance=0pt,
 topdistance=0pt,leftmargindistance=0pt,rightmargindistance=0pt,
 leftedgedistance=0pt,rightedgedistance=0pt,width=fit,height=fit]

\def\BarcodeThreeOfNine#1{#1} %% todo....

\def\Field[#1]{%
\bgroup
\getparameters[!!][#1]%% collect key/val
%
%
%%%% textEdit
\doifsamestring{\!!ui}{textEdit}{% text field
\setlayer[BackLayer][x=\!!x,y=\!!y ,location=br]{%
\expanded{\getparameters[!!textEdit@][\!!textEdit]}% collect textEdit 
attributes
\expanded{\getparameters[!!para@][\!!para]}% collect para attributes
\ruledvbox to \!!h{\hsize=\!!w %
\vss
\doifsamestringelse{\!!textEdit@multiLine}{0}{% single line
 \doifsamestring{\!!para@hAlign}{}{%
   \hbox to \!!w {\getvalue\s!dummy \vphantom{K}\getvalue\!!name \hss}%
  }%
 \doifsamestring{\!!para@hAlign}{left}{%
   \hbox to \!!w {\getvalue\s!dummy \vphantom{K} \getvalue\!!name \hss}%
 }%
 \doifsamestring{\!!para@hAlign}{right}{%
  \hbox to \!!w {\hss \getvalue\s!dummy  \vphantom{K} \getvalue\!!name}%
 }%
 \doifsamestring{\!!para@hAlign}{center}{%
  \hbox to \!!w {\hss \getvalue\s!dummy  \getvalue\!!name \hss}%
 }%
}{% multiline
\getvalue\s!dummy \getvalue\!!name%
}
%
\vss
}}}%
%%%% barcode
\doifsamestring{\!!ui}{barcode}{% barcode (todo..)
\setlayer[BackLayer][x=\!!x,y=\!!y ,location=br]{%
\doifsamestring{\!!type}{39}{% type of barcode
\ruledvbox to \!!h{\hsize=\!!w
\vss
\centerline{\expanded{\BarcodeThreeOfNine{\getvalue{\!!name}}}}
\vss}
}%
}}
\egroup
}
\protect

%%
%% Macros for filling forms
%%
\def\FillForm{%
%%
%% I have really 200 Fields
%%
\Field[%
name={codicearticolo_len6},%
ui={textEdit},%
textEdit={multiLine={0},},%
%x={0.520in},%
x={0.520in},%
y={0.217in},%
w={3.096in},%
h={0.882in},%
para={vAlign={middle},hAlign={}},%%
]

\Field[%
ui={barcode},%
type={39},%
name={barcode_codice___matricola},%
x={0.434in},%
y={1.259in},%
w={4.210in},%
h={0.651in},%
para={vAlign={middle},hAlign={}},%%
]
}

\starttext
\bgroup
%% I have really 200 \setvalue ....
\setvalue{codicearticolo_len6}{957803}
\setvalue{barcode_codice___matricola}{*9F9578030052201312*}
\hskip1sp%% force flush layer ??
\FillForm\page
\egroup
%% and so on for 1000 /1500 pages...
\stoptext

%----------------
Problems
1) I have 200 fields for a single page;
2) I have 1000/1500 pages
My code it's very slow:  does anybody has another approach ?

Thanks in advance
luigi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: strange behaviour of colors
  2005-09-06 12:59 strange behaviour of colors Mojca Miklavec
  2005-09-06 13:18 ` Filling forms luigi.scarso
@ 2005-09-06 13:46 ` luigi.scarso
  2005-09-06 14:42   ` Mojca Miklavec
  2005-09-06 16:11 ` Hans Hagen
  2 siblings, 1 reply; 7+ messages in thread
From: luigi.scarso @ 2005-09-06 13:46 UTC (permalink / raw)


Mojca Miklavec wrote:

> Hello,
>
> In the following example, the title color changes on the second page. 
> How can I avoid that? I can probably switch the cmyk/rgb colors off, 
> but I would like to keep them as rgb/cmyk if possible.
>
> \setupcolors[state=start]
> \setuphead[title][page=yes,color=blue]
> \starttext
>
> \title{first page}
> some text
>
> \title{second page}
> The title color has changed.
>
> \definecolor [transparentred]  [r=1,t=.5,a=1]
> \blackrule[width=2cm,height=2cm,color=transparentred]
> \stoptext
>
> Thank you,
>     Mojca
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
And moving \definecolor [transparentred]  [r=1,t=.5,a=1]
before \starttext ?
Under linux with acro7 I can't see differences.

luigi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: strange behaviour of colors
  2005-09-06 13:46 ` strange behaviour of colors luigi.scarso
@ 2005-09-06 14:42   ` Mojca Miklavec
  0 siblings, 0 replies; 7+ messages in thread
From: Mojca Miklavec @ 2005-09-06 14:42 UTC (permalink / raw)


luigi.scarso wrote:
> Mojca Miklavec wrote:
> 
> > Hello,
> >
> > In the following example, the title color changes on the second page.
> > How can I avoid that? I can probably switch the cmyk/rgb colors off,
> > but I would like to keep them as rgb/cmyk if possible.
> >
> > \setupcolors[state=start]
> > \setuphead[title][page=yes,color=blue]
> > \starttext
> >
> > \title{first page}
> > some text
> >
> > \title{second page}
> > The title color has changed.
> >
> > \definecolor [transparentred]  [r=1,t=.5,a=1]
> > \blackrule[width=2cm,height=2cm,color=transparentred]
> > \stoptext
> >
> > Thank you,
> >     Mojca
> >
> And moving \definecolor [transparentred]  [r=1,t=.5,a=1]
> before \starttext ?

It's \blackrule that triggers the change, not the \definecolor, but
you nevertheless gave me an idea! I will make a 0 times 0 box on the
first page which eventually solves the problem then, but this should
be solved generally.

> Under linux with acro7 I can't see differences.

After turning "separation preview" on, the colors appear to be "equal"
again (for the time when the little pup-up window is there, then the
changes appear again). I guess that the first title is typeset with
"rgb" blue and the second one with "cmyk" blue. With proper profile
settings, the colors appear to be the same (and should look the same),
but I'm affraid that they aren't. However, I don't know how to check
this.
It's quite possible that under windows some weird profile for
converting rgb <-> cmyk is chosen.

Thank you,
    Mojca

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Filling forms
  2005-09-06 13:18 ` Filling forms luigi.scarso
@ 2005-09-06 14:47   ` Taco Hoekwater
  2005-09-06 15:09     ` luigi.scarso
  0 siblings, 1 reply; 7+ messages in thread
From: Taco Hoekwater @ 2005-09-06 14:47 UTC (permalink / raw)




Hi Luigi,

It is hard to benchmark stuff without the actual dataset, but I
have some hints that may help you. (I hope my prose is not too
confusing).


luigi.scarso wrote:
> Hi, I'm working on a project that require filling forms.
> Every field has  (x,y,width,height) dimension and
> ui=(barcode,texEdit) type (textEdit has some attributes too)

I would have used two separate macros then, one for barcodes
and one for textEdit. More macros that each do less is generally
faster than fewer macros that do more.

If you have 200 fields, don't be scared to define 200 named
macros for them


> 
> \def\Field[#1]{%
> \bgroup
> \getparameters[!!][#1]%% collect key/val

You could use \rawgetparameters in this kind of input. It is a
lot faster and you have complete control over spaces in the
input, so there is no need to use the slower \getparameters.

> %
> %
> %%%% textEdit
> \doifsamestring{\!!ui}{textEdit}{% text field

\doifsamestring is quite slow. A faster solution: most arguments
can only be one or two different things, right? Then you can
predefine a macro for the possible cases, say \dotextEdit and
\dobarcode, and replace most of the body of the \Field command
with

   \getvalue{do\!!ui}


I would suggest you try to do this pre-defining trick for all things
you can possibly get away with.  String comparisons in macro code
are very expensive compared to the C lookup times for macro names.
Another example:

  \doifsamestring{\!!para@hAlign}{left}{%
    \hbox to \!!w {\getvalue\s!dummy \vphantom{K} \getvalue\!!name \hss}%
  }%

is a lot slower than:

  \def\parahAlignleft{% in the preamble
    \hbox to \!!w {\getvalue\s!dummy \vphantom{K} \getvalue\!!name \hss}%
  }

followed by

   \getvalue{parahAlign\!!para@hAlign} % in actual code


What is that \getvalue\s!dummy doing there, btw? I don't see what
purpose it serves.


You can also gain a considerable bit of speed by using an explicit
\hrule with the correct size, instead of \vphantom{K}. Or just put
the dimensions in a global \hbox beforehand:

   % in the preamble
   \newbox\Kbox
   \setbox\Kbox=\hbox{\vphantom{K}}
   \def\parahAlignleft{%
    \hbox to \!!w {\getvalue\s!dummy \copy\Kbox \getvalue\!!name \hss}%
   }


Oh, and grouping is also slow. Why would you bother restoring stuff
if you will overwrite the values before the next use ? There is no
need for \bgroup ...\egroup around the pages if every page defines
every field anyway.


I'm quite confident that a near-optimal solution will look like this:


	... lots and lots of macro defs,
         \starttext
          %% Some 200 \getvalue  calls
         \getvalue{codicearticolo_len6}{957803}
         \getvalue{barcode_codice___matricola}{*9F9578030052201312*}
         \page


Final trick: when in doubt, run TeX with

   \tracingall \tracingonline=0

in the preable, on an input file of just a few pages. The general rule
of thumb is: the smaller log file, the faster the 'real' run will be.


I hope this helps,

Taco

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Filling forms
  2005-09-06 14:47   ` Taco Hoekwater
@ 2005-09-06 15:09     ` luigi.scarso
  0 siblings, 0 replies; 7+ messages in thread
From: luigi.scarso @ 2005-09-06 15:09 UTC (permalink / raw)


Taco Hoekwater wrote:

>
>
> Hi Luigi,
>
> It is hard to benchmark stuff without the actual dataset, but I
> have some hints that may help you. (I hope my prose is not too
> confusing).
>
It's very clear.

> I hope this helps,

It's sure.

luigi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: strange behaviour of colors
  2005-09-06 12:59 strange behaviour of colors Mojca Miklavec
  2005-09-06 13:18 ` Filling forms luigi.scarso
  2005-09-06 13:46 ` strange behaviour of colors luigi.scarso
@ 2005-09-06 16:11 ` Hans Hagen
  2 siblings, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2005-09-06 16:11 UTC (permalink / raw)


Mojca Miklavec wrote:

> Hello,
>
> In the following example, the title color changes on the second page. 
> How can I avoid that? I can probably switch the cmyk/rgb colors off, 
> but I would like to keep them as rgb/cmyk if possible.
>
> \setupcolors[state=start]
> \setuphead[title][page=yes,color=blue]
> \starttext
>
> \title{first page}
> some text
>
> \title{second page}
> The title color has changed.
>
> \definecolor [transparentred]  [r=1,t=.5,a=1]
> \blackrule[width=2cm,height=2cm,color=transparentred]
> \stoptext

for a while i thought that it was a bug but it;s just acrobat messing up (in full acrobat 6 as well as reader 7): if you process the text with \pdfcompresslevel=0 you will see that the title has no transparency and is just the same rgb color as on page 1; acrobat always had problems with transparency + aliasing + caching + whatever deals with colors 

(best put some fake transparent thingie on page one)

Hans 


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-09-06 16:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-06 12:59 strange behaviour of colors Mojca Miklavec
2005-09-06 13:18 ` Filling forms luigi.scarso
2005-09-06 14:47   ` Taco Hoekwater
2005-09-06 15:09     ` luigi.scarso
2005-09-06 13:46 ` strange behaviour of colors luigi.scarso
2005-09-06 14:42   ` Mojca Miklavec
2005-09-06 16:11 ` Hans Hagen

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).