Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!brutus.cs.uiuc.edu!lll-winken!ncis.tis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!hplabs!hpfcso!cunniff From: cunniff@hpfcso.HP.COM (Ross Cunniff) Newsgroups: comp.sys.amiga.tech Subject: Revised DR2D specification Message-ID: <9310006@hpfcso.HP.COM> Date: 12 Dec 89 20:02:35 GMT Organization: Hewlett-Packard, Fort Collins, CO, USA Lines: 429 Here is a revised DR2D format that responds to some of the comments posted here or e-mailed. The changes include: * Object attributes (fill color, etc.) are now more IFF-like * It uses the FTXT FONS chunk for font information * Nested objects (groups) are now more IFF-like * ProVector specific chunks are no longer documented here * Arrowhead attributes have been added * Bounding box information is optional * The limit of 256 fill and edge colors has been removed (it is now 65536) * Layer description information has been added * Line dash patterns are no longer hard coded (i.e. they are configurable/modifiable) The single change which some people have requested that is NOT here is: coordinates are still in IEEE format. The arguments for changing them are: * Hard to read and parse not true; see my previous response on this where I give a 20-line C routine to convert to fixed-point notation * Integers are more natural debatable; anyway, a program can decide to convert to integers if it wants to * Would require two passes over the file to decide which scaling factor to use for integers not true, the DRHD chunk has bounding box information which can be used to determine a suitable scaling factor * Integers are more flexible; they have a greater precision; you could have a project-wide scaling factor for them Integers do potentially have a greater precision; however, remember that this is an INTERCHANGE format. Consider Project A, with a scaling factor of 1,000,000 and Project B with a scaling factor of 100. Consider cut-and-paste between the projects. If you cut from project B, you can have objects that WILL NOT FIT in the range of Project A. If you cut from Project A, you can have objects that will resolve to singularities in the range of Project B. "Ah," you say, "What if each object has its own scaling factor?" to which I would reply "Let's just take it all the way; each coordinate has its own scaling factor. Oops, that is what a floating point number IS..." Anyway, here is the revised format: 89/12/10 The following is the format of the DR2D IFF FORM file produced by ProVector, a 2-dimensional structured graphics program. Each chunk is described by first giving the chunk ID (both in ASCII and in hex) and then giving the structure associated with the chunk, as well as any extra definitions that make sense. Coordinates are specified in IEEE format (see note 1 for a description of the IEEE format). It is assumed that these 'drawings' are on white 'paper'. Please address questions and comments to: Ross Cunniff Taliesin, Inc. P.O. Box 1671 Fort Collins, CO 80522 (303) 484-7321 FORM (0x464F524D) /* All drawings are a FORM */ struct FORMstruct { ULONG ID; ULONG Size; /* Total size of the file */ }; DR2D (0x44523244) /* ID of 2D drawing */ DRHD (0x44524844) /* Drawing header */ struct DRHDstruct { ULONG ID; ULONG Size; IEEE XMin, YMin, /* Minimum and maximum */ XMax, YMax; /* coordinates of the drawing area */ }; /* The following are global project properties */ CMAP (0x434D4150) /* Color map */ /* Same as ILBM CMAP */ struct CMAPstruct { ULONG ID; ULONG Size; UBYTE ColorMap[Size]; }; FONS (0x464F4E53) /* Font for text */ /* Same as FTXT.FONS */ struct FONSstruct { ULONG ID; ULONG Size; UBYTE FontID; /* ID it's called */ UBYTE Pad1; /* Always 0 */ UBYTE Proportional; /* Is it proportional? */ UBYTE Serif; /* Has it serifs? */ CHAR Name[Size-4]; /* The name of the font */ }; DASH (0x44415348) /* Line dash pattern for edges */ struct DASHstruct { ULONG ID; ULONG Size; USHORT DashID; /* Name of the dash pattern */ USHORT NumDashes; /* Should always be even */ IEEE Dashes[NumDashes]; /* On-off pattern */ }; /* The numbers in the dash patterns are relative to the line weight. The dash pattern {1.0,0.0} will always yield a dotted line with the dots as long as they are tall. By convention, DashID 0 is reserved to mean 'No line pattern at all', i.e. the edges are invisible. This DASH pattern should NOT appear in a DR2D FORM. Again by convention, a NumDashes of 0 means that the line is solid. */ AROW (0x41524F57) /* An arrow-head pattern */ #define ARROW_FIRST 0x01 /* Draw an arrow on the first point */ #define ARROW_LAST 0x02 /* Draw an arrow on the last point */ struct AROWstruct { ULONG ID; ULONG Size; UBYTE Flags; /* Flags, from ARROW_*, above */ UBYTE Pad0; /* Should always 0 */ USHORT ArrowID; /* Name of the arrow head */ USHORT NumPoints; IEEE ArrowPoints[NumPoints]; /* See note 2 */ }; FILL (0x46494C4C) /* Object-oriented fill pattern */ /* See note 3 */ struct FILLstruct { ULONG ID; ULONG Size; USHORT FillID; /* ID of the fill */ USHORT NumObjs; /* Number of objects in the fill */ }; LAYR (0x4C415952) /* Define a layer */ #define LF_ACTIVE 0x01 /* Active for editing */ #define LF_DISPLAYED 0x02 /* Displayed on the screen */ struct LAYRstruct { ULONG ID; ULONG Size; USHORT LayerID; /* ID of the layer */ UBYTE Flags; /* Flags, from LF_*, above */ UBYTE Pad0; /* Always 0 */ }; /* The following sets object attributes for the next object(s). The attributes are in effect until the next ATTR chunk is found, or until the end of the enclosing FORM, whichever comes first. */ ATTR (0x41545452) /* Object attributes */ /* Various fill types */ #define FT_NONE 0 /* No fill */ #define FT_COLOR 1 /* Fill with color from palette */ #define FT_OBJECTS 2 /* Fill with tiled objects */ /* Join types */ #define JT_NONE 0 /* Don't do line joins */ #define JT_MITER 1 /* Mitered join */ #define JT_BEVEL 2 /* Beveled join */ #define JT_ROUND 3 /* Round join */ struct ATTRstruct { UBYTE FillType; /* One of FT_*, above */ UBYTE JoinType; /* One of JT_*, above */ UBYTE EdgePattern; /* ID of edge dash pattern*/ UBYTE ArrowHeads; /* ID of arrowhead to use */ USHORT FillValue; /* Color or object with which to fill */ USHORT EdgeValue; /* Edge color index */ USHORT WhichLayer; /* Which layer it's in */ IEEE EdgeThick; /* Line width */ }; BBOX (0x42424F48) /* Bounding box of the next object in the FORM */ struct BBOXstruct { ULONG ID; ULONG Size; IEEE XMin, YMin, /* Bounding box of obj. */ XMax, YMax; /* including line width */ }; /* This chunk is ONLY in effect for the NEXT object in the FORM. Note that a BBOX may apply to a FILL or an AROW. */ /* The following are object definitions */ RAST (0x52415354) /* Raster image */ struct RASTstruct { ULONG ID; ULONG Size; IEEE XPos, YPos, /* Virtual coords */ XSize, YSize; /* Virtual size */ SHORT NumX, NumY, Depth; /* Actual size */ UBYTE Colors[3*(1<