1.vb中实现用鼠标绘制直线的屏幕代码
2.VB 在桌面屏幕上画一条直线如何让它重绘?
3.vb.net ç»çº¿åç»ä¿ç以åç»å¾
4.vb中画线命令代码
5.VB ç»ç´çº¿
6.vbä¸å¦ä½è¡¨ç¤ºå±å¹ä¸ä¸ç¹
vb中实现用鼠标绘制直线的代码
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then
Picture1.Cls '按右键可清屏
ElseIf Picture1.CurrentX = 0 And Picture1.CurrentY = 0 Then
Picture1.PSet (X, Y), vbBlack '开始画第一个点
Else
Picture1.Line -(X, Y), vbBlack '画线
End If
End Sub
VB 在桌面屏幕上画一条直线如何让它重绘?
'屏幕重绘 源码如下
'画多线声波色条
Public Sub DrawFrequencies(intSamples() As Integer, picbox As PictureBox)
'FFT_SAMPLES =
Dim sngRealOut(FFT_SAMPLES - 1) As Single
Dim sngBand As Single
Dim hBrush As Long
Dim i As Long
Dim j As Long
Dim intRed As Integer
Dim intGreen As Integer
Dim intBlue As Integer
Dim rcBand As RECT
If UBound(intSamples) < FFT_SAMPLES - 1 Then Exit Sub
If clsFFT Is Nothing Then
Set clsFFT = New clsFourier
clsFFT.NumberOfSamples = FFT_SAMPLES
clsFFT.WithTimeWindow = 1
End If
'读入数据
For i = 0 To FFT_SAMPLES - 1 'FFT_SAMPLES =
clsFFT.RealIn(i + 1) = intSamples(i) '动态数值传送
Next
' lower band amplitudes
For i = 0 To FFT_BANDS - 1 'band(i) = 0 FFT_BANDS =
band(i) = band(i) - FFT_BANDLOWER 'FFT_BANDLOWER = 0.
If band(i) < 0 Then band(i) = 0
Next
'band(0) = 0 : band(1) = 0 : band(2) = 0 : band(3) = 0 : band(4) = 0 : band(5) = 0 : band(6) = 0
For i = 0 To FFT_SAMPLES / 2
'FFT_SAMPLES =
sngRealOut(i) = clsFFT.ComplexOut(i + 1) / (FFT_SAMPLES / 4) /
If sngRealOut(i) > FFT_MAXAMPLITUDE Then
sngRealOut(i) = FFT_MAXAMPLITUDE
End If
sngRealOut(i) = sngRealOut(i) / FFT_MAXAMPLITUDE 'FFT_MAXAMPLITUDE = 0.2
Next
j = FFT_STARTINDEX
For i = 0 To FFT_BANDS - 1 'FFT_BANDS =
For j = j To j + FFT_BANDWIDTH 'FFT_BANDWIDTH = 3
sngBand = sngBand + sngRealOut(j)
Next
sngBand = (sngBand * (Hanning(i + 3, FFT_BANDS + 3) + 1)) / FFT_BANDWIDTH
'MsgBox band(i) '--------------------------------
If band(i) < sngBand Then band(i) = sngBand
If band(i) > 1 Then band(i) = 1
j = j + FFT_BANDSPACE
Next
' draw bars
picbox.Cls
intRed =
intBlue =
'画整个色块 共块色条
For i = 0 To FFT_BANDS - 1 'FFT_BANDS = picbox.ScaleHeight =
intGreen = (band(i) * ) ' i ( 0-)
hBrush = CreateSolidBrush(RGB(intRed, intGreen, intBlue))
'画单个色块
With rcBand
.Right = i * (DRW_BARWIDTH + DRW_BARSPACE) + DRW_BARWIDTH + DRW_BARXOFF
.Left = i * (DRW_BARWIDTH + DRW_BARSPACE) + DRW_BARXOFF
'单个色块的高度 忽上忽下 DRW_BARYOFF=2 常数 band(i)自定精度数组(0-) 从小到大
'.Top = max(DRW_BARYOFF, Min(picbox.ScaleHeight, picbox.ScaleHeight - (picbox.ScaleHeight * band(i))) - DRW_BARYOFF) ' - 1)
.Top = max(2, Min(, - ( * band(i))) - 2)
.Bottom = picbox.ScaleHeight - DRW_BARYOFF
End With
FillRect picbox.hdc, rcBand, hBrush '用指定刷子填充色块区域
DeleteObject hBrush
Next
End Sub
vb.net ç»çº¿åç»ä¿ç以åç»å¾
å¯ä»¥æææç»ç线é½ä¿åå¨ä¸ä¸ªå表ä¸ï¼ç»çæ¶åå ¨é¨ç»åºå³å¯ãå¦ä¸ï¼Public Class Form1
Class Line 'ç´çº¿ç±»
Public Point1, Point2 As Point 'æåï¼ç´çº¿ç两个端ç¹
Sub New(p1 As Point, p2 As Point) 'æé æ¹æ³
Point1 = p1
Point2 = p2
End Sub
Public Sub Draw(g As Graphics) 'ç»å¶æ¹æ³
g.DrawLine(Pens.Black, Point1, Point2)
End Sub
End Class
Private Lines As New List(Of Line) 'å表ç¨äºä¿åææç»ä¸çç´çº¿
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
BackColor = Color.White
DoubleBuffered = True 'å¼å¯åç¼å²å¯ææé¿å éªç
End Sub
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
Lines.Add(New Line(e.Location, e.Location)) 'å¨ç´çº¿å表ä¸æ·»å ç´çº¿
End Sub
Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
If e.Button <> Windows.Forms.MouseButtons.Left Then Return 'å·¦é®æªæä¸
'é¼ æ æå¨æ¶æ¹åå表æåä¸æ¡ç´çº¿ï¼ä¹å³å½åç´çº¿ç第äºä¸ªç«¯ç¹ï¼
Lines(Lines.Count - 1).Point2 = e.Location
Refresh() 'å·æ°çªä½
End Sub
'å¨FormçPaintäºä»¶ä¸ç»å¶ææç´çº¿ï¼æ¯æ¬¡Form1éç»æ¶é½ä¼è§¦åPaintäºä»¶
'PS: ä¹å¯ä»¥éè¿éåOnPaintæ¹æ³æ¥è¾¾å°ç±»ä¼¼çææ
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias 'å¼å¯æé¯é½¿
For Each l In Lines 'éåææç´çº¿
l.Draw(e.Graphics) 'è°ç¨ç»å¶æ¹æ³ï¼ä¼ å ¥çåæ°å¯ä»¥ç解为ç»å¸
Next
End Sub
End Class
è¿è¡ææï¼
vb中画线命令代码
对象.Line (x1,y1)-(x2,y2)
对象可以是窗体或PicTureBox控件。
(x1,画线画线趣出行源码y1) 是一个端点的坐标
(x2,y2) 是另一个端点的坐标
VB ç»ç´çº¿
ç»ç´çº¿
为äºå¨ä¸¤ä¸ªåæ ç¹ä¹é´ç»ä¸æ¡ç´çº¿ï¼å¯ä½¿ç¨ Line æ¹æ³çç®åå½¢å¼ï¼å ¶è¯æ³å¦ä¸ï¼
[object.]Line [(x1, y1)]â(x2, y2)[, color]
å ¶ä¸ Object æ¯å¯éæ©çï¼è¥çç¥ï¼æ¤æ¹æ³å°å¨ä»£ç æè¿æ¥ççªä½ï¼å½åçªä½ï¼ä¸ç»çº¿ã第ä¸å¯¹åæ ä¹æ¯å¯éçãå°±ææçåæ å¼æ¥è¯´ï¼x å y åæ°é½æ¢å¯ä»¥æ¯æ´æ°ï¼ä¹å¯ä»¥æ¯åæ°ãä¾å¦ï¼ä¸åè¯å¥å¯å¨çªä½ä¸ç»ä¸æ¡æ线ã
Line (, )â(, )
Visual Basic æç»åºçä¸æ¡ç´çº¿ï¼è¦å æ¬ç¬¬ä¸ä¸ªç«¯ç¹ï¼èä¸æ¯æåä¸ä¸ªç«¯ç¹ãè¿ç§è¡ä¸ºå¨ä»ç¹å°ç¹ç»å°éæ²çº¿æ¶æ¯æç¨çã为äºç»æåä¸ä¸ªç«¯ç¹ï¼åºä½¿ç¨è¿ç§è¯æ³ï¼
PSet [Step] (0, 0)[, color]
第ä¸å¯¹åæ (x1, y1) æ¯å¯éçãå¦æçç¥è¿äºåæ ï¼å°æ该对象ç x,y å½åä½ç½®ï¼ç»å¾åæ ï¼ä½ä¸ºç«¯ç¹ãå½åä½ç½®æ¯ç± CurrentX å CurrentY å±æ§æå®çï¼ç¶èå¨å ¶å®æ åµå®ä¼çäºä»¥åçå¾å½¢æ¹æ³æ Print æ¹æ³æç»æåç¹çä½ç½®ãå¦æ以å没æ使ç¨è¿å¾å½¢æ¹æ³æ Print æ¹æ³ï¼æ没æ设置 CurrentX å CurrentY å±æ§ï¼å缺çä½ç½®ä¸ºå¯¹è±¡çå·¦ä¸è§ã
ä¾å¦ï¼ä»¥ä¸è¯å¥éè¿ä¸ç¹è¿æ¥ç»åºä¸ä¸ªä¸è§å½¢ã
'设置起ç¹ç x åæ ã
CurrentX =
'设置起ç¹ç y åæ ã
CurrentY =
'åèµ·ç¹çå³ä¸æ¹ç»ä¸ç´çº¿ã
Line -(, )
'åå½åç¹çå·¦æ¹ç»ä¸ç´çº¿ã
Line -(, )
'åå³ä¸æ¹ç»ä¸ç´çº¿å°èµ·ç¹ã
Line -(, )
Blanker åºç¨ç¨åºä½¿ç¨ Line æ¹æ³å建åºäºä¸äºæ趣çå¾æ¡æ ·å¼ã为äºçå°è¿äºå¾æ¡ï¼å¯ä»âé项âèåä¸ï¼éå®âCrossfireâï¼ç¶åéå®âStart Demoâæé®ï¼å³å¯çå°ã
Step å ³é®å
PSetãLineãå Circle æ¹æ³ä½¿ç¨ä»¥ä¸è¯æ³å¯æå®ä¸ä¸ªæå¤ä¸ªç¹ï¼
(x, y)
å¯å¨æ¯ä¸ªç¹ä¹åå ä¸ Step å ³é®åï¼ç¨æ¥æå®è¦ç»åºçç¹ï¼æ¯ç¸å¯¹æåç»åºç¹çä½ç½®ãVisual Basic è¦å° x å y çå¼å å°æåæç»çç¹ä¸ãä¾å¦ï¼ä¸è¾¹è¿æ¡è¯å¥ï¼
Line (, )â(, )
çä»·äºï¼
Line (, )âStep(, )
å¨è®¸å¤æ åµä¸ï¼Step å ³é®åå¯å é¤æç»ä¸æå°è®°å½æåæç»ç¹ä½ç½®çè´æ ãç»å¸¸æä¸ºå ³å¿çå¯è½æ¯ä¸¤ç¹çç¸å¯¹ä½ç½®ï¼èä¸æ¯å®ä»¬çç»å¯¹ä½ç½®ã
使ç¨é¢è²åæ°
为äºæ¹åç´çº¿çé¢è²ï¼åºå°å¯éç color åæ°ä¸å¾å½¢æ¹æ³ä¸èµ·ä½¿ç¨ãä¾å¦ï¼ä¸è¿°è¯å¥å°ç»ä¸æ¡æ·±èè²çç´çº¿ï¼
Line (, )â(, ), RGB(0, 0, )
å¦æçç¥äº color åæ°ï¼å°ä½¿ç¨å¨å ¶ä¸ç»çº¿ç对象ç ForeColor å±æ§ï¼æ¥å³å®ç´çº¿çé¢è²ã
RNDæ¥è®¾ç½®éæºå¼
vbä¸å¦ä½è¡¨ç¤ºå±å¹ä¸ä¸ç¹
Private Sub Form_Load()
Form1.ForeColor = vbRed
Form1.DrawWidth = 8
Form1.PSet (Form1.Width / 2, Form1.Height / 2)
End Sub
2024-12-23 01:41
2024-12-23 01:27
2024-12-23 01:04
2024-12-23 00:22
2024-12-23 00:20
2024-12-23 00:05
2024-12-22 23:47
2024-12-22 23:31