外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。
javaで2重線を引く(2sen)
:javaで2重線を引く(2sen)
@echo off
if not exist %~dp0SenDraw.class (
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
more +%%n %0 > %~dpn0.java
javac -encoding shift_jis %~dpn0.java
)
)
set w=%1
if not defined w (
set w=200
goto exe
)
if %1==1 set w=200
if %1==2 set w=400
if %1==3 set w=120
if %1==4 set w=150
if %1==5 set w=180
if %1==6 set w=220
if %1==7 set w=250
if %1==8 set w=300
if %1==9 set w=350
:exe
copy jwc_temp.txt myfiles > nul
java -Dfile.encoding=shift_jis -classpath %~dp0 SenDraw > jwc_temp.txt
goto:eof
REM #jww
REM #1-%d 始点を指示してください
REM #2%d 終点を指示してください
REM #k 線の幅| 200(L) | 400(R) | 120 | 150 | 180 | 220 | 250 | 300 | 350 |
REM #e
#!この次の行からプログラムを書いてください
import java.io.*;
import java.util.regex.Pattern;
class SenDraw {
public static void main(String args) {
double w = Double.parseDouble(System.getenv("w"));
try {
BufferedReader f = new BufferedReader(new FileReader("myfiles"));
String line;
int i = 0;
String hp = new String[10];
while ( (line = f.readLine()) != null) {
if (Pattern.compile("^hp[1-9][0-9]*").matcher(line).find()) {
String str = line.split(" ", 2);
i = Integer.parseInt(str[0].replaceAll("^hp|-$", ""));
hp[i] = str[1].trim();
}
}
f.close();
double x1, y1, x2, y2, d, xw, yw;
String p = hp[1].split(" ");
x1 = Double.parseDouble(p[0]);
y1 = Double.parseDouble(p[1]);
String[] q = hp[2].split(" ");
x2 = Double.parseDouble(q[0]);
y2 = Double.parseDouble(q[1]);
d = Math.atan2(y2 - y1, x2 - x1);
xw =-w / 2 * Math.sin(d);
yw = w / 2 * Math.cos(d);
System.out.printf("%.15f %.15f %.15f %.15f%n", x1 + xw, y1 + yw, x2 + xw, y2 + yw);
if (w != 0.0) {
System.out.printf("%.15f %.15f %.15f %.15f%n", x1 - xw, y1 - yw, x2 - xw, y2 - yw);
}
String mode = "長穴";
if (mode.equals("長穴") && (w != 0.0)) {
double a = d * 180.0 / Math.PI + 90.0;
double r = w / 2.0;
System.out.printf("ci %.15f %.15f %.15f %.15f %.15f %.15f %.15f%n", x1, y1, r, a, a+180.0, 1.0, 0.0);
System.out.printf("ci %.15f %.15f %.15f %.15f %.15f %.15f %.15f%n", x2, y2, r, a-180.0, a, 1.0, 0.0);
}
} catch (IOException e) {
System.out.println(e);
}
}
}