ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* drops module (draft)
@ 2012-12-06 17:08 Peter Rolf
  2012-12-06 18:05 ` Aditya Mahajan
  2012-12-07 18:02 ` Otared Kavian
  0 siblings, 2 replies; 16+ messages in thread
From: Peter Rolf @ 2012-12-06 17:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]

Hi all,

a first version of the 'drops'-module (MkIV only) is available at

https://www.wuala.com/indiego/public/ConTeXt/drops/?key=caiCGLasLFmJ


Taken from the included documentation..
[..]
'drops' is a small extension for ConTeXt, that allows you to add drop
shadows to rectangular regions (so called boxshadows). A working
installation of ImageMagick (IM) is required to create the shadow
graphics. The supported color spaces are CMYK, RGB and Gray, the file
formats are limited to PNG and JPG.
[..]
Read the manual for detailed information.

The attached example is just a small test file for the 'rotation'
parameter (a compensation for the object rotation, so that the shadow
stays at the given direction). You will find other examples in the
documentation and there is also a 'pile' example with the complete
source. The 'presets' pdf contains the predefined setups for different
shadow (or frame) types and it's source is a good starting point for
your own experiments.

This is a first draft, but most things work quite stable. If you want to
help, test as much as possible. :-)

*You need a recent version of ImageMagick for this module.*

6.7.8-2 to 6.8.0-7 (wrong version info 6.8.0-6): used here, should work
6.7.6-0 or lower: will fail due to incompatibilities
7.0.0.0 alpha: untested ('magick' is used instead of 'convert')

Tested on Windows7 64bit and Debian 6.0.5-i386 (IM compiled from source)


Happy TeXing!


Peter

