Imports System.Drawing.Bitmap Imports System.Drawing.Imaging 'Option Strict On Public Class Form1 Private _width As Integer = 80 Private _height As Integer = 120 Private _files As Integer = 128 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim image1 As New Bitmap(_width, _height) Dim image2 As New Bitmap(_width, _height) Dim count As Integer = _files - 1 Dim x, y As Integer Dim theta As Double = 0.0 _initBar() Dim newColor As Color While count >= 0 For x = 0 To image1.Width - 1 For y = 0 To image1.Height - 1 newColor = _getCol(x, y, count, +1) image1.SetPixel(x, y, newColor) newColor = _getCol(x, y, count, -1) image2.SetPixel(x, y, newColor) Next Next PictureBox1.Image = image1 PictureBox2.Image = image2 PictureBox1.Refresh() PictureBox2.Refresh() saveImage(count, image1, "l") saveImage(count, image2, "r") _setBar(_files - count) count = count - 1 End While ProgressBar1.Value = 0 End Sub Private Sub _initBar() ProgressBar1.Minimum = 0 ProgressBar1.Maximum = _files ProgressBar1.Step = 1 End Sub Private Sub _setBar(ByVal num As Integer) ProgressBar1.Value = num End Sub Private Sub saveImage(ByVal count As Integer, ByVal image As Bitmap, ByVal lr As String) Dim filename As String = TextBox1.Text & CStr(count) & "_" & lr & ".png" image.Save(filename, ImageFormat.Png) Console.WriteLine(filename + "を書き出し") End Sub Private Function _getCol(ByVal x As Integer, ByVal y As Integer, ByVal i As Integer, ByVal dir As Double) As Color Dim red As Double = 0 Dim green As Double = 0 Dim blue As Double = 0 Dim speed As Double = 1.0 Dim cx As Double = _width * 0.5 Dim cy As Double = _height * 0.5 Dim dx As Double = (x - cx) Dim dy As Double = (y - cy) Dim nx As Double Dim ny As Double Dim r As Double = Math.Sqrt(dx * dx + dy * dy) Dim theta As Double Dim bAll As Boolean = True Dim newColor As Color If r = 0 Then r = 0.1 End If Dim rRatio As Double = Math.Max(0,0.07*speed*i*(1 - (Math.Sqrt(r/(cY*1.1))) )) Dim bInSide As Boolean = (r < cx And r < cy) If (Not bAll) And (Not bInSide) Then newColor = Color.FromArgb(0, 128, 128) Else theta = Math.Atan2(-dy, dx) nx = (cx + Math.Cos(theta - dir * rRatio) * r) - x ny = (cy - Math.Sin(theta - dir * rRatio) * r) - y blue = Math.Max(0, Math.Min(nx + 128, 255)) green = Math.Max(0, Math.Min(ny + 128, 255)) newColor = Color.FromArgb(CInt(red), CInt(green), CInt(blue)) End If Return newColor End Function End Class