File: xstringl.sci

package info (click to toggle)
scilab 5.3.3-10
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 330,656 kB
file content (51 lines) | stat: -rw-r--r-- 1,722 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2008 - INRIA - Jean-Baptiste Silvy
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at    
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt

//=======================================================================
// File   : xstringl.sci
// Desc   : Compute the bounding rectangle of a text
//          (old version of stringbox)
//======================================================================

function [rect] = xstringl( varargin )

// the call is rect=xstringl(x,y,str,[fontId,fontSize]) 

[lhs,rhs] = argn(0) ;
listArg = varargin ;

// rect = xstringl(x,y,str,[fontId,fontSize])

select rhs,
  case 3 then
    // stringbox(str, x, y)
    corners = stringbox(listArg (3), listArg (1), listArg (2));
  case 4 then
    // stringbox(str, x, y, angle = 0, fontId)
    corners = stringbox(listArg (3), listArg (1), listArg (2), 0, listArg (4));
  case 5 then
    // stringbox(str, x, y, angle = 0, fontId, fontSize);
    corners = stringbox(listArg (3), listArg (1), listArg (2), 0, listArg (4), listArg (5));
  else
    // incorrect number of input argmuments
    error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."), "xstringl", 3, 5));
    return ;
end;

// convert corners into position and size
// position, upper-left point
rect(1) = corners (1,2); // x
rect(2) = corners (2,2); // y

// size width, height
rect(3) = abs(corners(1,3) - corners(1,1));
rect(4) = abs(corners(2,3) - corners(2,1));


endfunction