Sg2.9
Control Calligraphic Thickness
Recent RSS
Control Calligraphic Thickness
From:  Squis
Date:  3. February 2007, 22:58

Something I have been missing in AI: The possibility to retroactively control the thickness of calligraphic brush strokes. NOT with just a stylus, but tweaking the width of specific portions of a stylus-drawn stroke AFTER it has been drawn. Either with point-for-point control, or something more generic: "Start thin, go wide in the middle, end thin again".

That's what I've been dreaming of.

Re: Control Calligraphic Thickness
From:  Jürg Lehni
Date:  1. March 2007, 16:28

Hi Alex,

I don't have a tablet here right now, but here a bit of insight into the format:

The array returned by path.tabletData contains values of the type TabletValue (so far not documented in the Reference). This is a simple object with two fields: offset and value.

Offset is a value between 0 and 1, with 0 being the beginning of the path, and 1 the end. The range for value also goes from 0 to 1.

When retrieving tabletData, you get an array containing these objects. When setting, you can also directly set a two dimensional array, which is then internally converted to TabletValues:

path.tabletData = [[0, 0], [0.5, 1], [1, 0]];

This creates a ramp from 0 to 1 in the middle and back to 0 at the end.

And there are two requirements that you should meet:

  • The values should allways have a first object with offset 0 and a last one with offset 1.
  • There should not be more than a certain amount of pairs. I am not sure if I remember correctly, but thought it was 128, or 256. Maybe it is more.

Also, it is good to know that when you cut a path, the tabletData array gets split at the right place automatically for you, and the offset values are ajusted accordingly.

Re: Control Calligraphic Thickness
From:  alex
Date:  1. March 2007, 16:35

Juerg - Many thanks.

Re: Control Calligraphic Thickness
From:  Hiroyuki Sato
Date:  4. March 2007, 05:34

>Lehni
I've realized I was misunderstanding the usage of setTabletData.
Setting it with an array seems to work fine!

>alex
I put a file containing a tablet-drawn brush path at here.
http://park12.wakwak.com/~shp/lc/et/tabdatasample_cs.zip

This file was saved with CS.
Sorry for being late. I was hesitating to upload a file
just because I don't have CS2.

Re: Control Calligraphic Thickness
From:  alex
Date:  5. March 2007, 06:43

Hiroyuki-

Much appreciated, but I'd already come to the same conclusion.. An array works just great for setting data!

I'm out looking for work across the next few days, but I'll post my code when I get a chance to clean it up. Here's a snapshot of my current results:

http://bigblackwood.googlepages.com/hst.gif

Re: Control Calligraphic Thickness
From:  Jürg Lehni
Date:  5. March 2007, 10:28

Alex, wow! That looks very promising. It's a great idea to use the stroke variation for a arster in that way. I have a raster script here that does a similar thing, but with a stroke based raster cell that is duplicated and then varied in density.

I'm looking forward to seing more!

Re: Control Calligraphic Thickness
From:  Squis
Date:  9. March 2007, 14:58

So would there be a possibility to apply tabletData / line thickness from one line to another?

Say I've got a line drawn with the pencil-tool, with all bezier-points arranged exactly the way I want them. Then I do a few brush-swipes and apply the line-thickness of the nicest brush-stroke to the pencil-line. Thus I get a naturally looking brush stroke along the right path.

Re: Control Calligraphic Thickness
From:  Ricardo
Date:  12. March 2007, 22:11

Alex
actually what you are developing is one of my wishes, until now the only way i'm doing that is in Photoshop by changing Mode to> bitmap then> Halftonescreen> line...so on. But the final image doesn't work for cutter or plotter cutting.

I'm looking forward to seing more too!

Re: Control Calligraphic Thickness
From:  alex
Date:  13. March 2007, 23:11

Squis: That shouldn't be too hard. You'd have to approximate the length of the 'target' line with your tablet-drawn line if you don't want a stretched result. Just select both lines, have a script identify one as the target, one as donor and set:

target.tabletData = donor.tabletData;

Ricardo: I hear ya. I'd been through the same trouble with custom halftones for some time. I still use your solution for some jobs though... Photoshop has an excellent halftone algorithm after all. I take the image into grayscale, jack up the resolution to 1200 or so, and convert to Bitmap with the appropriate halftone. Then turn the channel to a selection, and convert that to a path. Export the path to Illustrator, and you're set. It's not super precise, but it can give very good results with a plotter/cutter.

I'm trying to nail down a couple more features for my script, but I should have it posted within the week. For now here's the result of some more testing and its partial outlines:

http://bigblackwood.googlepages.com/AM-BW.png
http://bigblackwood.googlepages.com/outlines.png

Re: Control Calligraphic Thickness
From:  Squis
Date:  21. March 2007, 06:45

Nope, just isn't working. Hiroyuki's script causes my Illustrator to crash. I tried reconstructing a simplified script myself:

var pathes = activeDocument.getMatchingItems(Path,{selected: true});
if (pathes.length > 0){
activeDocument.getSelectedItems()[1].tabletData = activeDocument.getSelectedItems()[0].tabletData;
}

Doesn't work and causes Illustrator to crash as well. I've tried things like

activeDocument.getSelectedItems()[1].tabletData = activeDocument.getSelectedItems()[0].getTabletData();

and

activeDocument.getSelectedItems()[1].setTabletData(activeDocument.getSelectedItems()[0].getTabletData);

Sometimes it works and sometimes it doesn't, but it always causes the program to crash. Sometimes the program waits for me to draw another line and then crashes.

Is there some basic scripting rule I need to follow? Does Scriptographer not work with the Tryout version of CS2? Is there a more stable version of Scriptographer I can download?

Re: Control Calligraphic Thickness
Date:  21. March 2007, 19:22

This isn't a fix, but for clarity: the things you tried are basically all the same.
I tend to find it clearer not to use the getters and setters:

var selItem = activeDocument.getSelectedItems()[0];

is the same as

var selItem = activeDocument.selectedItems[0];

and

activeDocument.selectedItems[0].setTabletData(data)

is the same as

activeDocument.selectedItems[0].tabletData = data
Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
L-System 26.10.11