• Vui lòng đọc nội qui diễn đàn để tránh bị xóa bài viết
  • Tìm kiếm trước khi đặt câu hỏi

Gradient: Diamond, Rectangle, Cirlce and Quad

Các thủ thuật về truyền thông đa phương tiện, đồ họa

Moderators: tungcan5diop, QUANITGROBEST

User avatar
clarkkent
Mạnh Thường Quân
Mạnh Thường Quân
Posts: 1641
Joined: Wed 16/04/2008 11:25 am
Location: Chợ Lách - Bến Tre
Been thanked: 31 times
Contact:

Gradient: Diamond, Rectangle, Cirlce and Quad

Postby clarkkent » Sun 14/12/2008 10:34 am

Thủ thuật: Gradient: Diamond, Rectangle, Cirlce and Quad
Tác giả: Nguyễn Trung Tín sưu tầm
Mô tả: Gradient: Diamond, Rectangle, Cirlce and Quad


gradient.PNG
gradient.PNG (38.96 KiB) Viewed 3630 times

Code: Select all

  1. Imports System.Drawing.Drawing2D
  2. Public Class Form1
  3.     Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
  4.         Dim g As Graphics = e.Graphics
  5.         Dim width As Integer = Me.ClientRectangle.Width / 2
  6.         Dim height As Integer = Me.ClientRectangle.Height / 2
  7.  
  8.         Dim triPoints As Point() = New Point() {New Point(width / 2, 0), New Point(0, height), New Point(width, height)}
  9.         Dim b As PathGradientBrush = New PathGradientBrush(triPoints)
  10.         b.SurroundColors = New Color() {Color.Red, Color.Blue}
  11.         Dim x As Integer = 0
  12.         Dim y As Integer = 0
  13.         g.FillRectangle(b, x, y, width, height)
  14.  
  15.         Dim quadPoints As Point() = New Point() {New Point(0, 0), New Point(width, 0), New Point(width, height), New Point(0, height)}
  16.         b = New PathGradientBrush(quadPoints)
  17.         b.WrapMode = WrapMode.Tile
  18.         x = width
  19.         y = 0
  20.         g.FillRectangle(b, x, y, width, height)
  21.  
  22.         Dim diamondPoints As Point() = New Point() {New Point(width / 2, 0), New Point(width, height / 2), New Point(width / 2, height), New Point(0, height / 2)}
  23.         b = New PathGradientBrush(diamondPoints)
  24.         b.WrapMode = WrapMode.Tile
  25.         b.CenterPoint = New PointF(0, height / 2)
  26.         x = 0
  27.         y = height
  28.         g.FillRectangle(b, x, y, width, height)
  29.  
  30.         Dim circle As GraphicsPath = New GraphicsPath()
  31.         circle.AddEllipse(0, 0, width, height)
  32.         b = New PathGradientBrush(circle)
  33.         b.WrapMode = WrapMode.Tile
  34.         b.SurroundColors = New Color() {Color.White}
  35.         b.CenterColor = Color.Black
  36.         x = width
  37.         y = height
  38.         g.FillRectangle(b, x, y, width, height)
  39.     End Sub
  40. End Class


• Hôm bây: www.tinsoftware.com ^ ^
Cố gắng lên...

Return to “[.NET] Âm thanh và Đồ họa”

Who is online

Users browsing this forum: No registered users and 1 guest