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.

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Fri Feb 11, 2011 11:54 am

Lorenz-
Regarding your, "grc2coreGrc - Showcase" project utilizing the power of Ian's CG XFcn
I think it might be a good idea to put empty into cd fld "dObject" of the palette wd "Color Picker".

Although the field is not visible in the palette wd, the path being there triggers the opening of a Finder window (see the screenshot attached). Leaving it blank prevents this in this project showcase.

Although the color picker is not functional either way, since the tool of wd "grc2coreGrc - Showcase" is never "pointer" which is necessary for selection of any object, I think it's still nice to have the Color Picker present because it helps people imagine possibilities.
-Dan
grc2coreGrc_1.0.1 PickerProb.jpg
grc2coreGrc_1.0.1 PickerProb.jpg (17.69 KiB) Viewed 8387 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 » Fri Feb 11, 2011 2:11 pm

Hi Dan
Yep, thats not good. Thanks for the feedback. I replaced the project with an update.
The Color Picker is only there to be used in the RTE instead of the built in Picker. I prefer my picker since it is in a palette wd and displays a more useful arrangement of the system clut colors.
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Tue Feb 15, 2011 6:53 pm

A SuperCard basics question:
What font Does SC's ScripTracer use to display pictureData exported into a variable?
exp-pictureData-> font in ScripTracer.png
exp-pictureData-> font in ScripTracer.png (27.47 KiB) Viewed 8373 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 codegreen » Tue Feb 15, 2011 8:58 pm

Dan_Kelleher wrote:What font Does SC's ScripTracer use to display pictureData exported into a variable?

The system font (currently Lucida Grande).

-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: grc2coreGrc Showcase

Postby sctell » Wed Feb 16, 2011 12:00 am

Hi,

Is it only 4.7 as I get error "never heard of the function name" whenever I click on the Create coreGrcs button?

It points here:
Code: Select all
-- calculate width even when not all text is shown
put textWidthMax(dObject) into item number(items of dData)+1 of dData



and here when I click the ">" button
Code: Select all
repeat with i=1 to the number of items of dGrcs
show cd grc item i of dGrcs
hide cd grc ((item i of dGrcs)&".coreGrc")
end repeat


and ditto when I press the "<" button

and here when I click the "Show coreGrc" checkBox
Code: Select all
on mouseUp
lock screen

put "myPolygon,myRect,myOval,myRoundRect,myText" into dGrcs


if the hilite of me then
repeat with i=1 to the number of items of dGrcs
hide cd grc item i of dGrcs
show cd grc ((item i of dGrcs)&".coreGrc")
end repeat
else
repeat with i=1 to the number of items of dGrcs
show cd grc item i of dGrcs
hide cd grc ((item i of dGrcs)&".coreGrc")
end repeat
end if
end mouseUp
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: grc2coreGrc Showcase

Postby sctell » Wed Feb 16, 2011 12:02 am

Hi again,

and just one more thing.............

The project would not close "can't find button field or graphic":
Code: Select all
on closeCard

lock screen

put "myPolygon,myRect,myOval,myRoundRect,myText" into dGrcs

repeat with i=1 to the number of items of dGrcs
show cd grc item i of dGrcs
hide cd grc ((item i of dGrcs)&".coreGrc")
end repeat

set the hilite of cd btn "Show coreGrc" to false
end closeCard
sctell
 
Posts: 1128
Joined: Sun Jul 06, 2008 10:41 am

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Wed Feb 16, 2011 8:02 am

Hi Terry,
I see that too.
SC 4.7 is required as Lorenz used at least one function new to SC 4.7.

The FIRST error you report occurs here using SC 4.6.3 because (The textWidthMax function returns the width of the widest line of text in a field or draw text graphic, in pixels.) is new to SC 4.7.

The second error (btn ">") occurs only because the first error has previously occurred.

If you replace the instance of the project where the error occurred with a fresh copy via expansion of the zipped archive, "grc2coreGrc_1.0.4.zip" (from the top of page 1 of this topic) and FIRST click the
btn ">", that error (btn ">") does not occur.

I did not look at the other errs you reported.
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 » Wed Feb 16, 2011 8:58 am

Terry

Re: textWidthMax function only for SC 4.7
I wasn't aware of this, sorry.

You can change the script of the project to make it compatible with SC 4.6.3 by changing the script of the project in the following lines:

