0001 function drawBezier(p,color,weight)
0002
0003
0004
0005
0006
0007
0008
0009
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
0019
0020
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
0032
0033 setDataBezier(mapHandle,c(1,:),c(2,:));
0034 elseif strcmp(CB_MAP_OUTPUT, 'svg')
0035
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
0044
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