rect Subroutine

public subroutine rect(x1, y1, x2, y2)

NAME

  rect(3f) - [M_pixel:POLYGON] draw rectangle given two corners
  (LICENSE:PD)

SYNOPSIS

definition:

subroutine rect(x1,y1, x2,y2)
real,intent(in) :: x1,y1,x2,y2

DESCRIPTION

Draw rectangle given two opposite corners.

OPTIONS

X1,Y1  coordinates of a corner of the rectangle
X2,Y2  coordinates of corner point opposite first point

EXAMPLE

Sample program:

program demo_rect
use M_pixel
use M_pixel__writegif, only : writegif
implicit none
   integer :: i

   !! set up graphics area
   call prefsize(400,400)
   call vinit()
   call ortho2(left=-100.0, right=100.0, bottom=-100.0, top=100.0)

   !! draw some filled rectangles
   do i=95,5,-10
      call makepoly()
      call color(i/10)
      call rect( -1.0*i, -1.0*i, 1.0*i, 1.0*i )
      call closepoly()
   enddo

   !! draw some rectangles
   call linewidth(50)
   call color(7)
   do i=5,95,5
      call rect( -1.0*i, -1.0*i, 1.0*i, 1.0*i )
   enddo

   !! render pixel array to a file
   call writegif('rect.3m_pixel.gif',P_pixel,P_colormap)

   !! display graphic assuming display(1) is available
   call execute_command_line('display rect.3m_pixel.gif')

   !! wrap up graphics
   call vexit()

end program demo_rect

AUTHOR

John S. Urban

LICENSE

Public Domain

Arguments

Type IntentOptional Attributes Name
real, intent(in) :: x1
real, intent(in) :: y1
real, intent(in) :: x2
real, intent(in) :: y2

Contents

Source Code


Source Code

subroutine rect(x1,y1, x2,y2)

! ident_1="@(#) M_pixel rect(3f) draw line rectangle given two opposite corners"

!
!  x1,y1 ############ x2,y1
!        #          #
!        #          #
!        #          #
!  x1,y2 ############ x2,y2
!

real,intent(in)            :: x1,y1,x2,y2

   call move2(x1,y1)
   call draw2(x1,y2)
   call draw2(x2,y2)
   call draw2(x2,y1)
   call draw2(x1,y1)

end subroutine rect