Created
July 20, 2021 07:39
-
-
Save AJpon/e63b12a8b03ecd5db65c5ca36655fc2f to your computer and use it in GitHub Desktop.
Cinema 4D の Sketch and Toon で書き出した illustrator 形式のファイルを SVG に変換
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import processing.svg.*; | |
String[] lines; | |
void setup() { | |
// スケッチのサイズはC4Dのレンダリング解像度と同じにしてください | |
size(1280, 720); | |
noFill(); | |
noLoop(); | |
strokeWeight(0.1); | |
lines = loadStrings("SketchAndToon.ai"); | |
beginRecord(SVG, "output.svg"); | |
} | |
void draw() { | |
for (String str : lines) { | |
String[] parts = str.split(" "); | |
String tail = parts[parts.length-1]; | |
if (tail.equals("m")) { | |
noFill(); | |
beginShape(); | |
vertex(float(parts[0]), float(parts[1])); | |
} else if (tail.equals("L")) { | |
vertex(float(parts[0]), float(parts[1])); | |
} else if (tail.equals("S")) { | |
endShape(); | |
} else if (tail.equals("s")) { | |
endShape(CLOSE); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment