Files
TempleOS-Rijn/Demo/Graphics/Extents.HC
T
2018-09-08 21:47:50 +02:00

54 lines
1.1 KiB
HolyC

//Test image which we will determine the extents of.
$SP,"<1>",BI=1$
U0 Extents()
{
CDC *dc=DCAlias;
I64 min_x,max_x,min_y,max_y;
//Screen, not window coordinates.
I64 h=Fs->pix_left+Fs->scroll_x,v=Fs->pix_top+Fs->scroll_y;
DocClear;
DCFill;
//This sets a flag to record the
//extents of what we draw and inits
//the max's and min's. Vals are
//screen coordinates.
DCExtentsInit(dc);
dc->pen_width=3;
Sprite3(dc,40,GR_HEIGHT>>1,0,$IB,"<1>",BI=1$);
dc->color=LTRED;
dc->pen_width=1;
//This box is the extents.
GrLine(dc,dc->min_x-h,dc->min_y-v,dc->max_x-h,dc->min_y-v);
GrLine(dc,dc->min_x-h,dc->min_y-v,dc->min_x-h,dc->max_y-v);
GrLine(dc,dc->max_x-h,dc->max_y-v,dc->max_x-h,dc->min_y-v);
GrLine(dc,dc->max_x-h,dc->max_y-v,dc->min_x-h,dc->max_y-v);
DCDel(dc);
PressAKey;
DCFill;
SpriteExtents($IB,"<1>",BI=1$,&min_x,&max_x,&min_y,&max_y);
"X: %d to %d\n",min_x,max_x;
"Y: %d to %d\n",min_y,max_y;
}
Extents;
œ
#øÿÿÿ
#øÿÿÿ1
1 "
"
**
*
þÿÿÿ
þÿÿÿ*õÿÿÿôÿÿÿHello