Re: [NTLK] Clip art?

From: Michael J. Hu▀mann <michael_at_michael-hussmann.de>
Date: Sun Apr 19 2009 - 21:01:54 EDT

Andy Hill (adhill@fastmail.co.uk) wrote:

> When you say it is also fairly easy to make your own using NTK, how easy
> would that be for a complete novice?

You don't really have to write any code, merely adapt a template. For
example, once you have created a resource file containing the clip art
as named PICT resources (using Rezilla, for example), you write a script
such as this:

OpenResFile(Home & "MyStamps.rsrc");

DefineGlobalConstant('kStampArray, [
        MakePixFamily (nil, nil, {rsrcSpec: "My first stamp", bitdepth: 4}),
        MakePixFamily (nil, nil, {rsrcSpec: "My second stamp", bitdepth: 4}),
        MakePixFamily (nil, nil, {rsrcSpec: "My third stamp", bitdepth: 4})
]);

CloseResFile();

InstallScript := func(partFrame, removeFrame)
begin
        local viewDef := GetViewDefs('drawPaper).default;
        local sym := EnsureInternal(kAppSymbol);
        if viewDef then viewDef:?RegStamps(sym, kStampArray);
end;

RemoveScript := func(removeFrame)
begin
        local sym := EnsureInternal(kAppSymbol);
        local viewDef := GetViewDefs('drawPaper).default;
        if viewDef then
                begin
                        viewDef:?UnRegStamps(sym);
                        local registry := GetViewDefs('drawPaper).StampListRegistry;
                        if registry AND HasSlot(registry, sym) then RemoveSlot(registry, sym);
                end;
end;

You can ignore most of this; just copy the code into a text file and
edit the first few lines: insert the name of the resource file
("MyStamps.rsrc" in this case) in the first line and the names of the
stamps ("My first stamp", "My second stamp", and "My third stamp") in
the following lines -- these are the names of the PICT resources in the
resource file. You can define as many (or as few) stamps as you wish
here. The rest of the code will be the same for any set of stamps and
can thus be left as is. The bit depth here is 4 (for 16 shades of grey),
but it could also be 1 (b&w). Now open NTK, create a new project, add
the resource file and the script file to the project, and compile it
into a package of type "auto part". That's all there is to it, basically.

- Michael

Michael J. Hu▀mann

E-mail: michael@michael-hussmann.de
WWW (personal): http://michael-hussmann.de
WWW (professional): http://digicam-experts.de

====================================================================
The NewtonTalk Mailing List - http://www.newtontalk.net/
The Official Newton FAQ - http://www.splorp.com/newton/faq/
The Newton Glossary - http://www.splorp.com/newton/glossary/
WikiWikiNewt - http://tools.unna.org/wikiwikinewt/
====================================================================
Received on Sun Apr 19 21:02:06 2009

This archive was generated by hypermail 2.1.8 : Mon Apr 20 2009 - 18:30:00 EDT