[-- Attachment #2: rotate.pdf --]
[-- Type: application/pdf, Size: 8942 bytes --]

[-- Attachment #3: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: drops module (draft)
  2012-12-06 17:08 drops module (draft) Peter Rolf
@ 2012-12-06 18:05 ` Aditya Mahajan
  2012-12-06 18:18   ` Wolfgang Schuster
                     ` (4 more replies)
  2012-12-07 18:02 ` Otared Kavian
  1 sibling, 5 replies; 16+ messages in thread
From: Aditya Mahajan @ 2012-12-06 18:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, 6 Dec 2012, Peter Rolf wrote:

> Hi all,
>
> a first version of the 'drops'-module (MkIV only) is available at
>
> https://www.wuala.com/indiego/public/ConTeXt/drops/?key=caiCGLasLFmJ
>
>
> Taken from the included documentation..
> [..]
> 'drops' is a small extension for ConTeXt, that allows you to add drop
> shadows to rectangular regions (so called boxshadows). A working
> installation of ImageMagick (IM) is required to create the shadow
> graphics. The supported color spaces are CMYK, RGB and Gray, the file
> formats are limited to PNG and JPG.
> [..]
> Read the manual for detailed information.

Nice.

> The attached example is just a small test file for the 'rotation'
> parameter (a compensation for the object rotation, so that the shadow
> stays at the given direction). You will find other examples in the
> documentation and there is also a 'pile' example with the complete
> source. The 'presets' pdf contains the predefined setups for different
> shadow (or frame) types and it's source is a good starting point for
> your own experiments.
>
> This is a first draft, but most things work quite stable. If you want to
> help, test as much as possible. :-)
>
> *You need a recent version of ImageMagick for this module.*

I always thought that shadows were possible to do in PDF 
(after all TikZ does it using some type of PDF primitives). Since you are 
the PDF expert, I am interested in knowing why you choose to go the 
ImageMagic route.

In terms of interface, wouldn't it be better if this somehow interfaced 
with the background/overlay mechanism. For example,

\definedropshadow[identifier][...options...]

which will define an overlay that will call ImageMagic with appropriate 
parameters (and caching the results if speed is a concern),

and then

\externalfigure[name][background=identifier]

should draw a dropped shadow around the image

Aditya
___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: drops module (draft)
  2012-12-06 18:05 ` Aditya Mahajan
@ 2012-12-06 18:18   ` Wolfgang Schuster
  2012-12-07 12:01     ` Peter Rolf
  2012-12-06 18:35   ` Marco
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Wolfgang Schuster @ 2012-12-06 18:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 06.12.2012 um 19:05 schrieb Aditya Mahajan <adityam@umich.edu>:

> On Thu, 6 Dec 2012, Peter Rolf wrote:
> 
>> Hi all,
>> 
>> a first version of the 'drops'-module (MkIV only) is available at
>> 
>> https://www.wuala.com/indiego/public/ConTeXt/drops/?key=caiCGLasLFmJ
>> 
>> 
>> Taken from the included documentation..
>> [..]
>> 'drops' is a small extension for ConTeXt, that allows you to add drop
>> shadows to rectangular regions (so called boxshadows). A working
>> installation of ImageMagick (IM) is required to create the shadow
>> graphics. The supported color spaces are CMYK, RGB and Gray, the file
>> formats are limited to PNG and JPG.
>> [..]
>> Read the manual for detailed information.
> 
> Nice.

The module would be cleaner with a MkIV rewrite and I would drop the option
to accept each module parameter with \usemodule.

I would also create a new namespace for the \setupdrops command because
currently it uses the “module” namespace.

\def\dosetupdrops[#1]%
  {\iffirstargument\getparameters[\??module drops:][#1,{\c!setup=}]\else % never parameter 'setup'
   \ctxlua{thirddata.drops.resetdrops()}\fi} % reset all parameters to their default, when no argument is given

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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: drops module (draft)
  2012-12-06 18:05 ` Aditya Mahajan
  2012-12-06 18:18   ` Wolfgang Schuster
@ 2012-12-06 18:35   ` Marco
  2012-12-06 19:46     ` Hans Hagen
  2012-12-07 12:04     ` Peter Rolf
  2012-12-06 19:05   ` Hans Hagen
                     ` (2 subsequent siblings)
  4 siblings, 2 replies; 16+ messages in thread
From: Marco @ 2012-12-06 18:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 2012–12–06 Aditya Mahajan wrote:

> I always thought that shadows were possible to do in PDF (after all
> TikZ does it using some type of PDF primitives).

It is. I use MetaPost to draw the shadows using the shading
mechanism:

  withshading("circular", urcorner bottom_left, urcorner bottom_left, radius, 0)
  withfromshadecolor \MPcolor{c:transparent}
  withtoshadecolor   col;

and it works well if placed in an overlay. However, I did not manage
to get it working in TikZ, it could not display shadings to
transparent colours (which is very handy for slides where the
shadings might overlay graphics with a non-uniform colour).

> Since you are the PDF expert, I am interested in knowing why you
> choose to go the ImageMagic route.

From my experience shadows made from MetaPost shadings (which uses
PDF shadings, I assume) are quite low level. It's harder to get the
angle, distance and shadow size correctly implemented. I think the
ImageMagick shadings are more high level and ready to use.


Marco

___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: drops module (draft)
  2012-12-06 18:05 ` Aditya Mahajan
  2012-12-06 18:18   ` Wolfgang Schuster
  2012-12-06 18:35   ` Marco
@ 2012-12-06 19:05   ` Hans Hagen
  2012-12-06 19:44   ` Hans Hagen
  2012-12-07 11:59   ` Peter Rolf
  4 siblings, 0 replies; 16+ messages in thread
From: Hans Hagen @ 2012-12-06 19:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 12/6/2012 7:05 PM, Aditya Mahajan wrote:
> On Thu, 6 Dec 2012, Peter Rolf wrote:
>
>> Hi all,
>>
>> a first version of the 'drops'-module (MkIV only) is available at
>>
>> https://www.wuala.com/indiego/public/ConTeXt/drops/?key=caiCGLasLFmJ
>>
>>
>> Taken from the included documentation..
>> [..]
>> 'drops' is a small extension for ConTeXt, that allows you to add drop
>> shadows to rectangular regions (so called boxshadows). A working
>> installation of ImageMagick (IM) is required to create the shadow
>> graphics. The supported color spaces are CMYK, RGB and Gray, the file
>> formats are limited to PNG and JPG.
>> [..]
>> Read the manual for detailed information.
>
> Nice.
>
>> The attached example is just a small test file for the 'rotation'
>> parameter (a compensation for the object rotation, so that the shadow
>> stays at the given direction). You will find other examples in the
>> documentation and there is also a 'pile' example with the complete
>> source. The 'presets' pdf contains the predefined setups for different
>> shadow (or frame) types and it's source is a good starting point for
>> your own experiments.
>>
>> This is a first draft, but most things work quite stable. If you want to
>> help, test as much as possible. :-)
>>
>> *You need a recent version of ImageMagick for this module.*
>
> I always thought that shadows were possible to do in PDF (after all TikZ
> does it using some type of PDF primitives). Since you are the PDF
> expert, I am interested in knowing why you choose to go the ImageMagic
> route.

Some tricks are possible with functions that repeat bitmap patterns in 
clever ways but I lost the code that does it. If Peter can tell us what 
graphics are needed we can also make them directly as the img library 
has that possibility (we use it in mojca's gnuplot module)

Anyhow, as you are the math magician, here's a start:

\starttext

\startluacode
     local format = string.format
     function document.TestBitmap(nx,ny)
         local r = { }
         local s = 1/nx
         for i=1,ny do
             local c = { }
             for j=1,nx/2 do
                 c[#c+1] = format("%02x",j*s*255)
             end
             for j=nx/2,1,-1 do
                 c[#c+1] = format("%02x",j*s*255)
             end
             c = table.concat(c,"",1,nx)
             r[#r+1] = c
         end
         r = table.concat(r,"\r",1,ny)
         print(r)
         context(r)
     end
\stopluacode

\startMPcode
     draw 
textext("\bitmapimage[x=100,y=100,color=gray]{\ctxlua{document.TestBitmap(100,100)}}") 
xsized 10cm ;
\stopMPcode

\stoptext

So, what's needed is some edge related jugling.

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: drops module (draft)
  2012-12-06 18:05 ` Aditya Mahajan
                     ` (2 preceding siblings ...)
  2012-12-06 19:05   ` Hans Hagen
@ 2012-12-06 19:44   ` Hans Hagen
  2012-12-07 11:59   ` Peter Rolf
  4 siblings, 0 replies; 16+ messages in thread
From: Hans Hagen @ 2012-12-06 19:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 12/6/2012 7:05 PM, Aditya Mahajan wrote:

> I always thought that shadows were possible to do in PDF (after all TikZ
> does it using some type of PDF primitives). Since you are the PDF
> expert, I am interested in knowing why you choose to go the ImageMagic
> route.

not so efficient but it shows a bit what bitmaps can do

\starttext

\startluacode
     local format = string.format
     local concat = table.concat
     function document.TestBitmap(nx,ny)
         nx = math.round(nx/65536)
         ny = math.round(ny/65536)
         nx = 2 * math.round(nx/2)
         ny = 2 * math.round(ny/2)
         local r = { }
         local dx = 255/nx
         local dy = 255/ny
         for i=1,ny/2 do
             local n = i*dy
             local c = { }
             for j=1,nx/2 do
                 c[#c+1] = format("%02x",j*dx+n)
             end
             for j=nx/2,1,-1 do
                 c[#c+1] = format("%02x",j*dx+n)
             end
             c = concat(c,"",1,nx)
             r[#r+1] = c
         end
         for i=ny/2,1,-1 do
             local n = i*dy
             local c = { }
             for j=1,nx/2 do
                 c[#c+1] = format("%02x",j*dx+n)
             end
             for j=nx/2,1,-1 do
                 c[#c+1] = format("%02x",j*dx+n)
             end
             c = concat(c,"",1,nx)
             r[#r+1] = c
         end
         r = concat(r,"\r",1,ny)
         figures.bitmapimage {
             data        = r,
             xresolution = nx,
             yresolution = ny,
         }
     end
\stopluacode

\defineoverlay
   [BitMess]
   [{\scale
       [width=\dimexpr\overlaywidth+2ex,height=\dimexpr\overlayheight+2ex]
 
{\ctxlua{document.TestBitmap(\number\dimexpr\overlaywidth,\number\dimexpr\overlayheight)}}}]

\framed
   [width=10cm,
    height=10cm,
    frame=off,
    background={BitMess,color},
    backgroundcolor=white]
   {test}

\stoptext

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: drops module (draft)
  2012-12-06 18:35   ` Marco
@ 2012-12-06 19:46     ` Hans Hagen
  2012-12-07 12:04     ` Peter Rolf
  1 sibling, 0 replies; 16+ messages in thread
From: Hans Hagen @ 2012-12-06 19:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 12/6/2012 7:35 PM, Marco wrote:
> On 2012–12–06 Aditya Mahajan wrote:
>
>> I always thought that shadows were possible to do in PDF (after all
>> TikZ does it using some type of PDF primitives).
>
> It is. I use MetaPost to draw the shadows using the shading
> mechanism:
>
>    withshading("circular", urcorner bottom_left, urcorner bottom_left, radius, 0)
>    withfromshadecolor \MPcolor{c:transparent}
>    withtoshadecolor   col;
>
> and it works well if placed in an overlay. However, I did not manage
> to get it working in TikZ, it could not display shadings to
> transparent colours (which is very handy for slides where the
> shadings might overlay graphics with a non-uniform colour).

I think drops are somewhat different as they might follow different 
rules than circular or linear shades

>> Since you are the PDF expert, I am interested in knowing why you
>> choose to go the ImageMagic route.
>
>  From my experience shadows made from MetaPost shadings (which uses
> PDF shadings, I assume) are quite low level. It's harder to get the
> angle, distance and shadow size correctly implemented. I think the
> ImageMagick shadings are more high level and ready to use.

Yes. Of course we can make shading more clever, but to be honest I never 
had the need.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: drops module (draft)
  2012-12-06 18:05 ` Aditya Mahajan
                     ` (3 preceding siblings ...)
  2012-12-06 19:44   ` Hans Hagen
@ 2012-12-07 11:59   ` Peter Rolf
  4 siblings, 0 replies; 16+ messages in thread
From: Peter Rolf @ 2012-12-07 11:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 06.12.2012 19:05, schrieb Aditya Mahajan:
> On Thu, 6 Dec 2012, Peter Rolf wrote:
> 
>> Hi all,
>>
>> a first version of the 'drops'-module (MkIV only) is available at
>>
>> https://www.wuala.com/indiego/public/ConTeXt/drops/?key=caiCGLasLFmJ
>>
>>
>> Taken from the included documentation..
>> [..]
>> 'drops' is a small extension for ConTeXt, that allows you to add drop
>> shadows to rectangular regions (so called boxshadows). A working
>> installation of ImageMagick (IM) is required to create the shadow
>> graphics. The supported color spaces are CMYK, RGB and Gray, the file
>> formats are limited to PNG and JPG.
>> [..]
>> Read the manual for detailed information.
> 
> Nice.
> 
>> The attached example is just a small test file for the 'rotation'
>> parameter (a compensation for the object rotation, so that the shadow
>> stays at the given direction). You will find other examples in the
>> documentation and there is also a 'pile' example with the complete
>> source. The 'presets' pdf contains the predefined setups for different
>> shadow (or frame) types and it's source is a good starting point for
>> your own experiments.
>>
>> This is a first draft, but most things work quite stable. If you want to
>> help, test as much as possible. :-)
>>
>> *You need a recent version of ImageMagick for this module.*
> 
> I always thought that shadows were possible to do in PDF (after all TikZ
> does it using some type of PDF primitives). Since you are the PDF
> expert, I am interested in knowing why you choose to go the ImageMagic
> route.
>
Because it's relative simple (I use a working function) , fast (in terms
of rendering speed) and the footprint of the shadow graphics is not that
big (png: one color, only alpha channel differs). Quality is (as you can
see) also not an issue. Mh, there is nothing wrong with bitmaps ;-)

See Type4/Type5 Shadings (Free-Form Gouraud-Shaded Triangle Meshes) on
page 314 of the PDF Reference for the PDF alternative. The problems to
solve are the calculation of the mesh points (think about rounded
squares) and also to find a proper shading function (which sets the
colors). See 'Shadow Internals' at

http://www.imagemagick.org/Usage/blur/#shadow%20internals

Far from trivial (and I'm only an amateur with limited time).

Also: you can 'draw' (command of IM) any shape in IM (SVG paths are
supported) and use the 'shadow' function on that. Theoretically you can
extent drops to support any shape (path or drawing). That's one reason
why I used the more general name 'drops' instead of the currently better
fitting 'boxshadow'. The other reason is, that Hans would never use the
stupid name 'drops' internally. :-D

> In terms of interface, wouldn't it be better if this somehow interfaced
> with the background/overlay mechanism. For example,
> 
> \definedropshadow[identifier][...options...]
> 
> which will define an overlay that will call ImageMagic with appropriate
> parameters (and caching the results if speed is a concern),
> 
> and then
> 
> \externalfigure[name][background=identifier]
> 
> should draw a dropped shadow around the image
> 

Needs some thinking


> Aditya
> ___________________________________________________________________________________
> 
> 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  : http://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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: drops module (draft)
  2012-12-06 18:18   ` Wolfgang Schuster
@ 2012-12-07 12:01     ` Peter Rolf
  2012-12-07 12:57       ` Wolfgang Schuster
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Rolf @ 2012-12-07 12:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 06.12.2012 19:18, schrieb Wolfgang Schuster:
> 
> Am 06.12.2012 um 19:05 schrieb Aditya Mahajan <adityam@umich.edu>:
> 
>> On Thu, 6 Dec 2012, Peter Rolf wrote:
>>
>>> Hi all,
>>>
>>> a first version of the 'drops'-module (MkIV only) is available at
>>>
>>> https://www.wuala.com/indiego/public/ConTeXt/drops/?key=caiCGLasLFmJ
>>>
>>>
>>> Taken from the included documentation..
>>> [..]
>>> 'drops' is a small extension for ConTeXt, that allows you to add drop
>>> shadows to rectangular regions (so called boxshadows). A working
>>> installation of ImageMagick (IM) is required to create the shadow
>>> graphics. The supported color spaces are CMYK, RGB and Gray, the file
>>> formats are limited to PNG and JPG.
>>> [..]
>>> Read the manual for detailed information.
>>
>> Nice.
> 
> The module would be cleaner with a MkIV rewrite and I would drop the option
> to accept each module parameter with \usemodule.
>
Will look into that. I have to fix several remaining problems (IM
related) first, before I can think about a 'cleanup' :-D

> I would also create a new namespace for the \setupdrops command because
> currently it uses the “module” namespace.
> 
> \def\dosetupdrops[#1]%
>   {\iffirstargument\getparameters[\??module drops:][#1,{\c!setup=}]\else % never parameter 'setup'
>    \ctxlua{thirddata.drops.resetdrops()}\fi} % reset all parameters to their default, when no argument is given
> 

Ok. Can you explain why that is a problem?


> 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  : http://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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: drops module (draft)
  2012-12-06 18:35   ` Marco
  2012-12-06 19:46     ` Hans Hagen
@ 2012-12-07 12:04     ` Peter Rolf
  2012-12-07 12:49       ` Marco Patzer
  1 sibling, 1 reply; 16+ messages in thread
From: Peter Rolf @ 2012-12-07 12:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 06.12.2012 19:35, schrieb Marco:
> On 2012–12–06 Aditya Mahajan wrote:
> 
>> I always thought that shadows were possible to do in PDF (after all
>> TikZ does it using some type of PDF primitives).
> 
> It is. I use MetaPost to draw the shadows using the shading
> mechanism:
> 
>   withshading("circular", urcorner bottom_left, urcorner bottom_left, radius, 0)
>   withfromshadecolor \MPcolor{c:transparent}
>   withtoshadecolor   col;
>

Don't mix Type2/3 with Type 4/5 shadings (see my answer to Aditya). They
are all called 'shadings', but only the latter can be used for the
creation of realistic looking drop shadows.

And to repeat myself: there is nothing wrong with bitmaps. Take the best
from both worlds ;-)


> and it works well if placed in an overlay. However, I did not manage
> to get it working in TikZ, it could not display shadings to
> transparent colours (which is very handy for slides where the
> shadings might overlay graphics with a non-uniform colour).
> 
>> Since you are the PDF expert, I am interested in knowing why you
>> choose to go the ImageMagic route.
> 
> From my experience shadows made from MetaPost shadings (which uses
> PDF shadings, I assume) are quite low level. It's harder to get the
> angle, distance and shadow size correctly implemented. I think the
> ImageMagick shadings are more high level and ready to use.
> 
> 
> Marco
> 
> ___________________________________________________________________________________
> 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  : http://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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: drops module (draft)
  2012-12-07 12:04     ` Peter Rolf
@ 2012-12-07 12:49       ` Marco Patzer
  2012-12-07 13:27         ` Peter Rolf
  0 siblings, 1 reply; 16+ messages in thread
From: Marco Patzer @ 2012-12-07 12:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 2012–12–07 Peter Rolf wrote:

> Am 06.12.2012 19:35, schrieb Marco:
> > On 2012–12–06 Aditya Mahajan wrote:
> > 
> >> I always thought that shadows were possible to do in PDF (after all
> >> TikZ does it using some type of PDF primitives).
> > 
> > It is. I use MetaPost to draw the shadows using the shading
> > mechanism:
> > 
> >   withshading("circular", urcorner bottom_left, urcorner bottom_left, radius, 0)
> >   withfromshadecolor \MPcolor{c:transparent}
> >   withtoshadecolor   col;
> >
> 
> Don't mix Type2/3 with Type 4/5 shadings (see my answer to Aditya). They
> are all called 'shadings', but only the latter can be used for the
> creation of realistic looking drop shadows.

Thanks for pointing that out. I will have a look into my code again.

I was (and actually I still am) confused by the different shading
methods provided by MetaFun. I admit that I never read the PDF
reference which means that I don't know the shading internals. I
experimented a little and came up with a working solution to add
some eye-candy to presentations.

> And to repeat myself: there is nothing wrong with bitmaps.

I agree. Even Knuth designed his fonts as bitmaps (at least the
output is a bitmap). However, bitmaps always have a fixed size and
thus are not scalable.

> Take the best from both worlds ;-)

ACK

And thanks for this nice module and especially for the well-written
documentation.


Marco

___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: drops module (draft)
  2012-12-07 12:01     ` Peter Rolf
@ 2012-12-07 12:57       ` Wolfgang Schuster
  0 siblings, 0 replies; 16+ messages in thread
From: Wolfgang Schuster @ 2012-12-07 12:57 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 07.12.2012 um 13:01 schrieb Peter Rolf <indiego@gmx.net>:

>> I would also create a new namespace for the \setupdrops command because
>> currently it uses the “module” namespace.
>> 
>> \def\dosetupdrops[#1]%
>>  {\iffirstargument\getparameters[\??module drops:][#1,{\c!setup=}]\else % never parameter 'setup'
>>   \ctxlua{thirddata.drops.resetdrops()}\fi} % reset all parameters to their default, when no argument is given
> 
> Ok. Can you explain why that is a problem?

It’s bad style to misuse internal namespaces and and you can’t be sure the namespaces changes
which lead to problems with the simple slides module which used the \setavariables namespace
for a while.

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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: drops module (draft)
  2012-12-07 12:49       ` Marco Patzer
@ 2012-12-07 13:27         ` Peter Rolf
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Rolf @ 2012-12-07 13:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 07.12.2012 13:49, schrieb Marco Patzer:
> On 2012–12–07 Peter Rolf wrote:
> 
>> Am 06.12.2012 19:35, schrieb Marco:
>>> On 2012–12–06 Aditya Mahajan wrote:
>>>
>>>> I always thought that shadows were possible to do in PDF (after all
>>>> TikZ does it using some type of PDF primitives).
>>>
>>> It is. I use MetaPost to draw the shadows using the shading
>>> mechanism:
>>>
>>>   withshading("circular", urcorner bottom_left, urcorner bottom_left, radius, 0)
>>>   withfromshadecolor \MPcolor{c:transparent}
>>>   withtoshadecolor   col;
>>>
>>
>> Don't mix Type2/3 with Type 4/5 shadings (see my answer to Aditya). They
>> are all called 'shadings', but only the latter can be used for the
>> creation of realistic looking drop shadows.
> 
> Thanks for pointing that out. I will have a look into my code again.
> 
> I was (and actually I still am) confused by the different shading
> methods provided by MetaFun. I admit that I never read the PDF
> reference which means that I don't know the shading internals. I
> experimented a little and came up with a working solution to add
> some eye-candy to presentations.
>

Nearly everyone loves eye-candy in presentations. It distracts the
observer from the question "What am I doing here....?" ;-)

>> And to repeat myself: there is nothing wrong with bitmaps.
> 
> I agree. Even Knuth designed his fonts as bitmaps (at least the
> output is a bitmap). However, bitmaps always have a fixed size and
> thus are not scalable.
>

True. I haven't played around with Photoshop or Indesign for years, but
the old versions also used bitmaps for their drop shadows. If Adobe as
the inventor of PDF does it, ...

>> Take the best from both worlds ;-)
> 
> ACK
> 
> And thanks for this nice module and especially for the well-written
> documentation.
>
I tried my best (which means it took a looooooooooooong time). :-)

> 
> Marco
> 
> ___________________________________________________________________________________
> 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  : http://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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: drops module (draft)
  2012-12-06 17:08 drops module (draft) Peter Rolf
  2012-12-06 18:05 ` Aditya Mahajan
@ 2012-12-07 18:02 ` Otared Kavian
  2012-12-07 20:53   ` Hans Hagen
  2012-12-08 13:03   ` Peter Rolf
  1 sibling, 2 replies; 16+ messages in thread
From: Otared Kavian @ 2012-12-07 18:02 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Peter,

Thank you for your very nice module.
For your information, I wanted just to report an issue I noticed with Adobe Reader (Version: 11.0.0 (11.0.0)) on Mac OS X 10.8: when I try to open the file « pile.pdf » (which is in your « examples » directory) Adobe Reader crashes and there is no way to open that file with it. However th eother file, « rotate.pdf » opens without any problem…

Best regards: OK

On 6 déc. 2012, at 18:08, Peter Rolf <indiego@gmx.net> wrote:

> Hi all,
> 
> a first version of the 'drops'-module (MkIV only) is available at
> 
> https://www.wuala.com/indiego/public/ConTeXt/drops/?key=caiCGLasLFmJ
> 
> 
> Taken from the included documentation..
> [..]
> 'drops' is a small extension for ConTeXt, that allows you to add drop
> shadows to rectangular regions (so called boxshadows). A working
> installation of ImageMagick (IM) is required to create the shadow
> graphics. The supported color spaces are CMYK, RGB and Gray, the file
> formats are limited to PNG and JPG.
> [..]
> Read the manual for detailed information.
> 
> The attached example is just a small test file for the 'rotation'
> parameter (a compensation for the object rotation, so that the shadow
> stays at the given direction). You will find other examples in the
> documentation and there is also a 'pile' example with the complete
> source. The 'presets' pdf contains the predefined setups for different
> shadow (or frame) types and it's source is a good starting point for
> your own experiments.
> 
> This is a first draft, but most things work quite stable. If you want to
> help, test as much as possible. :-)
> 
> *You need a recent version of ImageMagick for this module.*
> 
> 6.7.8-2 to 6.8.0-7 (wrong version info 6.8.0-6): used here, should work
> 6.7.6-0 or lower: will fail due to incompatibilities
> 7.0.0.0 alpha: untested ('magick' is used instead of 'convert')
> 
> Tested on Windows7 64bit and Debian 6.0.5-i386 (IM compiled from source)
> 
> 
> Happy TeXing!
> 
> 
> Peter
> <rotate.pdf>___________________________________________________________________________________
> 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  : http://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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: drops module (draft)
  2012-12-07 18:02 ` Otared Kavian
@ 2012-12-07 20:53   ` Hans Hagen
  2012-12-08 13:03   ` Peter Rolf
  1 sibling, 0 replies; 16+ messages in thread
From: Hans Hagen @ 2012-12-07 20:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Otared Kavian

On 12/7/2012 7:02 PM, Otared Kavian wrote:
> Hi Peter,
>
> Thank you for your very nice module.
> For your information, I wanted just to report an issue I noticed with Adobe Reader (Version: 11.0.0 (11.0.0)) on Mac OS X 10.8: when I try to open the file « pile.pdf » (which is in your « examples » directory) Adobe Reader crashes and there is no way to open that file with it. However th eother file, « rotate.pdf » opens without any problem…

I Noticed the same on Windows 8 / Acrobat 11.0 so it's in the pdf.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: drops module (draft)
  2012-12-07 18:02 ` Otared Kavian
  2012-12-07 20:53   ` Hans Hagen
@ 2012-12-08 13:03   ` Peter Rolf
  1 sibling, 0 replies; 16+ messages in thread
From: Peter Rolf @ 2012-12-08 13:03 UTC (permalink / raw)
  To: ntg-context

Hi Otared,

thanks for the report. No problems here with my old Acrobat Pro 9.52
(syntax checks shows no errors) or PDF-XChange Viewer 2.5 on Windows7
Ultimate 64-bit.

You can try to compile it on your machine (full source is included), if
you have a recent IM version installed. Sorry, I can't check it with a
newer Adobe version (parallel installation messes up the system and a
installation in a VM does not work).

I guess it's more a problem of the actual viewer (11), than a problem
with the PDF. Still annoying.


Best wishes,  Peter


Am 07.12.2012 19:02, schrieb Otared Kavian:
> Hi Peter,
> 
> Thank you for your very nice module.
> For your information, I wanted just to report an issue I noticed with Adobe Reader (Version: 11.0.0 (11.0.0)) on Mac OS X 10.8: when I try to open the file « pile.pdf » (which is in your « examples » directory) Adobe Reader crashes and there is no way to open that file with it. However th eother file, « rotate.pdf » opens without any problem…
>
> Best regards: OK
> 
> On 6 déc. 2012, at 18:08, Peter Rolf <indiego@gmx.net> wrote:
> 
>> Hi all,
>>
>> a first version of the 'drops'-module (MkIV only) is available at
>>
>> https://www.wuala.com/indiego/public/ConTeXt/drops/?key=caiCGLasLFmJ
>>
>>
>> Taken from the included documentation..
>> [..]
>> 'drops' is a small extension for ConTeXt, that allows you to add drop
>> shadows to rectangular regions (so called boxshadows). A working
>> installation of ImageMagick (IM) is required to create the shadow
>> graphics. The supported color spaces are CMYK, RGB and Gray, the file
>> formats are limited to PNG and JPG.
>> [..]
>> Read the manual for detailed information.
>>
>> The attached example is just a small test file for the 'rotation'
>> parameter (a compensation for the object rotation, so that the shadow
>> stays at the given direction). You will find other examples in the
>> documentation and there is also a 'pile' example with the complete
>> source. The 'presets' pdf contains the predefined setups for different
>> shadow (or frame) types and it's source is a good starting point for
>> your own experiments.
>>
>> This is a first draft, but most things work quite stable. If you want to
>> help, test as much as possible. :-)
>>
>> *You need a recent version of ImageMagick for this module.*
>>
>> 6.7.8-2 to 6.8.0-7 (wrong version info 6.8.0-6): used here, should work
>> 6.7.6-0 or lower: will fail due to incompatibilities
>> 7.0.0.0 alpha: untested ('magick' is used instead of 'convert')
>>
>> Tested on Windows7 64bit and Debian 6.0.5-i386 (IM compiled from source)
>>
>>
>> Happy TeXing!
>>
>>
>> Peter
>> <rotate.pdf>___________________________________________________________________________________
>> 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  : http://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  : http://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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2012-12-08 13:03 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-06 17:08 drops module (draft) Peter Rolf
2012-12-06 18:05 ` Aditya Mahajan
2012-12-06 18:18   ` Wolfgang Schuster
2012-12-07 12:01     ` Peter Rolf
2012-12-07 12:57       ` Wolfgang Schuster
2012-12-06 18:35   ` Marco
2012-12-06 19:46     ` Hans Hagen
2012-12-07 12:04     ` Peter Rolf
2012-12-07 12:49       ` Marco Patzer
2012-12-07 13:27         ` Peter Rolf
2012-12-06 19:05   ` Hans Hagen
2012-12-06 19:44   ` Hans Hagen
2012-12-07 11:59   ` Peter Rolf
2012-12-07 18:02 ` Otared Kavian
2012-12-07 20:53   ` Hans Hagen
2012-12-08 13:03   ` Peter Rolf

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