grc2coreGrc Showcase

Experimental projects, hacks, and other exploration of what is possible with SuperCard. Graphic files and .zip archives only.
Forum rules
Help keep this area clean by deleting attachments from existing posts that have been updated, or are no longer relevant.

grc2coreGrc Showcase

Postby LorenzT » Tue Jan 11, 2011 3:21 pm

This project contains a function that converts SC grcs to smooth Core Graphics (Quartz). All you need to do is pass the name of the grc and additional parameters like lineWidth, shadow, alpha transparency and rotation to get a smooth coreGrc in the place of a SC grc. And best of all, you get this without learning the complex Core Graphics lingo.
With additional functions arrows, stars, triangles and gradients can be generated.

grc2coreGrc-Showcase, Version 1.1.1, Mar 16, 2011
- functions for axial and radial gradients added (with SC 4.7.1 gradients that can be applied to backdrops)
- example for Core Graphics pie chart

Acknowledgement: This function could not have been written without the CG XFcn external and the outstanding Quartz Explorer project by Ian Bridges.
Attachments
grc2coreGrc_1.1.1.zip
(1.35 MiB) Downloaded 286 times
Last edited by LorenzT on Thu Mar 17, 2011 9:11 am, edited 14 times in total.
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Playground - Polygon

Postby sctell » Wed Jan 12, 2011 1:05 am

Hi Lorenz,


I started getting SuperTalk Error Number 14 : string longer than 255 characters when I tried to increase the shadow.

I then cancelled the error.

This then led to SuperTalk Error Number 11: Can't find button field or graphic when I clicked on Show coreGrc.

I am using SC 4.6.3


Terry
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: grc2coreGrc Playground - Polygon

Postby LorenzT » Wed Jan 12, 2011 4:56 am

Hi Terry
You can only increase the shadow by editing the script of the project and by changing the parameters in the handler 'on cgShadow' in the line get CG("setShadow","5,-5,5"). The first parameter is the x-offset of the shadow, the second the y-offset and the third is a blur value.
What value(s) did you use for the shadow?

Or did you change the lineWidth parameter by editing the text field? Apparently I left a handler in the script of that field that doesn't belong there.

Thanks for your feedback. I will soon post a more powerful version.
Lorenz
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Playground - Polygon

Postby sctell » Wed Jan 12, 2011 7:17 am

Hi Lorenz,

Silly me, I meant I clicked on line width and got the error. See the attached image.


Terry


Screen shot .png
Screen shot .png (56.39 KiB) Viewed 8518 times
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: grc2coreGrc Playground - Polygon

Postby LorenzT » Wed Jan 12, 2011 8:27 am

Oh, I'm using SC 4.7 and in this version the 'do' command digests more characters than SC 4.6.x

From the addendum to SC 4.7:
do - Expanded from 255 character limit to 1024 keywords

I'll check what I can do about that, I guess I have to split that up in smaller chunks...
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Playground - Polygon

Postby LorenzT » Wed Jan 12, 2011 12:30 pm

I just replaced the project with a fixed project that is compatible with SC 4.6+
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Playground - Polygon

Postby sctell » Thu Jan 13, 2011 11:53 am

Hi Lorenz,

The errors have now gone away.

Could you answer a question please.

As you decrease the line width from 10 down to 0 the opacity of the line seems to reduce.

Is that correct and how you intended it to work.

The blue line is bright at 10 and dim at 0.

--Terry
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: grc2coreGrc Playground - Polygon

Postby LorenzT » Thu Jan 13, 2011 1:54 pm

The Core Graphics are generated by the cg XFcn.They are anti-aliased and displayed in a png graphic. If I compare the graphics I get with grc2coreGrc with graphics in apps like Pages I can't see a difference. Because of the anti-aliasing lines with lineWidth <=1 pixel seem to be dimmed. Maybe that's why the lineWidth in the mentioned app defaults to 2.
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Playground - Polygon

Postby LorenzT » Thu Jan 13, 2011 3:00 pm

I just finished a new Playground!
You can find it in the first post of this thread. The new playground works with: lines, polygons, rectangles, ovals, roundRects, arcs and text grcs. And some objects you can even rotate.
Scripting the conversion of the arcs was especially difficult since SC arcs start from North and go clockwise and Core Graphics start East and go counter clockwise. Furthermore the scaling of arcs that are a segment of a circle to arcs that are a segment of an oval almost drove me nuts.

Enjoy the new Playground!
Next on my list are alpha transparencies and rotation...
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Playground - Polygon

Postby sctell » Fri Jan 14, 2011 6:51 am

Lorenz,

Keep up the good work.

I did notice that if you click repeatedly in quick succession on the stepper buttons, for example line width or rotate, the click does not always register.

I presume this is because of the calls to the external consuming time before returning control to SuperCard.

Is there anyway around this problem?

It would certainly detract from using the external in a situation where user experience was essential.

--Terry
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: grc2coreGrc Playground - Polygon

Postby LorenzT » Fri Jan 14, 2011 9:26 am

You don't need to click repeatedly on those buttons as there is a mouseStillDown handler that increases or decreases the value in the field. Only when you release the btn a mouseUp handles triggers the redrawing of the coreGrc. Anyway the next version will have sliders to change values.

The normal situation where you can use the grc2coreGrc function is when you want to generate some fancy graphics with a script. You proceed as usual by scripting your SC grc. You create a new grc and after you have finished what you can do in SC you call the grc2coreGrc function to add anti-aliasing, shadow and rotation.
E.g. grc2coreGrc(cd grc myNewGrc,0.5,shadow,1,30) will draw your SC grc with all the properties you defined in SC (dimensions, color etc.) and will apply lineWidth 0.5, shadow, alpha transparency 1 and rotation of 30 degrees. That's it (alpha not yet implemented, always use 1 for alpha).
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Playground

Postby LorenzT » Wed Jan 19, 2011 7:40 am

I just posted the most recent develoment stage of the grc2coreGrc function (see first post of this thread).
All SC grcs can now be converted to smooth Core Graphics and you can adjust several specs (shadow, alpha, rotation) of the graphics with sliders.
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby LorenzT » Mon Jan 24, 2011 8:16 am

Version 1.0 of the grc2coreGrc-function is out now and the updated showcase shows many possibilities of the function. There is also a new function 'cgStars' that will create star shaped core grapics as I thought it would make sense to build up a library of often used shapes. Please report issues you might run into by using this function.
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Mon Jan 24, 2011 9:39 am

My thanks to you Lorenz and to Ian as well as David & Terry; from my vantage I see a lot of synergism in action.

Lorenz, I have not had much time to use your tool but I see it's great utility intergrated into SuperCard.

...I thought it would make sense to build up a library of often used shapes.

arrows would be a great addition
-Dan
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: grc2coreGrc Showcase

Postby LorenzT » Tue Jan 25, 2011 1:41 am

arrows would be a great addition

Yes, arrows (and triangles) are on the front burner now.
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Thu Jan 27, 2011 10:03 am

just came across these nice arrows with a bezier-polygon-ish-twist that convey dynamism and like Bernie's Tangerine tool, does not take up much real estate.
drug targeted pathways_sml.jpg
drug targeted pathways_sml.jpg (20.34 KiB) Viewed 8361 times
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: grc2coreGrc Showcase

Postby LorenzT » Thu Jan 27, 2011 3:02 pm

Dan, those are really very fancy arrows! I'm sure it could be done but I'am already happy to provide straight but scriptable arrows that can have shadows, transparency, can be rotated and that point to a given loc.
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Thu Jan 27, 2011 7:43 pm

Hi Lorenz,
That would be great.
I just thought people might like to see the others; when I saw them I liked them so much.
-Dan
User avatar
Dan_Kelleher
 
Posts: 438
Joined: Sun Jul 06, 2008 2:45 pm
Location: Worcester (wouster as in would) Massachusetts USA

Re: grc2coreGrc Showcase

Postby LorenzT » Fri Jan 28, 2011 3:03 am

I just posted version 1.0.1
In this version there are seperate functions for stars, triangles and arrows.
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Fri Jan 28, 2011 6:23 am

Lorenz,
As Grant would have said (thanks Joe), thats a "Gem".
Right into my Lorenz Tchudi folder.
Thank you,
-Dan
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: grc2coreGrc Showcase

Postby LorenzT » Sun Jan 30, 2011 9:13 am

Dan, I'm glad that you like this!
In the next release there will be a function for gradients.
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Sun Jan 30, 2011 10:21 am

Nice.
I work from time to time on getting comfortable with David's BezierPolgon tool but it's going to be a while before I get back to it. I enjoyed seeing your picture on your home page. I thought you were much older! :)
Enjoy,
Dan
User avatar
Dan_Kelleher
 
Posts: 438
Joined: Sun Jul 06, 2008 2:45 pm
Location: Worcester (wouster as in would) Massachusetts USA

Re: grc2coreGrc Showcase

Postby gonetriadrr » Thu Feb 03, 2011 7:55 am

Dan_Kelleher wrote:Nice.
I work from time to time on getting comfortable with David's BezierPolgon tool but it's going to be a while before I get back to it.


The adobe type 1 font specification includes a primer on drawing with cubic beziers. Essential reading. Downloadable as pdf from the adobe site.

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

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Thu Feb 03, 2011 10:02 am

Thank you. I will.
Your instructions are AOK too.
Thank you for taking the time to write them. I realize it's a pain.

I just need time to practice all the selection mechanisms you provide.
I understand how valuable and essential it is to be able to make such specific selections.
My plan was to write for myself some clear instructions (just focusing on making those conditional selections) and to then send it to you thinking it might help you, having gotten that aspect described all in one place.
Alas, I'm off in other directions, but it's not out-of-mind.
-Dan
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: grc2coreGrc Showcase

Postby Dan_Kelleher » Thu Feb 03, 2011 10:33 am

Not exactly sure which primer you meant but I found this:

http://help.adobe.com/en_US/aftereffect ... 05B0a.html

from this search result:

http://community.adobe.com/help/search. ... x=0&go.y=0

(Type 1 font specfications gets a lot or hits at Adobe!)
User avatar
Dan_Kelleher
 
Posts: 438
Joined: Sun Jul 06, 2008 2:45 pm
Location: Worcester (wouster as in would) Massachusetts USA

Next

Return to The Lab

Who is online

Users browsing this forum: No registered users and 1 guest