GLE Library: ellipse.gle

! Subroutines for drawing ellipses around text and other objects

include "shape.gle"

ellipse_c = 0.25
ellipse_wd = -1
ellipse_hi = -1

sub set_ellipse_c c
   ellipse_c = c
end sub

sub set_ellipse_size wd hi
   ellipse_wd = wd
   ellipse_hi = hi
end sub

sub set_ellipse_size_str txt$
   ellipse_wd = twidth(txt$)+2*shape_dx
   ellipse_hi = theight(txt$)+2*shape_dy
end sub

sub ellipsebox x y w h name$
   local a = 0
   local a1 = h/(2*ellipse_c)
   if a < a1 then a = a1
   local a2 = w/2
   if a < a2 then a = a2
   local a3 = sqrt(w^2+h^2/ellipse_c^2)/2
   if a < a3 then a = a3
   local a4 = sqrt(h^2+w^2*ellipse_c^2)/(4*ellipse_c)
   if a < a4 then a=a4
   amove x+w/2-a y+h/2-ellipse_c*a
   box 2*a 2*ellipse_c*a name name$ nobox fill clear
   amove x+w/2 y+h/2
   ellipse a ellipse_c*a
end sub

sub ellipse_obj obj$ name$
   local xp = pointx(obj$+".bl")-shape_dx
   local yp = pointy(obj$+".bl")-shape_dy
   local w = width(obj$)+2*shape_dx
   local h = height(obj$)+2*shape_dy
   ellipsebox xp yp w h name$
end sub

sub ellipse_text x y txt$ name$
   local tw = twidth(txt$)+2*shape_dx
   local th = theight(txt$)+2*shape_dy
   if ellipse_wd <> -1 then tw = ellipse_wd
   if ellipse_hi <> -1 then th = ellipse_hi
   ellipsebox x-tw/2 y-th/2 tw th name$
   amove x y
   set just cc
   write txt$
end sub

sub ellipse_tex x y txt$ name$
   local txt2$ = "\tex{"+txt$+"}"
   ellipse_text x y txt2$ name$
end sub

sub def_ellipse_text txt$ name$
   local tw = twidth(txt$)+2*shape_dx
   local th = theight(txt$)+2*shape_dy
   if ellipse_wd <> -1 then tw = ellipse_wd
   if ellipse_hi <> -1 then th = ellipse_hi
   begin object name$
      ellipsebox -tw/2 -th/2 tw th "x"
      set just cc
      write txt$
   end object
end sub

sub def_ellipse_tex txt$ name$
   local txt2$ = "\tex{"+txt$+"}"
   def_ellipse_text txt2$ name$
end sub

 

[Return to subroutines page]