How can I set LineWidth property when using opengl?
Show older comments
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');
Answers (1)
Image Analyst
on 28 Apr 2014
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 Comments
Andreas
on 29 Apr 2014
Image Analyst
on 29 Apr 2014
Maybe you could post an image of what your desired output would look like to help us visualize.
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!