Mathematica

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

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

Wolfram 言語は冗長ですが、色がつけば読みやすく、プレーンテキストで貼るとどこでも読みにくくなります。

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

exportSnapshot[code_String, OptionsPattern[]] :=
  Module[{img, theme = OptionValue["Theme"]},
    img = render[code, theme];
    Export["snapshot.png", img, ImageResolution -> 144]
  ]
GitHub · ダーク
exportSnapshot[code_String, OptionsPattern[]] :=
  Module[{img, theme = OptionValue["Theme"]},
    img = render[code, theme];
    Export["snapshot.png", img, ImageResolution -> 144]
  ]
iA · ダーク
exportSnapshot[code_String, OptionsPattern[]] :=
  Module[{img, theme = OptionValue["Theme"]},
    img = render[code, theme];
    Export["snapshot.png", img, ImageResolution -> 144]
  ]
Solarized · ダーク

Mathematicaに合うテーマ選び

ここでは括弧の種類が意味を持ちます。角括弧、波括弧、二重角括弧はそれぞれ違います。これらを一色に潰さないテーマを選んでください。

サイズを正しく決める

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

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

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

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

ダウンロード