Actual version:
-- calculate width even when not all text is shown
put textWidthMax(dObject) into item number(items of dData)+1 of dData
set the width of dObject to textWidthMax(dObject)
-- was: put the width of dObject into item number(items of dData)+1 of dData

You can just comment two lines and uncomment one line to get the following code:
-- calculate width even when not all text is shown (only for SC 4.7)
-- put textWidthMax(dObject) into item number(items of dData)+1 of dData
-- set the width of dObject to textWidthMax(dObject)
put the width of dObject into item number(items of dData)+1 of dData

Or even better: if you do a test for the SC version the code will be ready when you get SC 4.7 ;-)

HTH
Lorenz
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Wed Feb 16, 2011 9:13 am

Why does ascii 32 (space) "appear to act as a line delimiter" when picturedata in a variable enters a text field I've created and when it enters the script tracer's field ?

The active lineDel is "cr" and scripts correctly return only 1 line.

If the lineDel is changed to "space", scripts correctly return 3 lines.

The source file used to set the pictureData of the grc was a screenshot of deskTop used as a "png" file.

(scroll to the bottom of the last(3RD) screenshot attached below)
-Dan


PictureData fld-Geneva FONT.jpg
PictureData fld-Geneva FONT.jpg (56.91 KiB) Viewed 8361 times

PictureData Scrptracer LuGr FONT.jpg
PictureData Scrptracer LuGr FONT.jpg (16.96 KiB) Viewed 8361 times

32 space ACTING AS lineDel.jpg
32 space ACTING AS lineDel.jpg (27.52 KiB) Viewed 8361 times



Code: Select all
on mouseUp
trace
put "" into cd fld 1
put "" into cd fld 2
wait 30

put myRect into dObject
export the picturedata of cd grc dObject into mpiRGBFiCol
put mpiRGBFiCol into cd fld 1

--put line 1 of mpiRGBFiCol into mpiRGBFiCol_ln1 --it is to all one line
--put mpiRGBFiCol_ln1 & cr & cr into cd fld 2

put 0 into tOutPut_LineNumber

put "Char Number " & "  dChar " & "  CharToNum " & "  LorenzNumber" &¬
cr & cr after cd fld 2

repeat for each char dChar in mpiRGBFiCol
add 1 to tOutPut_LineNumber

put "      " & tOutPut_LineNumber & "                " & dChar &¬
"                  " & charToNum(dChar) & "                 " &¬
charToNum(dChar) & cr after cd fld 2
--Try it without the round function to look at the unmolested charToNum(dChar) output

--round(100*charToNum(dChar)/255)/100 & cr after cd fld 2

--NOTE --> the "100* and "/100" forces the round to higher precision
--example 0.27, 0.45, and 0.41 instead of 0,0, and 0
--round(charToNum(dChar)/255) & cr after cd fld 2

if tOutPut_LineNumber = 450 then exit mouseUp-- Lorenz's conditional is,  if "<410 char"...then
end repeat
end mouseUp
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 » Wed Feb 16, 2011 9:35 am

Never mind Terry, I just uploaded a new version that avoids the SC 4.6.3 problem.
Lorenz
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby LorenzT » Wed Feb 16, 2011 9:45 am

@Dan
I think it is because dontWrap is false and then if after a long word there is a space the next 'word' will start on the next line. Try to set dontWrap to true.

Lorenz
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Wed Feb 16, 2011 9:52 am

@Lorenz
I'll try the "dontWrap = true"

Another Question:
RE: "if the number of chars of mpiRGBFiCol < 410 then" in the code below,
why "<410" ?
-Dan

Code: Select all
LINE 209
-- mpiRGBFiCol / ModuloPi-Method / only implemented for rectangles and ovals
  if the pictureData of dObject = true then
    export the picturedata of dObject into mpiRGBFiCol
    if the number of chars of mpiRGBFiCol < 410 then
      put round(100*charToNum(char 216 of mpiRGBFiCol)/255)/100 &comma&¬
        round(100*charToNum(char 217 of mpiRGBFiCol)/255)/100 &comma&¬
        round(100*charToNum(char 218 of mpiRGBFiCol)/255)/100 into mpiRGBFiCol
    else
      put false into mpiRGBFiCol
    end if
  else
    put false into mpiRGBFiCol
  end if
 



