How can I set LineWidth property when using opengl?
이전 댓글 표시
I am trying to plot a few simple geometries. One of them with a color gradient which switches the renderer to opengl. A simple test script is below. The rectangle is first drawn with a wide line width, but then changed once the fill is drawn
clear all,close all
color1 = [1 1 0];
color2 = [1 0 0];
rh=rectangle('Position',[0 0 60 60],'LineWidth',30,'EdgeColor',[0.5 0.5 0.5]);
hold on
%%the following command will switch the renderer and change the rectangle line width
fh=fill([10 20 20],[10 5 15],1,'FaceColor','interp','FaceVertexCData', [color1;color2;color2],'LineStyle','none');
답변 (1개)
Image Analyst
2014년 4월 28일
I believe fill() creates another graphics object in the overlay on top of the first one you drew with rectangle. Why don't you set the 'FaceColor' property of the rectangle? Though with an absurd line width of the edge of 30, with a rectangle that's only 60 high, you probably won't see the face unless you reduce the line width to something reasonable.
Try this:
color1 = [1 1 0];
color2 = [1 0 0];
rh = rectangle('Position',[0 0 60 60],...
'LineWidth', 15,...
'EdgeColor',[0 0.5 1], ...
'FaceColor', [1, 0, 1]);
hold on;
fh=fill([10 20 20],[10 5 15],1,'FaceColor','interp','FaceVertexCData', [color1;color2;color2],'LineStyle','none');% Enlarge figure to top half of the screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0.5 1 0.5]);
Does that do close to what you want?
댓글 수: 2
Andreas
2014년 4월 29일
Image Analyst
2014년 4월 29일
Maybe you could post an image of what your desired output would look like to help us visualize.
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!