Post Reply 
A simple graphics rectangle? My coordinates are wrong
06-05-2016, 08:35 AM (This post was last modified: 06-05-2016 08:37 AM by StephenG1CMZ.)
Post: #5
RE: A simple graphics rectangle? My coordinates are wrong
Thanks for your insights guys...
This version seems much clearer.
One known bug for me to look into in this code if it becomes necessary:
If border width is changed to 0 a border still appears.

Code:


 LOCAL Y0:=0;
 LOCAL BWIDTH:=8; //FRAME OR BORDER
 //KNOWN BUG:A WIDTH OF 0 STILL GIVES A BORDER
 
 LOCAL XLEN:=255; //255;
 LOCAL YLEN:=192; //192; //OR 175 MAIN AREA
 //INNER RECT IS XLEN*YLEN
 LOCAL BORDERU,BORDERD,BORDERL,BORDERR,SCRN;
 LOCAL COLRB:=RGB(0,0,#CDh);
 LOCAL COLRS:=RGB(0,#CDh,0);

 INITS()
 BEGIN
  BORDERU:={0,Y0,             XLEN+2*BWIDTH-1,Y0+BWIDTH-1};
  BORDERD:={0,Y0+BWIDTH+YLEN, XLEN+2*BWIDTH-1,Y0+YLEN+2*BWIDTH-1};
  BORDERL:={0,Y0+BWIDTH,      BWIDTH-1,Y0+YLEN+BWIDTH-1};
  BORDERR:={XLEN+BWIDTH,Y0,   XLEN+2*BWIDTH-1,Y0+YLEN+2*BWIDTH-1};
  SCRN:=   {BWIDTH,Y0+BWIDTH, XLEN+BWIDTH-1,Y0+YLEN+BWIDTH-1,COLRS};
 END;

 DRAW_BORDER()
 BEGIN
  RECT_P(BORDERU(1),BORDERU(2),BORDERU(3),BORDERU(4),COLRB);
  RECT_P(BORDERR(1),BORDERR(2),BORDERR(3),BORDERR(4),COLRB);
  RECT_P(BORDERD(1),BORDERD(2),BORDERD(3),BORDERD(4),COLRB);
  RECT_P(BORDERL(1),BORDERL(2),BORDERL(3),BORDERL(4),COLRB);
  WAIT;
 END;

 DRAW_SCREEN()
 BEGIN
  RECT_P(SCRN(1),SCRN(2),SCRN(3),SCRN(4),COLRS);
 END;

 
 EXPORT BORDER()
 BEGIN
  RECT_P();
  INITS();
  DRAW_BORDER();
  DRAW_SCREEN();
  FREEZE; 
 END;

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: A simple graphics rectangle? My coordinates are wrong - StephenG1CMZ - 06-05-2016 08:35 AM



User(s) browsing this thread: 1 Guest(s)