No.1ベストアンサー
- 回答日時:
' とりあえずいい加減にやった。
質問文中の図と上下逆だったりするので適当にソース弄って調整してください。' …なんかもっとすっきりしたコード書けそうなんだけどなあ
Option Explicit On
Option Strict On
Imports System
Public Class Q7371104
Public Shared Sub Main()
Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(500,500)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bmp)
'こっちのほうがわかりやすいかなと。
g.Clear(System.Drawing.Color.Black)
Dim path1 As System.Drawing.Drawing2D.GraphicsPath = New System.Drawing.Drawing2D.GraphicsPath()
Dim path2 As System.Drawing.Drawing2D.GraphicsPath = New System.Drawing.Drawing2D.GraphicsPath()
Dim path3 As System.Drawing.Drawing2D.GraphicsPath = New System.Drawing.Drawing2D.GraphicsPath()
path1.AddEllipse(0, 0, 200,200)
path2.AddEllipse(100, 0, 200,200)
'引数は整数らしいのでやむなく。
path3.AddEllipse(50,Convert.ToInt32(50 * Math.Sqrt(3)),200,200)
' Region.Excludeとかやってもいいけど面倒なので。
g.FillPath(New System.Drawing.SolidBrush(System.Drawing.Color.Red),path1)
g.FillPath(New System.Drawing.SolidBrush(System.Drawing.Color.Blue),path2)
g.FillPath(New System.Drawing.SolidBrush(System.Drawing.Color.Green),path3)
Dim r1 As System.Drawing.Region = New System.Drawing.Region(path1)
r1.Intersect(path2)
Dim r2 As System.Drawing.Region = New System.Drawing.Region(path1)
r2.Intersect(path3)
Dim r3 As System.Drawing.Region = New System.Drawing.Region(path2)
r3.Intersect(path3)
Dim r4 As System.Drawing.Region = New System.Drawing.Region(path1)
r4.Intersect(path2)
r4.Intersect(path3)
g.FillRegion(New System.Drawing.SolidBrush(System.Drawing.Color.Magenta),r1)
g.FillRegion(New System.Drawing.SolidBrush(System.Drawing.Color.Yellow),r2)
g.FillRegion(New System.Drawing.SolidBrush(System.Drawing.Color.Cyan),r3)
g.FillRegion(New System.Drawing.SolidBrush(System.Drawing.Color.White),r4)
g.Save()
'ファイル名とかはお好みでどうぞ
bmp.Save("D:\test.bmp")
End Sub
End Class
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- 大学受験 高校の科目変更されたことについてです 例えば世界史 私は世界史bしか勉強していないのですが、科目変更 2 2022/04/07 12:02
- iPhone(アイフォーン) AppleCare+ 盗難・紛失プラン for iPhone 14 Pro 12 か月ごとに、過失や 3 2022/09/16 17:30
- YouTube 新しく買ったデスクトップPCを使用すると、今までのGoogleのアカウントが使えなくなった。 1 2023/01/07 00:41
- au(KDDI) auデータ移行の有料化について… 先日、auショップにてスマホ機種変更の見積もりを取りました。 他に 6 2022/04/28 14:09
- その他(趣味・アウトドア・車) 個人売買のトラブルについて。 自動車の個人売買をしました。 こちらが売る側です。 相手に名義変更をす 4 2022/04/06 07:32
- iPhone(アイフォーン) ※ AppleCare+ 盗難・紛失プラン for iPhone 14 Pro(AppleにてiPh 1 2022/09/22 19:11
- 車検・修理・メンテナンス FIAT500のヘッドライトのバルブ交換について 4 2022/10/17 19:40
- 戸籍・住民票・身分証明書 マイナンバーカード お金に関して 4 2022/09/10 08:26
- 薬剤師・登録販売者・MR 変更調剤について 1 2022/05/22 11:50
- 学校 大学の学部変更 2 2022/09/15 18:37
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
htmlのolやulなどlistにtitleや...
-
HTML属性での「""」 「''」違い
-
複数のボタンを等間隔に、かつ...
-
iframeを使わずに上下50%ずつに...
-
ヘッダーとフッターだけ背景を...
-
div要素が重なってします
-
html の divとtable の役割
-
min-heightとheightの違いについて
-
h1に自分自身へのリンクを張...
-
標題<h1>に、網掛けはできますか?
-
cssのdivについて
-
特定範囲内のCSSの継承を断ち切...
-
ブラウザの表示幅で100%指定が...
-
3カラムレイアウトで「常に残り...
-
DD,DT,DDを横並び。paddingとma...
-
可変長要素を中は左寄せのまま...
-
XHTMLでループ処理のやり方
-
クリアフィックス(<class="cl">)
-
グリッドレイアウトで"auto-fit...
-
CSSで、contentsがfooterに重な...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
htmlのolやulなどlistにtitleや...
-
HTML属性での「""」 「''」違い
-
div要素が重なってします
-
<div id="container">の使いか...
-
複数のボタンを等間隔に、かつ...
-
html の divとtable の役割
-
divとpの使いわけ
-
ヘッダーとフッターだけ背景を...
-
min-heightとheightの違いについて
-
セクションをdivで囲むと見出し...
-
画面を縮小するとカラムが落ち...
-
ヘッダーを左右に二分割する方...
-
スペースを使わず文字位置を揃...
-
1時間30分を簡単に表したいで...
-
CSSで、contentsがfooterに重な...
-
h1に自分自身へのリンクを張...
-
divの中に外部のHTMLを埋め込む
-
hタグの右横に画像を表示
-
divを横に並べる方法
-
インラインフレームのページ内...
おすすめ情報