home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
utilities
/
utilsd
/
drawpersp
/
!DrawPersp
/
DrawLib
(
.txt
)
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
RISC OS BBC BASIC V Source
|
1995-01-29
|
36.9 KB
|
1,167 lines
>Module DrawLib
$*|Start PROCshell_DrawCreateFile
shell_DrawCreateFile(
buffer%)
creator$,style_blk%,trans_matrix%
EvntShell drawfiles in memory have a 60 byte 'pre-header' which keeps
track of current settings. The 'pre-header' must not be saved to disk
as the file will not be a valid drawfile!
*buffer% =
shell_HeapBlockFetch(60+24)
Ibuffer%!00 = -1 :
Number of current outline font (-1 if none)
:buffer%!04 = 60 :
Size of EvntShell pre-header
Sbuffer%!08 = 0 :
File offset to next free address (from start of file)
O|(buffer%+12)=1814.1732:
Current unit multiplier factor (real nr, 5 bytes)
1buffer%!20 = 7 :
Current path colour
1buffer%!24 = -1 :
Current fill colour
Nbuffer%!28 = 0 :
File offset to start of current group definition
0buffer%!32 = 0 :
Current path width
-buffer%!36 = 0 :
Current end cap
Mbuffer%!40 = -1 :
Number of outline fonts declared (-1 if none)
Vbuffer%!44 = -1 :
File offset to start of font table (-1 if no font table)
Ebuffer%!48 = 0 :
Pointer to path style description block
$buffer%!52 = 0 :
Unused
G$(buffer% + (buffer%!04))= "Draw" :
Required to tag as a drawfile
>buffer%!(buffer%!04 + 4) = 201 :
Major version number
>buffer%!(buffer%!04 + 8) = 0 :
Minor version number
W$(buffer% + (buffer%!04 + 12)) =
shell_StringPadTrailing(
shell_GetAppName," ",11)
Lbuffer%!08 = buffer%!04 + 24 :
24 is length of DrawFile so far...
Set extent words of DrawFile to be 0,0,1,1...
shell_DrawPutWord(0,buffer%)
shell_DrawPutWord(0,buffer%)
shell_DrawPutWord(0,buffer%)
shell_DrawPutWord(0,buffer%)
!*buffer%!48 =
shell_HeapBlockFetch(16)
style_blk% = buffer%!48
style_blk%!00 = 0
style_blk%!04 = 0
style_blk%!08 = 0
style_blk%!12 = 0
'*buffer%!52 =
shell_HeapBlockFetch(24)
trans_matrix% = buffer%!52
))trans_matrix%!00 = 1 << 16 :
x scale
**trans_matrix%!04 = 0 :
rotation
+*trans_matrix%!08 = 0 :
rotation
,)trans_matrix%!12 = 1 << 16 :
y scale
-3trans_matrix%!16 = 0 :
x position offset
.3trans_matrix%!20 = 0 :
y position offset
0"DRW_PATH_START% = buffer%!8
DRW_PATH_SCALE_FAC = 1
DRW_PATH_XMIN = 0
DRW_PATH_YMIN = 0
DRW_PATH_XMAX = 0
DRW_PATH_YMAX = 0
9#*|Stop PROCshell_DrawCreateFile
;%*|Start PROCshell_DrawOutlineFont
shell_DrawOutlineFont(
buffer%,text$,ptsize,pthigh,xorigin%,yorigin%)
start%,ptr%,lx%,by%,rx%,ty%,font%,scl_fac
scl_fac = |(buffer%+12)
font% = !buffer%
text$ <> ""
A3 buffer% =
shell_HeapBlockExtend(buffer%,256)
B# ptr% = buffer% + buffer%!8
start% = ptr%
D/ !ptr% = 1 :
Text object
ED ptr% += 24 :
Skip size, object bounds for now
F$ lx% = (xorigin% * scl_fac)
G$ by% = (yorigin% * scl_fac)
PROCshell_Tracef0("DEBUG::font is "+STR$font%)
PROCshell_Tracef0("DEBUG::font is "+FNshell_DrawFontName(buffer%,font%))
"Font_FindFont",,
shell_DrawFontName(buffer%,font%),ptsize * 16, pthigh * 16
handle%
"Font_SetFont",handle%
"Font_StringBBox",,text$
,r1%,r2%,r3%,r4%
"Font_LoseFont",handle%
PROCshell_Tracef0("DEBUG::r1% = "+STR$r1%)
PROCshell_Tracef0("DEBUG::r2% = "+STR$r2%)
PROCshell_Tracef0("DEBUG::r3% = "+STR$r3%)
PROCshell_Tracef0("DEBUG::r4% = "+STR$r4%)
S& rx% = lx% + ((r3%/1000)*640)
T& ty% = by% + ((r4%/1000)*640)
PROCshell_Tracef0("DEBUG::lx%="+STR$lx%)
PROCshell_Tracef0("DEBUG::by%="+STR$by%)
PROCshell_Tracef0("DEBUG::rx%="+STR$rx%)
PROCshell_Tracef0("DEBUG::ty%="+STR$ty%)
shell_DrawPutCoords(start% + 8,lx%,by%,rx%,ty%)
Z' !ptr% = buffer%!20 :ptr% += 4
[' !ptr% = buffer%!24 :ptr% += 4
\' !ptr% = font% :ptr% += 4
]' !ptr% = ptsize * 640 :ptr% += 4
^' !ptr% = pthigh * 640 :ptr% += 4
_2 !ptr% = xorigin% * |(buffer%+12):ptr% += 4
`2 !ptr% = yorigin% * |(buffer%+12):ptr% += 4
shell_DrawPutString(text$,ptr%)
start%!4 = ptr% - start%
shell_DrawUpdateBounds(buffer%,lx%,by%,rx%,ty%)
d> buffer% =
shell_HeapBlockExtend(buffer%,start%!4 - 256)
buffer%!8 += start%!4
i$*|Stop PROCshell_DrawOutlineFont
k#*|Start PROCshell_DrawPutString
shell_DrawPutString(S$,
ptr%)
$ptr% = S$
ptr% +=
?ptr% = 0
ptr% += 1
ptr%
4 = 0
u"*|Stop PROCshell_DrawPutString
w#*|Start PROCshell_DrawPutCoords
shell_DrawPutCoords(start%,lx%,by%,rx%,ty%)
start%!00 = lx%
start%!04 = by%
start%!08 = rx%
start%!12 = ty%
"*|Stop PROCshell_DrawPutCoords
&*|Start PROCshell_DrawSetPathWidth
shell_DrawSetPathWidth(buffer%,width)
1buffer%!32 =
((width * |(buffer%+12)) + 0.5)
%*|Stop PROCshell_DrawSetPathWidth
'*|Start PROCshell_DrawSetPathColour
shell_DrawSetPathColour(buffer%,R%,G%,B%)
buffer%?20 = 0
buffer%?21 = R%
buffer%?22 = G%
buffer%?23 = B%
&*|Stop PROCshell_DrawSetPathColour
)*|Start PROCshell_DrawSetPathNoColour
shell_DrawSetPathNoColour(buffer%)
buffer%!20 = -1
(*|Stop PROCshell_DrawSetPathNoColour
'*|Start PROCshell_DrawSetFillColour
shell_DrawSetFillColour(buffer%,R%,G%,B%)
buffer%?24 = 0
buffer%?25 = R%
buffer%?26 = G%
buffer%?27 = B%
&*|Stop PROCshell_DrawSetFillColour
)*|Start PROCshell_DrawSetNoFillColour
shell_DrawSetNoFillColour(buffer%)
buffer%!24 = -1
(*|Stop PROCshell_DrawSetNoFillColour
!*|Start PROCshell_DrawPutWord
shell_DrawPutWord(k%,
buffer%)
next%
/buffer% =
shell_HeapBlockExtend(buffer%,4)
next% = buffer% + buffer%!08
!next% = k%
buffer%!08 += 4
*|Stop PROCshell_DrawPutWord
$*|Start PROCshell_DrawStartGroup
shell_DrawStartGroup(
buffer%,name$)
next%
buffer%!28 > 0
shell_DrawEndGroup(buffer%)
Kbuffer%!28 = buffer%!08:
Store file offset to current group definition
PROCshell_Tracef0("DEBUG::bb_offset = "+STR$~buffer%!28)
shell_DrawPutWord(06,buffer%) :
Object type 6 (group)
shell_DrawPutWord(36,buffer%) :
Current size of group object
shell_DrawPutWord(-1,buffer%) :
Bounding box xmin
shell_DrawPutWord(-1,buffer%) :
Bounding box ymin
shell_DrawPutWord(1,buffer%) :
Bounding box xmax
shell_DrawPutWord(1,buffer%) :
Bounding box ymax
0buffer% =
shell_HeapBlockExtend(buffer%,12)
"next% = buffer% + buffer%!08
$next% = name$
Abuffer%!08 += 12 :
Update file offset to next free address..
#*|Stop PROCshell_DrawStartGroup
"*|Start PROCshell_DrawEndGroup
shell_DrawEndGroup(buffer%)
start%
buffer%!28 > 0
% start% = buffer% + (buffer%!28)
/ start%!4 = (buffer% + buffer%!8) - start%
buffer%!28 = 0
!*|Stop PROCshell_DrawEndGroup
%*|Start PROCshell_DrawDestroyFile
shell_DrawDestroyFile(buffer%)
shell_HeapBlockExists(buffer%!48)
shell_HeapBlockReturn(buffer%!48)
shell_HeapBlockReturn(buffer%)
$*|Stop PROCshell_DrawDestroyFile
"*|Start PROCshell_DrawSaveFile
shell_DrawSaveFile(buffer%,file$)
Add some error trapping here...
X% =
(file$)
PROCshell_Tracef0("DEBUG::size is "+STR$(buffer%!8 - buffer%!4))
"OS_GBPB",2,X%,buffer% + (buffer%!4),buffer%!8 - buffer%!4
("SetType "+file$+ " &AFF")
!*|Stop PROCshell_DrawSaveFile
*|Start FNshell_DrawLoadFile
shell_DrawLoadFile(name$)
buff%,X%,size%
shell_DrawCreateFile(buff%)
,buff%!8 -= 40 :
don't need the header..
$size% =
shell_FileLength(name$)
/buff% =
shell_HeapBlockExtend(buff%,size%)
X% =
(name$)
"OS_GBPB",4,X%,buff% + buff%!4,size%
buff%!8 = size% + buff%!4
shell_DrawSetScale(buffer%,1,1)
= buff%
*|Stop FNshell_DrawLoadFile
!*|Start PROCshell_DrawEllipse
shell_DrawEllipse(
buffer%,X,Y,Xm,Ym)
start%,A,B,C,D,E,K,Xs,Ys
start% = buffer%!8
X = X * |(buffer%+12)
Y = Y * |(buffer%+12)
Xm = Xm * |(buffer%+12)
Ym = Ym * |(buffer%+12)
PROCshell_Tracef0("DEBUG::X="+STR$X)
PROCshell_Tracef0("DEBUG::Y="+STR$Y)
PROCshell_Tracef0("DEBUG::Xm="+STR$Xm)
PROCshell_Tracef0("DEBUG::Ym="+STR$Ym)
Xm >= Ym
A = Xm / Xm / 10 + 0.5
Xm / Ym < 2
A = 0.7
Xm / Ym > 4.5
A = 0.95
Xs = A * Xm
( Ys =
(1 - Xs * Xs / Xm / Xm) * Ym
Ym > Xm
A = Ym / Xm / 10 + 0.5
Ym / Xm < 2
A = 0.7
Ym / Xm > 4.5
A = 0.95
Ys = A * Ym
( Xs =
(1 - Ys * Ys / Ym / Ym) * Xm
B = Ym + (Ym - Ys) / 3
%K = Xs * Xs + (B - Ys) * (B - Ys)
.C = (
(4 * Xs * Xs + 12 * K) - 2 * Xs) / 6
D = Xm + (Xm - Xs) / 3
%K = Ys * Ys + (D - Xs) * (D - Xs)
.E = (
(4 * Ys * Ys + 12 * K) - 2 * Ys) / 6
shell_DrawPutWord(2,buffer%) :
Object type 2 (path)
shell_DrawPutWord(0,buffer%) :
Size of object (dummy value)
shell_DrawPutWord(X - Xm,buffer%):
Set size of bounding box xmin
shell_DrawPutWord(Y - Ym,buffer%):
Set size of bounding box ymin
shell_DrawPutWord(X + Xm,buffer%):
Set size of bounding box xmax
shell_DrawPutWord(Y + Ym,buffer%):
Set size of bounding box ymax
shell_DrawUpdateBounds(buffer%,X - Xm,Y - Ym,X + Xm,Y + Ym)
shell_DrawPutWord(buffer%!24,buffer%) :
Fill colour
shell_DrawPutWord(buffer%!20,buffer%) :
Path colour
shell_DrawPutWord(buffer%!32,buffer%) :
Path width
shell_DrawPutWord(00,buffer%) :
Pattern
shell_DrawPutWord(2,buffer%) :
Absolute move
shell_DrawPutWord(X + Xs,buffer%) :
x start
shell_DrawPutWord(Y - Ys,buffer%) :
y start
shell_DrawPutWord(6,buffer%)
shell_DrawPutWord(X + C,buffer%)
shell_DrawPutWord(Y - B,buffer%)
shell_DrawPutWord(X - C,buffer%)
shell_DrawPutWord(Y - B,buffer%)
shell_DrawPutWord(X - Xs,buffer%)
shell_DrawPutWord(Y - Ys,buffer%)
shell_DrawPutWord(6,buffer%)
shell_DrawPutWord(X - D,buffer%)
shell_DrawPutWord(Y - E,buffer%)
shell_DrawPutWord(X - D,buffer%)
shell_DrawPutWord(Y + E,buffer%)
shell_DrawPutWord(X - Xs,buffer%)
shell_DrawPutWord(Y + Ys,buffer%)
shell_DrawPutWord(6,buffer%)
shell_DrawPutWord(X - C,buffer%)
shell_DrawPutWord(Y + B,buffer%)
shell_DrawPutWord(X + C,buffer%)
shell_DrawPutWord(Y + B,buffer%)
shell_DrawPutWord(X + Xs,buffer%)
shell_DrawPutWord(Y + Ys,buffer%)
shell_DrawPutWord(6,buffer%)
shell_DrawPutWord(X + D,buffer%)
shell_DrawPutWord(Y + E,buffer%)
shell_DrawPutWord(X + D,buffer%)
shell_DrawPutWord(Y - E,buffer%)
shell_DrawPutWord(X + Xs,buffer%)
shell_DrawPutWord(Y - Ys,buffer%)
shell_DrawPutWord(0,buffer%) :
End of path
JJ!(buffer% + start% + 4) = buffer%!8 - start% :
Store size of object
M *|Stop PROCshell_DrawEllipse
O *|Start PROCshell_DrawCircle
shell_DrawCircle(
buffer%,X,Y,R)
start%,A,B,C,style_blk%
style_blk% = buffer%!48
start% = buffer%!8
X = X * |(buffer%+12)
Y = Y * |(buffer%+12)
R = R * |(buffer%+12)
A = R /
B = A + R / 2.544
C = A - R / 2.544
shell_DrawPutWord(2,buffer%) :
Object type 2 (path)
shell_DrawPutWord(0,buffer%) :
Size of object (dummy value)
shell_DrawPutWord(X - R,buffer%) :
Set size of bounding box xmin
shell_DrawPutWord(Y - R,buffer%) :
Set size of bounding box ymin
shell_DrawPutWord(X + R,buffer%) :
Set size of bounding box xmax
shell_DrawPutWord(Y + R,buffer%) :
Set size of bounding box ymax
shell_DrawUpdateBounds(buffer%,X - R,Y - R,X + R,Y + R)
shell_DrawPutWord(buffer%!24,buffer%) :
Fill colour
shell_DrawPutWord(buffer%!20,buffer%) :
Path colour
shell_DrawPutWord(buffer%!32,buffer%) :
Path width
shell_DrawPutWord(style_blk%!0,buffer%) :
Style word
(style_blk%?0
1 << 7) <> 0
shell_DrawPutWord(style_blk%!04,buffer%) :
Offset to pattern start
shell_DrawPutWord(style_blk%!08,buffer%) :
Nr of elements in pattern
shell_DrawPutWord(style_blk%!12,buffer%) :
Length of dash element
shell_DrawPutWord(2,buffer%) :
Absolute move
shell_DrawPutWord(X + A,buffer%) :
x start
shell_DrawPutWord(Y - A,buffer%) :
y start
shell_DrawPutWord(6,buffer%)
shell_DrawPutWord(X + C,buffer%)
shell_DrawPutWord(Y - B,buffer%)
shell_DrawPutWord(X - C,buffer%)
shell_DrawPutWord(Y - B,buffer%)
shell_DrawPutWord(X - A,buffer%)
shell_DrawPutWord(Y - A,buffer%)
shell_DrawPutWord(6,buffer%)
shell_DrawPutWord(X - B,buffer%)
shell_DrawPutWord(Y - C,buffer%)
shell_DrawPutWord(X - B,buffer%)
shell_DrawPutWord(Y + C,buffer%)
shell_DrawPutWord(X - A,buffer%)
shell_DrawPutWord(Y + A,buffer%)
shell_DrawPutWord(6,buffer%)
shell_DrawPutWord(X - C,buffer%)
shell_DrawPutWord(Y + B,buffer%)
shell_DrawPutWord(X + C,buffer%)
shell_DrawPutWord(Y + B,buffer%)
shell_DrawPutWord(X + A,buffer%)
shell_DrawPutWord(Y + A,buffer%)
shell_DrawPutWord(6,buffer%)
shell_DrawPutWord(X + B,buffer%)
shell_DrawPutWord(Y + C,buffer%)
shell_DrawPutWord(X + B,buffer%)
shell_DrawPutWord(Y - C,buffer%)
shell_DrawPutWord(X + A,buffer%)
shell_DrawPutWord(Y - A,buffer%)
shell_DrawPutWord(0,buffer%) :
End of path
J!(buffer% + start% + 4) = buffer%!8 - start% :
Store size of object
*|Stop PROCshell_DrawCircle
*|Start PROCshell_DrawBox
shell_DrawBox(
buffer%,x0,y0,width,height)
start%,scl_fac
start% = buffer%!8
scl_fac = |(buffer%+12)
x0 = x0 * scl_fac
y0 = y0 * scl_fac
width = width * scl_fac
height = height * scl_fac
shell_DrawPutWord(2,buffer%) :
Object type 2 (path)
shell_DrawPutWord(0,buffer%) :
Size of object (dummy value)
shell_DrawPutWord(x0,buffer%) :
Set size of bounding box xmin
shell_DrawPutWord(y0,buffer%) :
Set size of bounding box ymin
shell_DrawPutWord(x0 + width,buffer%) :
Set size of bounding box xmax
shell_DrawPutWord(y0 + height,buffer%):
Set size of bounding box ymax
shell_DrawUpdateBounds(buffer%,x0,y0,x0 + width,y0 + height)
shell_DrawPutWord(buffer%!24,buffer%) :
Fill colour
shell_DrawPutWord(buffer%!20,buffer%) :
Path colour
shell_DrawPutWord(buffer%!32,buffer%) :
Path width
shell_DrawPutWord(00,buffer%) :
Pattern
shell_DrawPutWord(02,buffer%) :
Absolute move
shell_DrawPutWord(x0,buffer%) :
x start
shell_DrawPutWord(y0,buffer%) :
y start
shell_DrawPutWord(08,buffer%) :
Draw to absolute position
shell_DrawPutWord(x0,buffer%)
shell_DrawPutWord(y0 + height,buffer%)
shell_DrawPutWord(08,buffer%)
shell_DrawPutWord(x0 + width,buffer%)
shell_DrawPutWord(y0 + height,buffer%)
shell_DrawPutWord(08,buffer%)
shell_DrawPutWord(x0 + width,buffer%)
shell_DrawPutWord(y0,buffer%)
shell_DrawPutWord(08,buffer%)
shell_DrawPutWord(x0,buffer%)
shell_DrawPutWord(y0,buffer%)
shell_DrawPutWord(00,buffer%) :
End of path
G!(buffer% + start% + 4) = buffer%!8 - start%:
Store size of object
*|Stop PROCshell_DrawBox
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Path Object
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
**|Start PROCshell_DrawUpdateObjectBBox
shell_DrawUpdateObjectBBox( buffer%, x_coord, y_coord )
x_coord < DRW_PATH_XMIN
DRW_PATH_XMIN = x_coord
x_coord > DRW_PATH_XMAX
DRW_PATH_XMAX = x_coord
y_coord < DRW_PATH_YMIN
DRW_PATH_YMIN = y_coord
y_coord > DRW_PATH_YMAX
DRW_PATH_YMAX = y_coord
7!( buffer% + DRW_PATH_START% + 08 ) = DRW_PATH_XMIN
7!( buffer% + DRW_PATH_START% + 12 ) = DRW_PATH_YMIN
7!( buffer% + DRW_PATH_START% + 16 ) = DRW_PATH_XMAX
7!( buffer% + DRW_PATH_START% + 20 ) = DRW_PATH_YMAX
)*|Stop PROCshell_DrawUpdateObjectBBox
#*|Start PROCshell_DrawPathStart
shell_DrawPathStart(
buffer%, x_coord, y_coord )
Set up Module Globals..
"DRW_PATH_START% = buffer%!8
*DRW_PATH_SCALE_FAC = |( buffer% + 12 )
*x_coord = x_coord * DRW_PATH_SCALE_FAC
*y_coord = y_coord * DRW_PATH_SCALE_FAC
DRW_PATH_XMIN = x_coord
DRW_PATH_YMIN = x_coord
DRW_PATH_XMAX = y_coord
DRW_PATH_YMAX = y_coord
DRW_PATH_XMIN = x_coord
DRW_PATH_YMIN = y_coord
DRW_PATH_XMAX = -&7FFFFFFF
DRW_PATH_YMAX = -&7FFFFFFF
shell_DrawPutWord( 2,buffer% ) :
Object type 2 (path)
shell_DrawPutWord( 0,buffer% ) :
Size of object (dummy value)
shell_DrawPutWord( DRW_PATH_XMIN, buffer% ) :
Set size of bounding box xmin
shell_DrawPutWord( DRW_PATH_YMIN, buffer% ) :
Set size of bounding box ymin
shell_DrawPutWord( DRW_PATH_XMAX, buffer% ) :
Set size of bounding box xmax
shell_DrawPutWord( DRW_PATH_YMAX, buffer% ) :
Set size of bounding box ymax
shell_DrawPutWord( buffer%!24, buffer% ) :
Fill colour
shell_DrawPutWord( buffer%!20, buffer% ) :
Path colour
shell_DrawPutWord( buffer%!32, buffer% ) :
Path width
shell_DrawPutWord( 00,buffer% ) :
Pattern
shell_DrawPutWord( 02,buffer% ) :
Absolute move
shell_DrawPutWord( x_coord, buffer% ) :
x start
shell_DrawPutWord( y_coord, buffer% ) :
y start
!*Stop PROCshell_DrawPathStart
$*|Start PROCshell_DrawPathDrawTo
shell_DrawPathDrawTo(
buffer%, x_coord, y_coord )
shell_DrawPutWord( 08, buffer% ) :
Draw to absolute position
*x_coord = x_coord * DRW_PATH_SCALE_FAC
*y_coord = y_coord * DRW_PATH_SCALE_FAC
shell_DrawPutWord( x_coord, buffer% )
shell_DrawPutWord( y_coord, buffer% )
shell_DrawUpdateObjectBBox( buffer%, x_coord, y_coord )
"*Stop PROCshell_DrawPathDrawTo
!*|Start PROCshell_DrawPathEnd
shell_DrawPathEnd(
buffer% )
shell_DrawPutWord( 00, buffer% )
Store size of object..
D!( buffer% + DRW_PATH_START% + 4 ) = buffer%!8 - DRW_PATH_START%
shell_DrawUpdateBounds( buffer%, DRW_PATH_XMIN, DRW_PATH_YMIN, DRW_PATH_XMAX, DRW_PATH_YMAX )
*Stop PROCshell_DrawPathEnd
'*|Start PROCshell_DrawPathCloseLine
shell_DrawPathCloseLine(
buffer% )
shell_DrawPutWord( 05, buffer% )
shell_DrawPutWord( 00, buffer% )
Store size of object..
D!( buffer% + DRW_PATH_START% + 4 ) = buffer%!8 - DRW_PATH_START%
shell_DrawUpdateBounds( buffer%, DRW_PATH_XMIN, DRW_PATH_YMIN, DRW_PATH_XMAX, DRW_PATH_YMAX )
%*Stop PROCshell_DrawPathCloseLine
&*|Start PROCshell_DrawUpdateBounds
shell_DrawUpdateBounds(buffer%,x0,y0,x1,y1)
bb_start%
#bb_start% = buffer% + buffer%!4
x0 > x1
x0,x1
y0 > y1
y0,y1
(bb_start% + 32) = 0
!(bb_start% + 36) = 0
!(bb_start% + 24) = x0
!(bb_start% + 28) = y0
!(bb_start% + 32) = x1
!(bb_start% + 36) = y1
x0 < !(bb_start% + 24)
!(bb_start% + 24) = x0
y0 < !(bb_start% + 28)
!(bb_start% + 28) = y0
x1 > !(bb_start% + 32)
!(bb_start% + 32) = x1
y1 > !(bb_start% + 36)
!(bb_start% + 36) = y1
buffer%!28 > 0
shell_DrawUpdateGroupBounds(buffer%,x0,y0,x1,y1)
.%*|Stop PROCshell_DrawUpdateBounds
0+*|Start PROCshell_DrawUpdateGroupBounds
shell_DrawUpdateGroupBounds(buffer%,x0,y0,x1,y1)
bb_start%
3$bb_start% = buffer% + buffer%!28
PROCshell_Tracef0("DEBUG::bb_offset = "+STR$~buffer%!28)
PROCshell_Tracef0("DEBUG::current x0 = "+STR$(!(bb_start% + 08)))
!(bb_start% + 08) = -1
!(bb_start% + 08) = x0
x0 < !(bb_start% + 08)
!(bb_start% + 08) = x0
!(bb_start% + 12) = -1
!(bb_start% + 12) = y0
y0 < !(bb_start% + 12)
!(bb_start% + 12) = y0
x1 > !(bb_start% + 16)
!(bb_start% + 16) = x1
y1 > !(bb_start% + 20)
!(bb_start% + 20) = y1
PROCshell_Tracef0("DEBUG::x0 = "+STR$x0)
PROCshell_Tracef0("DEBUG::y0 = "+STR$y0)
PROCshell_Tracef0("DEBUG::x1 = "+STR$x1)
PROCshell_Tracef0("DEBUG::y1 = "+STR$y1)
PROCshell_Tracef0("")
PROCshell_Tracef0("DEBUG::x0 = "+STR$(!(bb_start%+8)))
J**|Stop PROCshell_DrawUpdateGroupBounds
*|Start PROCshell_DrawLine
shell_DrawLine(
buffer%,x0,y0,x1,y1)
start%,pat_blk%,scl_fac,style_blk%,p_width%,cap_width%,cap_len%
cap_width2%,cap_len2%,bbox_xmin,bbox_xmax,bbbox_ymin,bbox_ymax
scl_fac = |(buffer%+12)
start% = buffer%!8
SHx0 = x0 * scl_fac :
Convert to draw units using stored scale factor
y0 = y0 * scl_fac
x1 = x1 * scl_fac
y1 = y1 * scl_fac
p_width% = buffer%!32
style_blk% = buffer%!48
x0 > x1
bbox_xmin = x1
bbox_xmax = x0
bbox_xmin = x0
bbox_xmax = x1
y0 > y1
bbox_ymin = y1
bbox_ymax = y0
bbox_ymin = y0
bbox_ymax = y1
PROCshell_Tracef0("DEBUG:: "+STR$(style_blk%?0 AND (1 << 2)))
PROCshell_Tracef0("DEBUG:: "+STR$(style_blk%?0 AND (1 << 3)))
(style_blk%?0
%1100)
(style_blk%?0
%110000) <> 0
Triangular end caps on the path, check the widths..
(style_blk%?0
%1100)
n9 cap_width% = style_blk%?2:
1/16ths of path width
o9 cap_len% = style_blk%?3:
1/16ths of path width
p3 cap_width% = (cap_width% * (p_width% / 16))
q3 cap_len% = (cap_len% * (p_width% / 16))
(style_blk%?0
%110000)
t: cap_width2% = style_blk%?4:
1/16ths of path width
u: cap_len2% = style_blk%?5:
1/16ths of path width
v5 cap_width2% = (cap_width2% * (p_width% / 16))
w5 cap_len2% = (cap_len2% * (p_width% / 16))
cap_width2% > cap_width%
cap_width% = cap_width2%
cap_len2% > cap_len%
cap_len% = cap_len2%
PROCshell_Tracef0("DEBUG:: cap_width% = "+STR$cap_width%)
PROCshell_Tracef0("DEBUG:: cap_len% = "+STR$cap_len%)
shell_DrawPutWord(2,buffer%) :
Object type 2 (path)
shell_DrawPutWord(0,buffer%) :
Size of object (dummy value)
shell_DrawPutWord(bbox_xmin-cap_len%,buffer%) :
Set size of bounding box xmin
shell_DrawPutWord(bbox_ymin-(p_width%/2)-cap_width%,buffer%) :
Set size of bounding box ymin
shell_DrawPutWord(bbox_xmax+cap_len%,buffer%) :
Set size of bounding box xmax
shell_DrawPutWord(bbox_ymax+(p_width%/2)+cap_width%,buffer%) :
Set size of bounding box ymax
shell_DrawUpdateBounds(buffer%,x0,y0,x1,y1):
Update DrawFile bounding box
shell_DrawPutWord(buffer%!24,buffer%) :
Fill colour (-1 = do not fill)
shell_DrawPutWord(buffer%!20,buffer%) :
Path colour (-1 = no outline)
shell_DrawPutWord(buffer%!32,buffer%) :
Path width
shell_DrawPutWord(style_blk%!0,buffer%) :
Style word
(style_blk%?0
1 << 7) <> 0
shell_DrawPutWord(style_blk%!04,buffer%) :
Offset to pattern start
shell_DrawPutWord(style_blk%!08,buffer%) :
Nr of elements in pattern
shell_DrawPutWord(style_blk%!12,buffer%) :
Length of dash element
shell_DrawPutWord(02,buffer%) :
Absolute move
shell_DrawPutWord(x0,buffer%) :
x start
shell_DrawPutWord(y0,buffer%) :
y start
shell_DrawPutWord(08,buffer%) :
Draw to absolute position
shell_DrawPutWord(x1,buffer%) :
x finish
shell_DrawPutWord(y1,buffer%) :
y finish
shell_DrawPutWord(00,buffer%) :
End of path
J!(buffer% + start% + 4) = buffer%!8 - start% :
Store size of object
*|Stop PROCshell_DrawLine
!*|Start PROCshell_DrawSetFont
shell_DrawSetFont(buffer%,font$)
ft_start%,ft_end%,f_handle%,ptr%,name$,found%
found% =
f_handle% = 0
font$ = ""
- !buffer% = 0 :
Font 0 is system font..
Search font table to find internal font handle of requested font
ft_start% = buffer%!44
ft_start% = -1
99,"No fonts have been initialised for this drawfile"
F ft_start% += buffer% :
Now points to start of font table object
PROCshell_Tracef0("DEBUG::font table size is = "+STR$(ft_start%!4))
* ft_end% = ft_start%!4 + ft_start%
ptr% = ft_start% + 8
& ft_handle% = ?ptr% : ptr% += 1
& name$ =
shell_GetString(ptr%)
V
PROCshell_Tracef0("DEBUG::font name found ("+STR$ft_handle%+") '"+name$+"'")
ptr% +=
name$ + 1
ptr%
4 <> 0
ptr% +=1
name$ = font$
) found% =
: ptr% = ft_end% + 1
R
PROCshell_Tracef0("DEBUG::font name match, handle is "+STR$ft_handle%)
0
PROCshell_Tracef0("DEBUG::NO MATCH")
ptr% >= ft_end%
found%
!buffer% = ft_handle%
PROCshell_Tracef0("DEBUG::Setting font handle to "+STR$(!buffer%))
99,"Font '"+font$+"' has not been initialised"
*|Stop PROCshell_DrawSetFont
"*|Start PROCshell_DrawInitFont
shell_DrawInitFont(
buffer%,font_name$)
ft_start%,ptr%,def_start%
shell_FontIsAvailable(font_name$,12,12)
6 buffer% =
shell_HeapBlockExtend(buffer%,256)
B ptr% = buffer% + buffer%!8 :
Next address in file..
def_start% = ptr%
buffer%!40 = -1
J
This routine hasn't been called before, so create new font table
T buffer%!44 = buffer%!8 :
Store file offset to start of font table
D !ptr% = 0:ptr% += 4 :
Create font table object
D !ptr% = 0:ptr% += 4 :
Skip object size for now
? buffer%!40 = 0 :
Nr of defined fonts
J ft_start% = buffer% + buffer%!44 :
Start of font table definition
@ buffer%!40 += 1 :
Increment font count
T ?ptr% = buffer%!40 :
Store internal font handle (starts at 1)
F $(ptr%+1) = font_name$ :
Store textual name of font
ptr% +=
(font_name$) + 2
G ?(ptr% - 1) = 0 :
Terminate name with CHR$(0)
ptr%
4 <> 0 :
Pad with trailing spaces to a word boundary
?ptr% = 0
ptr% += 1
L ft_start%!04 = ptr% - ft_start% :
Update size of font table object
C buffer%!08 += ptr% - def_start% :
Update size of DrawFile
Finally shrink heap block..
H buffer% =
shell_HeapBlockExtend(buffer%,(ptr% - ft_start%) - 256)
h void% =
shell_MessageWindow(
shell_MessageOneArg("SHELLMSG31",font_name$),0,
shell_GetAppName,"")
!*|Stop PROCshell_DrawInitFont
$*|Start PROCshell_DrawSetUnitsMM
shell_DrawSetUnitsMM(buffer%)
|(buffer% + 12) = 1814.1732
#*|Stop PROCshell_DrawSetUnitsMM
$*|Start PROCshell_DrawSetUnitsCM
shell_DrawSetUnitsCM(buffer%)
|(buffer% + 12) = 18141.732
#*|Stop PROCshell_DrawSetUnitsCM
$*|Start PROCshell_DrawSetUnitsIN
shell_DrawSetUnitsIN(buffer%)
|(buffer% + 12) = 46080
#*|Stop PROCshell_DrawSetUnitsIN
$*|Start PROCshell_DrawSetUnitsOS
shell_DrawSetUnitsOS(buffer%)
|(buffer% + 12) = 256
#*|Stop PROCshell_DrawSetUnitsOS
$*|Start PROCshell_DrawSetUnitsPT
shell_DrawSetUnitsPT(buffer%)
|(buffer% + 12) = 640
#*|Stop PROCshell_DrawSetUnitsPT
(*|Start PROCshell_DrawSetPathPattern
shell_DrawSetPathPattern(buffer%,dashed%,offset,nr_el%,len)
pat_blk%,scl_fac
pat_blk% = buffer%!48
scl_fac = |(buffer% + 12)
$pat_blk%?0 = pat_blk%?0
1 << 7
dashed% = 0
& pat_blk%?0 = pat_blk%?0
1 << 7
"pat_blk%!04 = offset * scl_fac
pat_blk%!08 = nr_el%
"pat_blk%!12 = len * scl_fac
'*|Stop PROCshell_DrawSetPathPattern
(*|Start PROCshell_DrawGetBoundingBox
shell_DrawGetBoundingBox(buffer%,
xpos,
ypos,
width,
height,os_units%)
drawfile_start%,drawfile_size%,bbox_blk%,trans_matrix%,div%
*drawfile_start% = buffer% + buffer%!4
,drawfile_size% = buffer%!8 - buffer%!4
!trans_matrix% = buffer%!52
trans_matrix%!20 = 0
trans_matrix%!24 = 0
")bbox_blk% =
shell_HeapBlockFetch(16)
os_units% <> 0
div% = 256
div% = 1
"DrawFile_BBox",0,drawfile_start%,drawfile_size%,trans_matrix%,bbox_blk%
%"xpos = (bbox_blk%!00) / div%
&"ypos = (bbox_blk%!04) / div%
'0width = (bbox_blk%!08 - bbox_blk%!00)/ div%
(0height = (bbox_blk%!12 - bbox_blk%!04)/ div%
shell_HeapBlockReturn(bbox_blk%)
+'*|Stop PROCshell_DrawGetBoundingBox
-#*|Start FNshell_DrawGetFileSize
shell_DrawGetFileSize(buffer%)
= buffer%!8 - buffer%!4
1"*|Stop FNshell_DrawGetFileSize
3 *|Start FNshell_DrawFontName
shell_DrawFontName(ptr%,font%)
ft_table%,ft_end%,df_start%,font$,p%,ft_handle%,found%
ptr%!44 = -1
99,"No fonts have been initialised for this drawfile"
df_start% = ptr% + ptr%!4
ft_table% = ptr%!44 + ptr%
PROCshell_Tracef0("DEBUG::ft_table% = &"+STR$~ft_table%)
PROCshell_Tracef0("DEBUG::df_start% = &"+STR$~df_start%)
font% = 0
font$ = "System Font"
PROCshell_Tracef0("DEBUG::font table size is = "+STR$(ft_table%!4))
?* ft_end% = ft_table%!4 + ft_table%
@ p% = ft_table% + 8
B" ft_handle% = ?p% : p% += 1
C$ font$ =
shell_GetString(p%)
p% +=
font$ + 1
4 <> 0
p% +=1
G
ft_handle% = font%
I' found% =
: p% = ft_end% + 1
J
p% >= ft_end%
found% = 0
99,"Font not found in font table"
= font$
*|Stop FNshell_DrawFontName
Font routines
T!*|Start FNshell_FontGetHandle
shell_FontGetHandle(font$,x,y)
font%
"Font_FindFont",,font$,x * 16,y * 16,0,0
font%
= font%
Z *|Stop FNshell_FontGetHandle
\$*|Start PROCshell_FontForgetFont
shell_FontForgetFont(font%)
"Font_LoseFont",font%
a#*|stop PROCshell_FontForgetFont
c#*|start PROCshell_FontSetColour
shell_FontSetColour(fore%,back%)
"ColourTrans_SetFontColours",0,back%,fore%,14
h"*|stop PROCshell_FontSetColour
j$*|Start PROCshell_DrawRenderFile
shell_DrawRenderFile(buffer%,x%,y%,q%,bound%)
drawsc%,draw%,drawlen%
bound%=-1
bound% = 1
bound% = 0
drawsc% = buffer%!52
o"draw% = buffer% + buffer%!4
p$drawlen% = buffer%!8 - buffer%!4
drawsc%!16 = x% * 256
drawsc%!20 = y% * 256
"DrawFile_Render",bound%,draw%,drawlen%,drawsc%,q% + 28
drawsc%!16 = 0
drawsc%!20 = 0
x#*|Stop PROCshell_DrawRenderFile
*|Start PROCshell_DrawRenderFile
DEF PROCshell_DrawRenderFile(buffer%,x%,y%,x_scl,y_scl,q%,bound%)
LOCAL drawsc%,draw%,drawlen%
IF bound%=-1 THEN bound% = 1 ELSE bound% = 0
drawsc% = FNshell_HeapBlockFetch(24)
draw% = buffer% + buffer%!4
drawlen% = buffer%!8 - buffer%!4
!drawsc% = INT(65536 * x_scl)
drawsc%!04 = 0
drawsc%!08 = 0
drawsc%!12 = INT(65536 * y_scl)
drawsc%!16 = x% * 256
drawsc%!20 = y% * 256
SYS "DrawFile_Render",bound%,draw%,drawlen%,drawsc%,q% + 28
PROCshell_HeapBlockReturn(drawsc%)
ENDPROC
*|Stop PROCshell_DrawRenderFile
#*|Start PROCshell_DrawTextSpace
shell_DrawTextSpace(ptr%,text$,font%,ptsize,pthigh,
lx%,
by%,
rx%,
ty%)
handle%,xscale%,yscale%,r1%,r2%,r3%,r4%
font% > 0
"Font_FindFont",,
shell_DrawFontName(ptr%,font%),ptsize * 16, pthigh * 16
handle%
"Font_SetFont",handle%
"Font_StringBBox",,text$
,r1%,r2%,r3%,r4%
"Font_ReadScaleFactor"
,xscale%,yscale%
"Font_LoseFont",handle%
1 ty% =
shell_DrawTextCoord(by%,r4%,yscale%)
1 rx% =
shell_DrawTextCoord(lx%,r3%,xscale%)
1 by% =
shell_DrawTextCoord(by%,r2%,yscale%)
1 lx% =
shell_DrawTextCoord(lx%,r1%,xscale%)
) rx% = lx% + ptsize * 2.5 *
(text$)
ty% = by% + pthigh * 2.5
"*|Stop PROCshell_DrawTextSpace
!*|Start FNshell_DrawTextCoord
shell_DrawTextCoord(v%,r%,scale%) = (v% * scale% + r% +scale% / 2) / scale%
*|Stop FNshell_DrawTextCoord
'*|Start PROCshell_DrawSetEndCapNone
shell_DrawSetEndCapNone(buffer%)
style_blk%
style_blk% = buffer%!48
6style_blk%?0 = style_blk%?0
1 << 2 :
set bit 2
6style_blk%?0 = style_blk%?0
1 << 3 :
set bit 3
7style_blk%?0 = style_blk%?0
1 << 2 :
unset bit 2
7style_blk%?0 = style_blk%?0
1 << 3 :
unset bit 3
&*|Stop PROCshell_DrawSetEndCapNone
(*|Start PROCshell_DrawSetEndCapRound
shell_DrawSetEndCapRound(buffer%)
style_blk%
style_blk% = buffer%!48
6style_blk%?0 = style_blk%?0
1 << 2 :
set bit 2
6style_blk%?0 = style_blk%?0
1 << 3 :
set bit 3
7style_blk%?0 = style_blk%?0
1 << 3 :
unset bit 3
'*|Stop PROCshell_DrawSetEndCapRound
)*|Start PROCshell_DrawSetEndCapSquare
shell_DrawSetEndCapSquare(buffer%)
style_blk%
style_blk% = buffer%!48
6style_blk%?0 = style_blk%?0
1 << 2 :
set bit 2
6style_blk%?0 = style_blk%?0
1 << 3 :
set bit 3
7style_blk%?0 = style_blk%?0
1 << 2 :
unset bit 2
(*|Stop PROCshell_DrawSetEndCapSquare
+*|Start PROCshell_DrawSetEndCapTriangle
shell_DrawSetEndCapTriangle(buffer%,width%,len%)
style_blk%,path_width%
!path_width% = buffer%!32 / 16
style_blk% = buffer%!48
%width% = width% * |(buffer% + 12)
%len% = len% * |(buffer% + 12)
6style_blk%?0 = style_blk%?0
1 << 2 :
set bit 2
6style_blk%?0 = style_blk%?0
1 << 3 :
set bit 3
'style_blk%?2 = width% / path_width%
'style_blk%?3 = len% / path_width%
PROCshell_Tracef0("DEBUG:: path width is "+STR$path_width%)
**|Stop PROCshell_DrawSetEndCapTriangle
)*|Start PROCshell_DrawSetStartCapNone
shell_DrawSetStartCapNone(buffer%)
style_blk%
style_blk% = buffer%!48
6style_blk%?0 = style_blk%?0
1 << 4 :
set bit 4
6style_blk%?0 = style_blk%?0
1 << 5 :
set bit 5
7style_blk%?0 = style_blk%?0
1 << 4 :
unset bit 4
7style_blk%?0 = style_blk%?0
1 << 5 :
unset bit 5
(*|Stop PROCshell_DrawSetStartCapNone
**|Start PROCshell_DrawSetStartCapRound
shell_DrawSetStartCapRound(buffer%)
style_blk%
style_blk% = buffer%!48
6style_blk%?0 = style_blk%?0
1 << 4 :
set bit 4
6style_blk%?0 = style_blk%?0
1 << 5 :
set bit 5
7style_blk%?0 = style_blk%?0
1 << 5 :
unset bit 5
)*|Stop PROCshell_DrawSetStartCapRound
+*|Start PROCshell_DrawSetStartCapSquare
shell_DrawSetStartCapSquare(buffer%)
style_blk%
style_blk% = buffer%!48
6style_blk%?0 = style_blk%?0
1 << 4 :
set bit 4
6style_blk%?0 = style_blk%?0
1 << 5 :
set bit 5
7style_blk%?0 = style_blk%?0
1 << 4 :
unset bit 4
**|Stop PROCshell_DrawSetStartCapSquare
-*|Start PROCshell_DrawSetStartCapTriangle
shell_DrawSetStartCapTriangle(buffer%,width%,len%)
style_blk%,path_width%
style_blk% = buffer%!48
!path_width% = buffer%!32 / 16
%width% = width% * |(buffer% + 12)
%len% = len% * |(buffer% + 12)
6style_blk%?0 = style_blk%?0
1 << 4 :
set bit 4
6style_blk%?0 = style_blk%?0
1 << 5 :
set bit 5
'style_blk%?2 = width% / path_width%
'style_blk%?3 = len% / path_width%
PROCshell_Tracef0("DEBUG:: path width is "+STR$path_width%)
,*|Stop PROCshell_DrawSetStartCapTriangle
"*|Start PROCshell_DrawSetScale
shell_DrawSetScale(buffer%,xscl,yscl)
matrix%
matrix% = buffer%!52
matrix%!00 =
(65536 * xscl)
matrix%!12 =
(65536 * yscl)
!*|Stop PROCshell_DrawSetScale
"*|Start PROCshell_DrawGetScale
shell_DrawGetScale(buffer%,
xscl,
yscl)
matrix%
matrix% = buffer%!52
xscl = matrix%!00 / 65536
yscl = matrix%!12 / 65536
!*|Stop PROCshell_DrawGetScale
&*|Start PROCshell_DrawResizeWindow
shell_DrawResizeWindow(buffer%,wh%,lm%,bm%,rm%,tm%)
xpos,ypos,width,height
shell_DrawGetBoundingBox(buffer%,xpos,ypos,width,height,
shell_WindowResize(wh%,0,- (tm% + bm% + height + ypos),width + lm% + rm%,0,0)
&%*|Stop PROCshell_DrawResizeWindow
('*|Start PROCshell_DrawScaleToWindow
shell_DrawScaleToWindow(buffer%,wh%,lm%,bm%,rm%,tm%,
xscl,
yscl)
xpos,ypos,width,height,w_blk%,w_width%,w_height%,o_xscl,o_yscl
shell_DrawSetScale(buffer%,o_xscl,o_yscl)
shell_DrawSetScale(buffer%,1,1)
shell_DrawGetBoundingBox(buffer%,xpos,ypos,width,height,
.'w_blk% =
shell_HeapBlockFetch(36)
!w_blk% = wh%
"Wimp_GetWindowState",,w_blk%
1Aw_width% = (w_blk%!12 - w_blk%!04 + w_blk%!20) - (lm% + rm%)
2Aw_height% = (w_blk%!16 - w_blk%!08 + w_blk%!24) - (tm% + bm%)
3*xscl = (w_width% / (width - 0))
4*yscl = (w_height% / (height - 0))
PROCshell_Tracef0(">>> "+STR$w_width%)
PROCshell_Tracef0(">>> "+STR$width)
PROCshell_Tracef0(">>> "+STR$w_height%)
PROCshell_Tracef0(">>> "+STR$height)
PROCshell_Tracef0(">>> xscl "+STR$xscl)
PROCshell_Tracef0(">>> yscl "+STR$yscl)
shell_HeapBlockReturn(w_blk%)
shell_DrawSetScale(buffer%,o_xscl,o_yscl)
?&*|Stop PROCshell_DrawScaleToWindow