THGraphics External

Here is where the magnanimous folks that create externals post them (.zip archives only please).

Re: THGraphics External

Postby gonetriadrr » Sat Apr 23, 2011 12:08 pm

Hi Terry,
I'm curious if there are strokeFill & fillStroke methods available.
Is it true that applying fill and stroke separately causes shadows to be rendered separately as well... causing darkening where the shadows overlap?

I have confirmed an issue with antialiasing and my attempt to create path based shaped blends with transparency.
A nearly fully transparent hairline occurs between each path. I may be able to work around by stroking each by half a pixel. Hope to post an update of BezierPen to demonstrate the issue in a few days.

Also wondering if it might be possible to specify a NS style rect to fill with an image/image file?

Of course, beggars can't be choosers :D
Thanks!
DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

Re: THGraphics External

Postby sctell » Fri Apr 29, 2011 11:56 pm

gonetriadrr wrote:I'm curious if there are strokeFill & fillStroke methods available.


I will look into this. They do not exist in NSBezierPath.
They do exist in core graphics. These are the options

kCGPathFillStroke
First fill and then stroke the path, using the nonzero winding number rule.

kCGPathEOFillStroke
First fill and then stroke the path, using the even-odd rule.

There does not appear to be a strokeFill option.

It may be possible to replicate them.

gonetriadrr wrote:Is it true that applying fill and stroke separately causes shadows to be rendered separately as well... causing darkening where the shadows overlap?


Yes, I believe you just need to be careful of the order in which you carry things out.
If you provide a simple example script I can see if we can work around this.

gonetriadrr wrote:I have confirmed an issue with antialiasing and my attempt to create path based shaped blends with transparency.
A nearly fully transparent hairline occurs between each path. I may be able to work around by stroking each by half a pixel. Hope to post an update of BezierPen to demonstrate the issue in a few days.


I have not come across this.
Could you provide a simple example script.

gonetriadrr wrote:Also wondering if it might be possible to specify a NS style rect to fill with an image/image file?


Not exactly sure what you are after.
As the canvas is NSImage based it is straightforward to place an image into the canvas. Can you specify a little more what you want.
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THGraphics External

Postby sctell » Sat Apr 30, 2011 12:08 am

gonetriadrr wrote:Is it true that applying fill and stroke separately causes shadows to be rendered separately as well... causing darkening where the shadows overlap?


Hi,

Just been reading the docs to remind myself.

Here is a quote from Apple's docs on this subject:

Shadow effects are stored as part of the graphics state, so once set, they affect all subsequent rendering commands in the current context. This is an important thing to remember because it might force you to think about the order in which you draw your content. For example, if you set up a shadow, fill a path, and then stroke the same path, you do not get a single shape with an outline, fill color, and shadow. Instead, you get two shapes—an outline and a fill shape—and two shadows, one for each shape. If you stroke the path after filling it, the shadow for the stroked path appears on top of the filled shape. In Figure 8-1, the desired effect was achieved by applying the shadow to only the fill shape of each path.


You can read up on it here:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaDrawingGuide/AdvancedDrawing/AdvancedDrawing.html
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THGraphics External

Postby gonetriadrr » Sat Apr 30, 2011 6:40 pm

sctell wrote:
gonetriadrr wrote:I'm curious if there are strokeFill & fillStroke methods available.


I will look into this. They do not exist in NSBezierPath.
They do exist in core graphics. These are the options

kCGPathFillStroke
First fill and then stroke the path, using the nonzero winding number rule.

kCGPathEOFillStroke
First fill and then stroke the path, using the even-odd rule.

There does not appear to be a strokeFill option.

It may be possible to replicate them.

Being able to define the winding rule as path is painted would be a real benefit.
I must have run across 'strokeFill' while looking over some postscript docs.

gonetriadrr wrote:Is it true that applying fill and stroke separately causes shadows to be rendered separately as well... causing darkening where the shadows overlap?


Yes, I believe you just need to be careful of the order in which you carry things out.
If you provide a simple example script I can see if we can work around this.

gonetriadrr wrote:I have confirmed an issue with antialiasing and my attempt to create path based shaped blends with transparency.
A nearly fully transparent hairline occurs between each path. I may be able to work around by stroking each by half a pixel. Hope to post an update of BezierPen to demonstrate the issue in a few days.


I have not come across this.
Could you provide a simple example script.
[/quote]

The latest BezierPen project update includes ready to render example. The announcement post includes a rendered example png. The antialiasing induced lines of increased transparency are evident in that png.
I'm not sure disabling antialiasing would solve the issue, and haven't taken time to test with antialiasing off via python quartz bridge yet. But i will.

gonetriadrr wrote:Also wondering if it might be possible to specify a NS style rect to fill with an image/image file?


Not exactly sure what you are after.
As the canvas is NSImage based it is straightforward to place an image into the canvas. Can you specify a little more what you want.[/quote]

