Reply to topic  [ 5 posts ] 
Paragraph shading 
Author Message

Joined: 2007-04-12 14:59:36
Posts: 229
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.


2014-01-19 05:07:57
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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.

_________________
philip


2014-01-19 05:47:46
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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

_________________
philip


2014-01-19 06:28:06
Profile

Joined: 2007-04-12 14:59:36
Posts: 229
Thank you.
I did not understand that "color" as argument of ShadingAttributes can't be a simple color name like "yellow"


2014-01-19 15:53:21
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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:

_________________
philip


2014-01-19 17:40:02
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software