円形、扇形ホットポイント作成サブルーチン
というわけで、前々からなんとなく作りたくなってちまちまと作っていた、円形のホットポイントを作成するサブルーチンが一応形になったので晒してみる。
実際には円形だけでなく、扇形やドーナツ型も作れます。
いや、需要があるかどうかはわかりませんが、とにかく作ってみたくなったので。
以下にソース。角度始点、角度終点は度で0〜360°までが有効です。しかし始点終点てわかりにくいな……。
あとコメントアウトされているLineコマンドはデバッグのためのものです。
コメントアウトを外せば、ホットポイントが作成された部分が赤くなります。
# Circle_HotPoint "ホットポイント名称" "ホットポイント解説" "中心X" "中心Y" "長辺" "短辺" "角度始点" "角度終点" Circle_HotPoint: Local Upper Bottom StartRad EndRad StartX EndX StartDeg EndDeg SlopeL SlopeR BaseX = Args(3) BaseY = Args(4) # 第一象限、第二象限にホットポイント作成 If Args(7) < 180 Then # 角度の始点終点を調節 If Args(8) > 180 Then EndDeg = 180 Else EndDeg = Args(8) Endif StartDeg = Args(7) StartRad = 3.141592 * StartDeg / 180 EndRad = 3.141592 * EndDeg / 180 # 開始X座標と終了X座標を設定 If Args(8) >= 90 Then StartX = Int(Cos(EndRad) * Args(5)) Else StartX = Int(Cos(EndRad) * Args(6)) Endif If Args(7) >= 90 Then EndX = Int(Cos(StartRad) * Args(6)) Else EndX = Int(Cos(StartRad) * Args(5)) Endif # 境界線の傾きを算出 SlopeR = Sin(StartRad) / Cos(StartRad) SlopeL = Sin(EndRad) / Cos(EndRad) For i = StartX to EndX If i >= 0 Then If i > (Cos(StartRad) * Args(6)) Then Bottom = SlopeR * i Else Bottom = Int( Sqr( Args(6) * Args(6) - i * i ) ) Endif Upper = Int( Sqr( Args(5) * Args(5) - i * i ) ) If Args(8) <= 90 Then Upper = Min(Upper, SlopeL * i) Endif Else If i < (Cos(EndRad) * Args(6)) Then Bottom = SlopeL * i Else Bottom = Int( Sqr( Args(6) * Args(6) - i * i ) ) Endif Upper = Int( Sqr( Args(5) * Args(5) - i * i ) ) If Args(7) >= 90 Then Upper = Min(Upper, SlopeR * i) Endif Endif HotPoint Args(1) i (Upper * -1) 1 Abs(Upper - Bottom) Args(2) # Line i (Upper * -1) i (Bottom * -1) #ff0000 Next Endif # 第三象限、第四象限にホットポイント作成 If Args(8) > 180 Then # 角度の始点終点を調節 If Args(7) < 180 Then StartDeg = 180 Else StartDeg = Args(7) Endif EndDeg = Args(8) StartRad = 3.141592 * StartDeg / 180 EndRad = 3.141592 * EndDeg / 180 # 開始X座標と終了X座標を設定 If Args(8) >= 270 Then EndX = Int(Cos(EndRad) * Args(5)) Else EndX = Int(Cos(EndRad) * Args(6)) Endif If Args(7) >= 270 Then StartX = Int(Cos(StartRad) * Args(6)) Else StartX = Int(Cos(StartRad) * Args(5)) Endif # 境界線の傾きを算出 SlopeL = Sin(StartRad) / Cos(StartRad) SlopeR = Sin(EndRad) / Cos(EndRad) For i = StartX to EndX If i > 0 Then If i > (Cos(EndRad) * Args(6)) Then Upper = SlopeR * i * -1 Else Upper = Int( Sqr( Args(6) * Args(6) - i * i ) ) Endif Bottom = Int( Sqr( Args(5) * Args(5) - i * i ) ) If Args(7) >= 270 Then Bottom = Min(Bottom, SlopeL * i * -1) Endif Else If i < (Cos(StartRad) * Args(6)) Then Upper = SlopeL * i * -1 Else Upper = Int( Sqr( Args(6) * Args(6) - i * i ) ) Endif Bottom = Int( Sqr( Args(5) * Args(5) - i * i ) ) If Args(8) < 270 Then Bottom = Min(Bottom, SlopeR * i * -1) Endif Endif HotPoint Args(1) i Upper 1 Abs(Upper - Bottom) Args(2) # Line i Upper i Bottom #ff0000 Next Endif Return