To avoid tiling using the fillwithpatternfile operator, i use the image/imageFile external to scale/rotate/crop the image to properly position the image within the canvas relative to the specific path that is to be filled.
I can live with this.
Though it would be nice to simply supply an origin & size parameters to position the image within the canvas.
I realize this probably means rolling in a subset of the image external.
And, would be a little use to the average user, unless there is also a method to get the bounds of a path.

Just food for thought.

Thanks!
DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

Re: THGraphics External

Postby sctell » Mon May 02, 2011 5:01 am

Hi,

I have just posted an update that implements the additional function:

get THGraphics("setShouldAntialias","true") or false

This turns on/off the antialiasing of the bezier path for the primitive routines only.
Also, it does not apply to the drawing of text.

Once antialiasing is turned off (false) all drawing via the primitive routines is affected until you set it to true.

It affects the following calls:

stroke
fill
fillRect
strokeRect
strokeLineFromPointToPoint
clipImage
clipImageFile
linearGradientInPath
radialGradientInPath
fillPathWithPattern
fillPathWithPatternFile
strokePathWithPattern
strokePathWithPatternFile

The update can be found in the first post of this thread.
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THGraphics External

Postby sctell » Mon May 02, 2011 11:53 am

gonetriadrr wrote:Though it would be nice to simply supply an origin & size parameters to position the image within the canvas.
I realize this probably means rolling in a subset of the image external.


So, you want to take an image, and place it into a rect (x,y,w,h) of the canvas?

I presume you can use the image external to do all the manipulation, send it back to SC as a var then just import it onto the THGraphics external canvas?

or

Save the file from the image external as tif or other then import the file onto the THGraphics external canvas?

I could incorporate either or both of the above as:

get THGraphics("importImage",imageVar,"x,y")
get THGraphics("importImageFile",imagePath,"x,y")

When I create an image with NSImage using the path or var the NSImage knows the size so it should only be necessary to place(draw) it into the canvas.

Is this what you want?
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THGraphics External

Postby gonetriadrr » Tue May 03, 2011 3:26 am

sctell wrote:
gonetriadrr wrote:Though it would be nice to simply supply an origin & size parameters to position the image within the canvas.
I realize this probably means rolling in a subset of the image external.


So, you want to take an image, and place it into a rect (x,y,w,h) of the canvas?

I presume you can use the image external to do all the manipulation, send it back to SC as a var then just import it onto the THGraphics external canvas?

or

Save the file from the image external as tif or other then import the file onto the THGraphics external canvas?

I could incorporate either or both of the above as:

get THGraphics("importImage",imageVar,"x,y")
get THGraphics("importImageFile",imagePath,"x,y")

When I create an image with NSImage using the path or var the NSImage knows the size so it should only be necessary to place(draw) it into the canvas.

Is this what you want?


Yes, the ability to specify the origin alone will do quite nicely. I presume x,y will be topleft coordinate.
I'm taking taking the file route rather than variables at this point.

Thanks!
DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

Re: THGraphics External

Postby gonetriadrr » Tue May 03, 2011 3:35 am

thGraphics & printing quality...

Terry, have you looked into pdf output.
If a means is not provided to output to pdf (or postscript) preserving vector path definitions, i would be very surprised.

DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

Re: THGraphics External

Postby sctell » Wed May 04, 2011 9:22 am

Hi,

I have just posted an update for this external that adds two additional functions.

These are:
-----------
get THGraphics("importImageFile",tPath,"tX,tY")

tPath is a POSIX path
tX and tY are the topleft coordinates of the imported image on the canvas
-----------
get THGraphics("printImage")

Shows the page layout panel, print panel and a progress panel.
-----------

The update is attached to the first post of this thread.
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THGraphics External

Postby sctell » Wed May 04, 2011 10:16 am

gonetriadrr wrote:thGraphics & printing quality...


It seems the answer is quite simple really as previously suggested the image is being created at 72dpi (screen).

I just did an experiment where I resized the canvas by a factor of 4.166 (4.166 * 72 = 300 dpi)

I also increased the font sizes of text by a similar factor (4.166) and when I printed the image (scaled to fit) the text clarity was perfect.

I am not sure yet if this is the correct way to do these things but it worked.
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THGraphics External

Postby gonetriadrr » Wed May 04, 2011 11:36 am

sctell wrote:
gonetriadrr wrote:thGraphics & printing quality...


It seems the answer is quite simple really as previously suggested the image is being created at 72dpi (screen).

I just did an experiment where I resized the canvas by a factor of 4.166 (4.166 * 72 = 300 dpi)

I also increased the font sizes of text by a similar factor (4.166) and when I printed the image (scaled to fit) the text clarity was perfect.

I am not sure yet if this is the correct way to do these things but it worked.


That's how photographic/raster images are handled in high-end print.
Still seems to me that all those bezier path commands are too similar to postscript for there not to be a method for spitting out those vectors to what would result in a resolution independent pdf.
Res'ing up raster data is very inefficient if printer or file format (like pdf) can handle postscript directly.

DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

Re: THGraphics External

Postby gonetriadrr » Wed May 04, 2011 11:43 am

sctell wrote:Hi,

I have just posted an update for this external that adds two additional functions.

These are:
-----------
get THGraphics("importImageFile",tPath,"tX,tY")

tPath is a POSIX path
tX and tY are the topleft coordinates of the imported image on the canvas
-----------
get THGraphics("printImage")

Shows the page layout panel, print panel and a progress panel.
-----------

The update is attached to the first post of this thread.


Thanks again for the additions!

DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

Re: THGraphics External

Postby sctell » Thu May 05, 2011 6:26 am

Hi,

A small correction the printImage command did not cancel correctly from the page layout panel.

The update is in the first post to the thread.
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THGraphics External

Postby sctell » Wed May 11, 2011 10:39 am

Hi,

An update to incorporate one additional command:

get THGraphics("setTextScale",tScale)

If you wish to scale text and it's coordinates you can use this function.

It should be called before you actually call any text routines.
It scales the coordinates and font point size that you pass in with a draw text routine.
It does not reset and will continue scaling until you set the scale to 1.0.

The routine was added to complement the scalePath routine.

The textBoxSize routine still returns the size associated with the original font size, not the scaled font size.

The update is in the first post of the thread.
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THGraphics External

Postby sctell » Tue May 24, 2011 10:30 am

Hi,
I have just posted an update to this external.

The existing text routines just draw into the canvas.
The two new functions allow for path based text.

get THGraphics("appendPathWithText", tText, tFontName, tFontSize,tPoint, tDegrees,tRotPoint)
This routine converts the text into a path which is added to the current path.

put THGraphics("textPathBounds",tText,tFontName, tFontSize,tPoint) into tPathBounds
This returns the bounds of the text to allow for other calculations you may wish to make.

It is now possible to work with multiple paths. You can save paths to a dictionary (NSDictionary) and save/load the dictionary from disk files.
The available routines are:

get THGraphics("setPathForKey","blueBox")
save the current path to the dictionary with a key "blueBox"

get THGraphics("pathForKey","blueBox")
sets the current path to path "blueBox" ready for stroke, fill etc.

get THGraphics("removePathForKey","redBox")

get THGraphics("removeAllPaths")

get THGraphics("writeDictToFile","/Users/Terry/Desktop/aaaaa")
writes the dictionary to a file at path

get THGraphics("readDictFromFile",tFilePath)
reads the dictionary from a file at path

What information is stored with the path:

the path name eg. "blueBox"
if antiAlias applies
the current line color
the current fill color
the current shadow
if clipping applies
and the path data

The update can be found in the first post of this thread.
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: THGraphics External

Postby gonetriadrr » Tue May 24, 2011 4:21 pm

sctell wrote:get THGraphics("importImageFile",tPath,"tX,tY")

tPath is a POSIX path
tX and tY are the topleft coordinates of the imported image on the canvas
-----------


I have found this feature useful, but not exactly what i expected.

Something more akin to 'fillPathWithPatternFile' with an additional parameter specifying the pattern origin would better suit, and be much appreciated. That is... 'fillPathWithPatternFileAtLoc("pathParam","x,y")' or whatever.
Might provide some animation opportunities as well.

Thanks!
DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

Re: THGraphics External

Postby gonetriadrr » Tue May 24, 2011 4:30 pm

Terry,
Looking forward to adopting latest additions. Though have little time to script until the fall.

DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

Re: THGraphics External

Postby gonetriadrr » Thu Oct 06, 2011 10:36 am

Preparing to get back to a long winter's scripting, but looks like the download link in first post of this thread has gone bad.

DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

Re: THGraphics External

Postby Dan_Kelleher » Thu Oct 06, 2011 1:21 pm

I think you mean a the link to <ThGraphics.zip>
I think Terry sent a msg somewhere here saying that he was moving that (and others?) to his site:
<http://www.theaford.co.uk/>
Daniel.Kelleher@umassmed.edu
SC4.7.3 OSX 10.7.2 Mac Pro
User avatar
Dan_Kelleher
 
Posts: 438
Joined: Sun Jul 06, 2008 2:45 pm
Location: Worcester (wouster as in would) Massachusetts USA

Re: THGraphics External

Postby gonetriadrr » Fri Oct 14, 2011 7:34 am

Dan_Kelleher wrote:I think you mean a the link to <ThGraphics.zip>
I think Terry sent a msg somewhere here saying that he was moving that (and others?) to his site:
<http://www.theaford.co.uk/>


Got it!
Thanks Dan.

DCS
gonetriadrr
 
Posts: 170
Joined: Fri Jan 08, 2010 6:50 pm

Re: THGraphics External

Postby Randall Lee Reetz » Thu Jan 08, 2015 8:48 am

No linked file? Where is the external?
What matters is what matters, knowing what matters and how to know it, matters the most.
Randall Lee Reetz
 
Posts: 65
Joined: Fri Mar 07, 2014 3:29 pm

Re: THGraphics External

Postby sctell » Thu Jan 08, 2015 11:07 am

Randall Lee Reetz wrote:No linked file? Where is the external?


It's now in the first post of this thread.
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Previous

Return to XCmds, XFcns, and XRtns

Who is online

Users browsing this forum: No registered users and 1 guest

cron