--LINE 414 
  -- fill color
      if item 2 of line 3 of dData = "true" then
        put true into dFill
       
        if mpiRGBFiCol <> false then
          put mpiRGBFiCol into dRGBFiCol  -- use mpiRGBFiCol for Fill
        else
          put line (item 3 of line 3 of dData) of the SCClutRGB of this project into dRGBFiCol
        end if
       
        if dAlphaFill <> empty then
          put dAlphaFill into item 4 of dRGBFiCol
        else
          put 1 into item 4 of dRGBFiCol
        end if
      else
        put false into dFill
        -- no fill: alpha=0
        put "0,0,0,0" into dRGBFiCol
      end if
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 codegreen » Wed Feb 16, 2011 9:56 am

Dan_Kelleher wrote:Why does ascii 32 (space) "appear to act as a line delimiter" when picturedata in a variable enters a text field I've created and when it enters the script tracer's field ?

I'm afraid I can only guess at what you're trying to ask here. Do you want to know why the content is wrapping at spaces? And if so, as opposed to what? (i.e., what were you expecting and why?)

-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Wed Feb 16, 2011 10:59 am

OK, thinking about it more, I see I had forgotten that the wrap was WORD wrap rather than character wrap; I was expecting character wrap which I suppose one would have to implement... for special occasions !

Now don't ask me to, "Name one." :)
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 » Wed Feb 16, 2011 12:19 pm

Dan_Kelleher wrote:
Another Question:
RE: "if the number of chars of mpiRGBFiCol < 410 then" in the code below,
why "<410" ?


To display millions of colors MPI sets the pictureData of a grc to a png file with RGB data. MPI does this by 'coloring' a certain number of pixels in the file (btw, this could also be done by coloring just one pixel). And this generated png file is smaller than 410 chars. As I didn't know of any other way to check if there is already a MPI color in a grc I chose to use the file size as I thought that other png data in the pictureData of a grc is larger than this. This however might not work in all cases.

Lorenz
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Thu Feb 17, 2011 8:49 am

