Matlab - how to draw pixels on a black full screen?

前端 未结 3 1714
耶瑟儿~
耶瑟儿~ 2021-01-13 06:27

I want matlab to show me a full screen, all black, and to be able to set pixels on it.

Is it even possible?

3条回答
  •  执念已碎
    2021-01-13 07:04

    You can't totally do that using pure MATLAB code. On Windows, I tried different combinations, but the taskbar will still be on top (the one with the Start button):

    %# 1)
    sz = get(0, 'ScreenSize');
    figure('Menubar','none', 'WindowStyle','modal', ...
        'Units','pixels', 'Position', [0 0 sz(3) sz(4)])
    
    %# 2)
    figure('Menubar','none', 'Units','normalized', 'Position',[0 0 1 1])
    
    %# 3)
    hFig = figure('Menubar','none', 'Units','normalized', 'Position',[0 0 1 1]);
    set(hFig, 'Units','pixels')
    p = get(hFig, 'Position');
    set(hFig, 'Position', [1 31 p(3) p(4)-8]);
    

    You would have to write a MEX function and call the the Win32 API directly. Fortunately, there should be existing submissions on FEX implementing such functionality.


    Here is an example of creating a full screen figure, and drawing points with the mouse. I am using the WindowAPI solution by Jan Simon

    %# open fullscreen figure
    hFig = figure('Menubar','none');
    WindowAPI(hFig, 'Position','full');
    
    %# setup axis
    axes('Color','k', 'XLim',[0 1], 'YLim',[0 1], ...
        'Units','normalized', 'Position',[0 0 1 1], ...
        'ButtonDownFcn',@onClick)
    

    The callback function:

    function onClick(hObj,ev)
        %# draw point
        p  = get(hObj,'CurrentPoint');
        line(p(1,1), p(1,2), 'Color','r', 'LineStyle','none', ...
            'Marker','.', 'MarkerSize',40, 'Parent',hObj)
    end
    

提交回复
热议问题