Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
87
Task/Yin-and-yang/Visual-Basic-.NET/yin-and-yang-1.vb
Normal file
87
Task/Yin-and-yang/Visual-Basic-.NET/yin-and-yang-1.vb
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
Imports System.Drawing
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Module Program
|
||||
''' <summary>
|
||||
''' Draws a Taijitu symbol on the specified <see cref="Graphics" /> surface at a specified location with a specified size.
|
||||
''' </summary>
|
||||
''' <param name="g">The <see cref="Graphics" /> surface to draw on.</param>
|
||||
''' <param name="location">The coordinates of the upper-left corner of the bounding rectangle that defines the symbol.</param>
|
||||
''' <param name="diameter">The diameter of the symbol, or the width and height of its bounding rectangle.</param>
|
||||
''' <param name="drawOutline">Whether to draw an outline around the symbol.</param>
|
||||
Sub DrawTaijitu(g As Graphics, location As PointF, diameter As Single, drawOutline As Boolean)
|
||||
Const sixth = 1 / 6
|
||||
|
||||
g.ResetTransform()
|
||||
g.TranslateTransform(location.X, location.Y)
|
||||
g.ScaleTransform(diameter, diameter)
|
||||
|
||||
g.FillPie(Brushes.Black, x:=0, y:=0, width:=1, height:=1, startAngle:=90, sweepAngle:=180) ' Left half.
|
||||
g.FillPie(Brushes.White, x:=0, y:=0, width:=1, height:=1, startAngle:=270, sweepAngle:=180) ' Right half.
|
||||
g.FillEllipse(Brushes.Black, x:=0.25, y:=0, width:=0.5, height:=0.5) ' Upper ball.
|
||||
g.FillEllipse(Brushes.White, x:=0.25, y:=0.5, width:=0.5, height:=0.5) ' Lower ball.
|
||||
g.FillEllipse(Brushes.White, x:=0.5 - sixth / 2, y:=sixth, width:=sixth, height:=sixth) ' Upper dot.
|
||||
g.FillEllipse(Brushes.Black, x:=0.5 - sixth / 2, y:=4 * sixth, width:=sixth, height:=sixth) ' Lower dot.
|
||||
|
||||
If drawOutline Then
|
||||
Using p As New Pen(Color.Black, width:=2 / diameter)
|
||||
g.DrawEllipse(p, x:=0, y:=0, width:=1, height:=1)
|
||||
End Using
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Draws one large and one small Taijitu symbol on the specified <see cref="Graphics" /> surface.
|
||||
''' </summary>
|
||||
''' <param name="g">The <see cref="Graphics" /> surface to draw on.</param>
|
||||
''' <param name="bounds">The width and height of the area to draw in.</param>
|
||||
Sub DrawDemo(g As Graphics, bounds As Single)
|
||||
Const PADDING = 10
|
||||
Dim ACTUAL = bounds - (PADDING * 2)
|
||||
|
||||
g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
|
||||
|
||||
DrawTaijitu(g, location:=New PointF(PADDING, PADDING), diameter:=ACTUAL / 4, drawOutline:=True)
|
||||
DrawTaijitu(g, location:=New PointF(PADDING + (bounds / 5), PADDING + (ACTUAL / 5)), diameter:=ACTUAL * 4 / 5, drawOutline:=True)
|
||||
End Sub
|
||||
|
||||
Sub Main(args As String())
|
||||
If args.Length = 0 Then
|
||||
Using frm As New YinYangForm()
|
||||
frm.ShowDialog()
|
||||
End Using
|
||||
|
||||
Else
|
||||
Dim imageSize = Integer.Parse(args(0), Globalization.CultureInfo.InvariantCulture)
|
||||
|
||||
Using bmp As New Bitmap(imageSize, imageSize),
|
||||
g = Graphics.FromImage(bmp),
|
||||
output = Console.OpenStandardOutput()
|
||||
|
||||
Try
|
||||
DrawDemo(g, imageSize)
|
||||
bmp.Save(output, Imaging.ImageFormat.Png)
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Specified size is too small", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End Try
|
||||
End Using
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Class YinYangForm
|
||||
Inherits Form
|
||||
|
||||
Sub Form_Paint() Handles Me.Paint
|
||||
Dim availableSize = Math.Min(Me.DisplayRectangle.Width, Me.DisplayRectangle.Height)
|
||||
Dim g As Graphics
|
||||
Try
|
||||
g = Me.CreateGraphics()
|
||||
DrawDemo(g, availableSize)
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Window size too small.", "Exception thrown", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Finally
|
||||
If g IsNot Nothing Then g.Dispose()
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
End Module
|
||||
41
Task/Yin-and-yang/Visual-Basic-.NET/yin-and-yang-2.vb
Normal file
41
Task/Yin-and-yang/Visual-Basic-.NET/yin-and-yang-2.vb
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
Imports System.IO
|
||||
|
||||
' Yep, VB.NET can import XML namespaces. All literals have xmlns changed, while xmlns:xlink is only
|
||||
' declared in literals that use it directly (e.g. the output of this program has it defined in both
|
||||
' of the <use /> tags and not the root, <svg />).
|
||||
Imports <xmlns="http://www.w3.org/2000/svg">
|
||||
Imports <xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
Module Program
|
||||
Sub Main()
|
||||
Dim doc =
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg version="1.1" width="30" height="30">
|
||||
<defs>
|
||||
<g id="y">
|
||||
<circle cx="0" cy="0" r="200" stroke="black"
|
||||
fill="white" stroke-width="1"/>
|
||||
<path d="M0 -200 A 200 200 0 0 0 0 200 100 100 0 0 0 0 0 100 100 0 0 1 0 -200 z" fill="black"/>
|
||||
<circle cx="0" cy="100" r="33" fill="white"/>
|
||||
<circle cx="0" cy="-100" r="33" fill="black"/>
|
||||
</g>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
' XML literals don't support DTDs.
|
||||
Dim type As New XDocumentType(name:="svg", publicId:="-//W3C//DTD SVG 1.1//EN", systemId:="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", internalSubset:=Nothing)
|
||||
doc.AddFirst(type)
|
||||
|
||||
Dim draw_yinyang =
|
||||
Sub(trans As Double, scale As Double) doc.Root.Add(<use xlink:href="#y" transform=<%= $"translate({trans},{trans}) scale({scale})" %>/>)
|
||||
|
||||
draw_yinyang(20, 0.05)
|
||||
draw_yinyang(8, 0.02)
|
||||
|
||||
Using s = Console.OpenStandardOutput(),
|
||||
sw As New StreamWriter(s)
|
||||
doc.Save(sw, SaveOptions.OmitDuplicateNamespaces)
|
||||
sw.WriteLine()
|
||||
End Using
|
||||
End Sub
|
||||
End Module
|
||||
14
Task/Yin-and-yang/Visual-Basic-.NET/yin-and-yang-3.vb
Normal file
14
Task/Yin-and-yang/Visual-Basic-.NET/yin-and-yang-3.vb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" width="30" height="30" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<g id="y">
|
||||
<circle cx="0" cy="0" r="200" stroke="black" fill="white" stroke-width="1" />
|
||||
<path d="M0 -200 A 200 200 0 0 0 0 200 100 100 0 0 0 0 0 100 100 0 0 1 0 -200 z" fill="black" />
|
||||
<circle cx="0" cy="100" r="33" fill="white" />
|
||||
<circle cx="0" cy="-100" r="33" fill="black" />
|
||||
</g>
|
||||
</defs>
|
||||
<use xlink:href="#y" transform="translate(20,20) scale(0.05)" xmlns:xlink="http://www.w3.org/1999/xlink" />
|
||||
<use xlink:href="#y" transform="translate(8,8) scale(0.02)" xmlns:xlink="http://www.w3.org/1999/xlink" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 794 B |
7
Task/Yin-and-yang/Visual-Basic-.NET/yin-and-yang-4.vb
Normal file
7
Task/Yin-and-yang/Visual-Basic-.NET/yin-and-yang-4.vb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Module Program
|
||||
Sub Main()
|
||||
Console.OutputEncoding = Text.Encoding.Unicode
|
||||
Dim cheat_harder = Function(scale As Integer) <span style=<%= $"font-size:{scale}%;" %>>☯</span>
|
||||
Console.WriteLine(<div><%= cheat_harder(700) %><%= cheat_harder(350) %></div>)
|
||||
End Sub
|
||||
End Module
|
||||
4
Task/Yin-and-yang/Visual-Basic-.NET/yin-and-yang-5.vb
Normal file
4
Task/Yin-and-yang/Visual-Basic-.NET/yin-and-yang-5.vb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<div>
|
||||
<span style="font-size:700%;">☯</span>
|
||||
<span style="font-size:350%;">☯</span>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue