drawBezier

PURPOSE ^

drawBezier Draw a bezier curve in a figure

SYNOPSIS ^

function drawBezier(p,color,weight)

DESCRIPTION ^

drawBezier Draw a bezier curve in a figure

 drawBezier(p,color,weight)

INPUT
 p         Coordinates
 color     Color of bezier curve
 weight    Weight of bezier curve

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function drawBezier(p,color,weight)
0002 %drawBezier Draw a bezier curve in a figure
0003 %
0004 % drawBezier(p,color,weight)
0005 %
0006 %INPUT
0007 % p         Coordinates
0008 % color     Color of bezier curve
0009 % weight    Weight of bezier curve
0010 %
0011 global CB_MAP_OUTPUT
0012 global mapHandle
0013 if nargin < 2
0014     color = [0 0 255];
0015     display('No color specified');
0016 end
0017 numpoints = 50;
0018 %a = zeros(2,numpoints);
0019 %b = zeros(2,numpoints);
0020 %c = zeros(2,numpoints);
0021 i = 0:numpoints;
0022 a = (p(:,1)* i + p(:,2)*(numpoints-i))/numpoints;
0023 b = (p(:,2)* i + p(:,3)*(numpoints-i))/numpoints;
0024 c = (a .* (ones(2,1)* i) + b .*(ones(2,1)  *(numpoints-i)))  /numpoints;
0025 if strcmp(CB_MAP_OUTPUT, 'matlab')
0026     if find(color>1)
0027         color = color/255;
0028     end
0029     line(c(1,:), -c(2,:),'Color',color,'LineWidth',weight);
0030 elseif strcmp(CB_MAP_OUTPUT, 'java')
0031     %line(c(1,:), c(2,:),'Color',color,'LineWidth',weight);
0032     % fill in code
0033      setDataBezier(mapHandle,c(1,:),c(2,:));
0034 elseif strcmp(CB_MAP_OUTPUT, 'svg')    
0035     %determine type of color input
0036     if ischar(color)
0037         colorStroke = color;
0038     else if isvector(color)
0039             colorStroke = strcat('rgb(',num2str(color(1)),',',num2str(color(2)),',',num2str(color(3)),')');
0040         end
0041     end
0042     fprintf(mapHandle,'<g id="" stroke="%s" stroke-width="%d" stroke-linecap="round">\n',colorStroke,ceil(weight));
0043 %     fprintf(mapHandle,'<g id="" stroke="deepskyblue" stroke-width="6" stroke-linecap="round">\n');
0044     %fprintf(mapHandle,'<path style="fill: none;" d="M%8.2f %8.2f C%8.2f %8.2f %8.2f %8.2f %8.2f %8.2f"/>\n',p2(1),-p2(2),p2(1),-p2(2),ptemp(1),-ptemp(2),p1(1),-p1(2));
0045     fprintf(mapHandle,'<path style="fill: none;" d="M%8.2f %8.2f C%8.2f %8.2f %8.2f %8.2f %8.2f %8.2f"/>\n',p(1,3),p(2,3) ,p(1,3),p(2,3),p(1,2),p(2,2),p(1,1),p(2,1));
0046     fprintf(mapHandle,'</g>\n');
0047 else
0048     display('error CB_MAP_OUTPUT in bezier');
0049 end
0050

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003