Matlab

Matlabコードスクリーンショット生成

Matlabのスニペットを、Macから離れることなく共有したくなる画像に。

MATLAB code is usually posted alongside a figure, which means the code image and the plot are read as a pair.

Codeshotは貼り付けたコードからMatlabを判別するので、言語の選び間違いは起きません。付属する30種類のうち3つのテーマで同じスニペットを、アプリ自身のスタイルシートで表示しています。

function img = exportSnapshot(code, theme, scale)
    arguments
        code   (1,:) char
        theme  (1,:) char = 'xcode'
        scale  (1,1) double = 2
    end

    img = render(code, theme);
    imwrite(imresize(img, scale), 'snapshot.png');
end
Edge · ダーク
function img = exportSnapshot(code, theme, scale)
    arguments
        code   (1,:) char
        theme  (1,:) char = 'xcode'
        scale  (1,1) double = 2
    end

    img = render(code, theme);
    imwrite(imresize(img, scale), 'snapshot.png');
end
GitHub · ダーク
function img = exportSnapshot(code, theme, scale)
    arguments
        code   (1,:) char
        theme  (1,:) char = 'xcode'
        scale  (1,1) double = 2
    end

    img = render(code, theme);
    imwrite(imresize(img, scale), 'snapshot.png');
end
Solarized · ダーク

Matlabに合うテーマ選び

Match the width of the code image to the figure beside it. Two images of different widths in one post looks like an accident.

サイズを正しく決める

画像サイズを内容に合わせるか、比率で固定します(1:1、4:3、3:2、16:9、9:16、2:3、3:4)。そのうえで1×・2×・3×から選んで書き出せば、Retinaディスプレイでも鮮明なままです。Cでクリップボードに直接コピー、またはSで保存できます。

30種類のテーマを見比べるか、全体の流れをご覧ください。

Matlabと、ほかの59言語のために

すべてMac上で動作します。コードが外に出ることはありません。

macOS版をダウンロード