nisus.com
https://www.nisus.com/forum/

Paragraph shading
https://www.nisus.com/forum/viewtopic.php?f=17&t=5608
Page 1 of 1

Author:  js [ 2014-01-19 05:07:57 ]
Post subject:  Paragraph shading

I wonder how Paragraph Shading can be applied via a macro to paragraphs with a selection.
I fear did not understand how to use the commands given in the Macro help file.

Author:  phspaelti [ 2014-01-19 05:47:46 ]
Post subject:  Re: Paragraph shading

I thought that I had written a macro to do such a thing, but I can't find it. So maybe I was just imagining things. I was probably thinking about Table cells.

The fact is that attributes are still very much a step-child in Nisus' macro language. They can't be created, and attribute objects retrieved from the text can't be changed, or applied to other selections. There is an ".addNewStyle" command (for document objects) which takes an attribute object as argument, but that's about it.

One would hope that a future update would add some commands like:
Code:
Attributes.new [attribute list]
Selection.apply [attributes object]

but at this point this is just a wish.

Author:  phspaelti [ 2014-01-19 06:28:06 ]
Post subject:  Re: Paragraph shading

Ok, so maybe I wasn't imagining things.
If you look in the macro reference in the section "Formatting Text" you will find the following:
Code:
Set Paragraph Shading Attributes shadingAttrs


So there you have it.

Here's a code example:
Code:
$lightGray = Color.newWithHexTriplet 'CCCCCC'
$shade = ShadingAttributes.newWithSolidColor $lightGray
Set Paragraph Shading Attributes $shade

Author:  js [ 2014-01-19 15:53:21 ]
Post subject:  Re: Paragraph shading

Thank you.
I did not understand that "color" as argument of ShadingAttributes can't be a simple color name like "yellow"

Author:  phspaelti [ 2014-01-19 17:40:02 ]
Post subject:  Re: Paragraph shading

js wrote:
Thank you.
I did not understand that "color" as argument of ShadingAttributes can't be a simple color name like "yellow"

Indeed. The extra step needed to use color in any command is a bit of a bother. And the shading attributes object command ".newWithBlendColors" requires two colors.
For this reason I usually use ".newWithPatternType" with argument 'Blend', but then you still need to set the blend ratio separately.
Code:
$shade = ShadingAttributes.newWithPatternType 'Blend'
$shade.blendRatio = 0.25
Set Paragraph Shading Attributes $shade

Well, we can achieve what we want, so we're not complaining, we're not complaining… :wink:

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/