I get it.
Thanks Lorenz and Stéphane. We miss you Stéphane.
Millions of colors with transparency and antialiasing is really nice.
(a replete color picker+the Mark->Chilton->Alec PixelColor XFcn + "grc2coreGrc" and the "CG" XFcn")

Also, I enjoyed tracing through the (rectangle-specific) "Create coreGraphic" script on card 3 of wd 1 in your "grc2coreGrc.sc45" Showcase project.

It's helpful in learning how to prepare the ground for using Ian Bridges' "CG" XFcn to render the high-quality core graphics.

It's also been helpful to me in learning some very useful SuperTalk syntax that was not second-nature to me as it is to you, like:

put the bottomleft of dObject into item number(items of dData)+1 of dData
put the width of dObject into item number(items of dData)+1 of dData
put the height of dObject into item number(items of dData)+1 of dData
-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 » Fri Feb 25, 2011 7:43 am

In project grc2coreGrcv_1.0.5, Lorenz is using a version of Ian's "CG" external described as an XFcn.

This version is prior to Stéphane & Ian's incorporation of the ability to directly set (from within the external) the core graphic pictureData of a SuperCard graphic.

In project grc2coreGrcv_1.0.5, the "CG" external returns the core graphic pictureData to a SuperCard variable, "param3" and then the SuperCard "display" syntax is used to set the pictureData of a SuperCard grc.

put empty into param3
get CG("drawImage","data",@param3)
[Snip]
set the pictureData of last grc to display param3 as PNG

@Mark: Is this what is meant by an external being an "XTRn" ( ? my spelling) rather than a XFcn ?

@Lorenz: Was there a reason you used the version of "CG" that you used (79936 bytes) in grc2coreGrc
rather than the enhanced Nov 2007 version (94620 bytes) found in Ian's core graphic's tutorial project, "Quartz Explorer UB2" found within the archive "Quartzify.zip" at Yahoo ?

<http://finance.groups.yahoo.com/group/SuperCard/files/Externals%20%28Universal%20Binary%29/>

-Dan
CG External-Two of several Versions.jpg
CG External-Two of several Versions.jpg (26.31 KiB) Viewed 8330 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 codegreen » Fri Feb 25, 2011 11:45 am

Dan_Kelleher wrote:@Mark: Is this what is meant by an external being an "XTRn" ( ? my spelling) rather than a XFcn ?

XRtns are a shy and elusive species of SuperCard external rarely seen in the wild. Unlike XCmds and XFcns they can register to receive a variety of events from the SC interpreter, and can own their own windows. The RTE's Object Browser is an XRtn...

-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: grc2coreGrc Showcase

Postby LorenzT » Fri Feb 25, 2011 11:58 am

Dan

I wasn't aware of the fact that there was a newer version of the XFcn. As the newer version is faster than the version I used I guess I'll have to to replace the old version. I'm curious to see how much faster the newer version will be...

BTW, this leads me to the question if there is a list or home for the most recent SC externals.

Lorenz
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Fri Feb 25, 2011 12:49 pm

Mark, Thank you for the info about XRtn externals.
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 » Fri Feb 25, 2011 2:48 pm

Lorenz,
...I guess I'll have to to replace the old version

I'd say, not neccessarily;
your grc2coreGrc project is a gem as is and it demonstrates ways of Using the "CG" external that can be very helpful as is.

Slowing-down is more amenable to learning than speed.
I found it helpful to see the "CG" version you used Explicitly return the one value ('pictureData' of the core graphic context or canvas) into the SuperCard Variable as a first step and then the use of the SuperTalk "display" mechanism to set that pictureData as a property of a SuperCard graphic. It's like the essential reductionist approach to understanding a biochemical reaction; isolate and demonstrate the 'half' reactions. We see that a biochemical reaction occurs (ya, fast so?) but to understand it we must take it apart (ScriptTracer guys & gals) and understand it's parts.

The way Ian's core graphic tutorial is written is also a gem and is a quite different Showcase.

The tutorial is in project, "Quartz Explorer UB2" (found within the archive "Quartzify.zip" at the SuperCard Yahoo site)

It is THE place to start to understand how the "CG" external creates Core graphics using OSX Quartz drawing mechanisms compared to SuperCard's QuickDraw-based mechanisms.
The tutorial is so well done that no ScriptTracer is required;
just look at the short scripts for each drawn example and try to understand them one at a time.
The context is the same size in most examples and the bottom left of the context is x,y = 0,0.
The objects are helpfully colored for easy identification and understanding how the code places each object within the context (on the canvas).

It also is a great introduction to both the Simplicity of using the "CG" external from within SuperCard as well as to the many reasons for using it:

• Anti-aliased graphics
• alpha channel support for transparency
• 32 bit RGBA colors
• complex paths of almost any shape
• bezier curves
• stroked, filled, and rotated text
• drop shadows
• axial & radial shadings

-Dan
Paths_.jpg
Paths_.jpg (21.59 KiB) Viewed 8324 times

Paths.jpg
Paths.jpg (10.78 KiB) Viewed 8324 times

Lines Patterns Caps & Joins__.jpg
Lines Patterns Caps & Joins__.jpg (36.65 KiB) Viewed 8324 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 » Mon Feb 28, 2011 5:45 am

I just tried to replace it with the newer CG XFcn but apparently this version doesn't allow special charaters as commas and quotes in text strings anymore. :(
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

Re: grc2coreGrc Showcase

Postby Dan_Kelleher » Mon Feb 28, 2011 6:59 am

I don't have anything useful to say regarding that issue Lorenz but I'd be interested to see a line of code that shows the problem; the context of the characters that are no longer accepted.
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 » Mon Feb 28, 2011 9:20 am

I put a "trace" at the top of the mouseUp handler script of the "Create coreGrc" button on the 3RD card (the single rectangle example) and used the script tracer to see how the core graphics XFcn works.

The attached image helped me to think about how large a core graphics context (canvas) has to be in order to rotate an object and/or to add a drop shadow to an object.
Thinking about CG context size.jpg
Thinking about CG context size.jpg (61.79 KiB) Viewed 8304 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 » Tue Mar 01, 2011 8:15 am

used the script tracer to see how the core graphics XFcn works.


Dan

Mind you, the calculations for the size of rotated objects are done in the grc2coreGrc function. To allow for a rotation around the center of an object you also have to translate the center of the object to the origin of the x- and y-axis, then you can rotate it and translate it back to its original place. Rotation of objects in CoreGraphics can (unfortunately?) only be done around the origin of the x- and y-axis.

BTW, the following code is the relavant code in the grc2coreGrc-function:
Code: Select all
-- translate object to the center of the canvas, then rotate around the center and translate back
get CG("translateCTM",dDim/2 &","& dDim/2)
get CG("rotateCTM", dRotation)
get CG("translateCTM",-dDim/2 &","& -dDim/2)


Lorenz
LorenzT
 
Posts: 176
Joined: Thu Dec 02, 2010 2:32 am
Location: Switzerland

PreviousNext

Return to The Lab

Who is online

Users browsing this forum: No registered users and 1 guest