home *** CD-ROM | disk | FTP | other *** search
- /*
- * A Mandala Enhanced Drawing Mode for ImageFX 2.0
- *
- */
-
- #include <exec/types.h>
- #include <scan/modall.h>
- #include <scan/drawinfo.h>
- #include <string.h>
- #include "common.h"
-
- /**********************************************************************\
-
- Library Vectors
-
- \**********************************************************************/
-
- /*
- * XDM_Attr:
- *
- * Return to ImageFX some information about the Drawing Style (eg.
- * whether Options are needed, whether we work on greyscale or
- * color, etc.). Called when ImageFX first scans the drawing
- * style directory.
- *
- */
- ULONG __saveds __asm XDS_Attr (register __a0 struct XDrawAttr *attr)
- {
- attr->Flags = XDMF_RedrawTrap | XDMF_UndoTrap;
- attr->Priority = 121;
- attr->Iterations = 4;
- return(0);
- }
-
- /*
- * XDS_Begin:
- *
- * Prepare before a pixel affecting operation.
- *
- */
- int __saveds __asm XDS_Begin (register __a0 struct IDrawInfo *di)
- {
- di->SPrivate = (APTR)ScanBase->MainBuffer;
- return(1);
- }
-
- /*
- * XDS_End:
- *
- * Cleanup after a pixel affecting operation.
- *
- */
- void __saveds __asm XDS_End (register __a0 struct IDrawInfo *di)
- {
- }
-
- static orig_le, orig_te;
-
- /*
- * XDS_Get:
- *
- *
- */
- int __saveds __asm XDS_Get (register __a0 struct IDrawInfo *di)
- {
- struct Buffer *buf = (struct Buffer *)di->SPrivate;
-
- if (!buf) return(0);
-
- switch(di->SIteration)
- {
- case 0 :
- orig_le = di->LE;
- orig_te = di->TE;
- break;
- case 1 :
- di->LE = (buf->Width / 2) + ((buf->Width / 2) - orig_le) - di->Width;
- di->TE = orig_te;
- break;
- case 2 :
- di->LE = (buf->Width / 2) + ((buf->Width / 2) - orig_le) - di->Width;
- di->TE = (buf->Height / 2) + ((buf->Height / 2) - orig_te) - di->Height;
- break;
- case 3 :
- di->LE = orig_le;
- di->TE = (buf->Height / 2) + ((buf->Height / 2) - orig_te) - di->Height;
- break;
- }
-
- GetFromBuf(buf, di);
-
- return(1);
- }
-
- /*
- * XDS_Put:
- *
- *
- */
- int __saveds __asm XDS_Put (register __a0 struct IDrawInfo *di)
- {
- struct Buffer *buf = (struct Buffer *)di->SPrivate;
-
- if (!buf) return(0);
-
- PutToBuf(buf, di);
-
- return(1);
- }
-
- /*
- * XDS_Options:
- *
- * Present a window to the user allowing him to adjust drawing style
- * options. Arguments may optionally be passed from an Arexx command.
- *
- */
- int __saveds __asm XDS_Options (register __a0 LONG *args)
- {
- return(0);
- }
-
- /*
- * XDS_LoadPrefs:
- *
- * Set preferences according to information loaded from disk.
- *
- */
- int __saveds __asm XDS_LoadPrefs (register __a0 void *prefs)
- {
- return(1);
- }
-
- /*
- * XDS_SavePrefs:
- *
- * Request preferences settings that are about to be saved to disk.
- *
- */
- int __saveds __asm XDS_SavePrefs (register __a0 void *prefs)
- {
- return(1);
- }
-
- int __saveds __asm XDS_Init (void)
- {
- return(1);
- }
-
- void __saveds __asm XDS_Cleanup (void)
- {
- }
-
- void __saveds __asm XDS_Redraw (register __d0 int left,
- register __d1 int top,
- register __d2 int right,
- register __d3 int bottom)
- {
- struct Buffer *buf = ScanBase->MainBuffer;
- int w, h;
-
- w = (right - left) + 1;
- h = (bottom - top) + 1;
-
- RedrawArea(left, top, right, bottom);
-
- #define MIRRORX1(x) ((buf->Width/2) + ((buf->Width/2) - (x)) - (w))
- #define MIRRORY1(y) ((buf->Height/2) + ((buf->Height/2) - (y)) - (h))
-
- RedrawArea(MIRRORX1(left), top, MIRRORX1(left)+w-1, bottom);
- RedrawArea(MIRRORX1(left), MIRRORY1(top), MIRRORX1(left)+w-1, MIRRORY1(top)+h-1);
- RedrawArea(left, MIRRORY1(top), right, MIRRORY1(top)+h-1);
- }
-
- BOOL __saveds __asm XDS_SaveUndo (register __a0 struct Buffer *buf,
- register __d0 int left,
- register __d1 int top,
- register __d2 int w,
- register __d3 int h)
- {
- int x1, y1, x2, y2;
- int right, bottom;
-
- right = left + w - 1;
- bottom = top + h - 1;
-
- x1 = MIRRORX1(left);
- y1 = top;
- x2 = MIRRORX1(left)+w-1;
- y2 = bottom;
- if (x1 < left) left = x1;
- if (y1 < top) top = y1;
- if (x2 > right) right = x2;
- if (y2 > bottom) bottom = y2;
-
- x1 = MIRRORX1(left);
- y1 = MIRRORY1(top);
- x2 = MIRRORX1(left)+w-1;
- y2 = MIRRORY1(top)+h-1;
- if (x1 < left) left = x1;
- if (y1 < top) top = y1;
- if (x2 > right) right = x2;
- if (y2 > bottom) bottom = y2;
-
- x1 = left;
- y1 = MIRRORY1(top);
- x2 = right;
- y2 = MIRRORY1(top)+h-1;
- if (x1 < left) left = x1;
- if (y1 < top) top = y1;
- if (x2 > right) right = x2;
- if (y2 > bottom) bottom = y2;
-
- return(SaveUndo(buf, left, top, (right-left+1), (bottom-top+1)));
- }
-
- /**********************************************************************\
-
- Library Initialization Stuff
-
- \**********************************************************************/
-
- /*
- * This is the table of all the functions that can be called in this
- * module. The first four (Open, Close, Expunge, and Null) are reserved
- * for system use and MUST be specified in the order shown. The actual
- * functions are in the standard module startup code.
- */
- ULONG FuncTable[] = {
- /* These four MUST be present in this order */
- (ULONG) LibOpen,
- (ULONG) LibClose,
- (ULONG) LibExpunge,
- (ULONG) LibNull,
-
- /* Specific to the module */
- (ULONG) XDS_Attr,
- (ULONG) XDS_Begin,
- (ULONG) XDS_End,
- (ULONG) XDS_Get,
- (ULONG) XDS_Put,
- (ULONG) XDS_Options,
- (ULONG) XDS_LoadPrefs,
- (ULONG) XDS_SavePrefs,
- (ULONG) 0,
- (ULONG) 0,
- (ULONG) XDS_Init,
- (ULONG) XDS_Cleanup,
- (ULONG) XDS_Redraw,
- (ULONG) XDS_SaveUndo,
-
- /* End with -1L */
- (ULONG) -1L
- };
-
- /*
- * These are used by the standard module startup code.
- * LibraryName is the name of the library, and LibraryID is a short
- * description of the library. Both of these are largely irrelavent,
- * but they are included just for completeness.
- */
- UBYTE LibraryID[] = "$VER: Mandala Drawing Style 2.0.15 (15.2.95)";
- UBYTE LibraryType = NT_XDRAWSTYLE;
-
- /*
- * This is called by the standard module startup code when Image Scan
- * first opens the module. Here we should fill in the NumGads,
- * NewGad, Language, and LangCount fields of the provided ModuleBase
- * structure if necessary.
- */
- long __asm UserOpen (register __a6 struct ModuleBase *modbase)
- {
- return(TRUE);
- }
-
- /*
- * This is called by the standard module startup code when Image Scan
- * closes the module. It should cleanup anything allocated or obtained
- * in the UserOpen() function.
- */
- long __asm UserClose (register __a6 struct ModuleBase *modbase)
- {
- return(TRUE);
- }
-
-