VB可使用Point方法來獲取圖片指定點的顏色。
欽州網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,欽州網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為欽州1000+提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)公司要多少錢,請找那個售后服務(wù)好的欽州做網(wǎng)站的公司定做!
Point 方法
按照長整數(shù),返回在 Form 或 PictureBox 上所指定磅的紅-綠-藍 (RGB) 顏色。
語法
object.Point(x, y)
'窗體判色代碼:
Private Sub Form1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1 = X
Text2 = Y
Text3 = Point(X, Y)
Text4 = (Val(Text3) Mod 65536) Mod 256 'Red
Text5 = (Val(Text3) Mod 65536) \ 256 'Green
Text6 = Val(Text3) \ 65536 'Blue
Shape1.FillColor = RGB(Val(Text4), Val(Text5), Val(Text6))
End Sub
'PictureBox判色代碼:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1 = X
Text2 = Y
Text3 = Picture1.Point(X, Y)
Text4 = (Val(Text3) Mod 65536) Mod 256 'Red
Text5 = (Val(Text3) Mod 65536) \ 256 'Green
Text6 = Val(Text3) \ 65536 'Blue
Shape1.FillColor = RGB(Val(Text4), Val(Text5), Val(Text6))
End Sub
Dim c As Color '新生成的顏色
Dim r As Byte 'RED
Dim g As Byte 'Green
Dim b As Byte 'Blue
Dim a As Byte 'Alpha 分量值
a = Button1.BackColor.A
r = Button1.BackColor.R
g = Button1.BackColor.G
b = Button1.BackColor.B
Dim rnd As New Random '生成隨機數(shù)
Dim i As Integer
i = rnd.Next(-10, 10)
r = r + IIf(r + i 255, -i, i)
i = rnd.Next(-10, 10)
g = g + IIf(g + i 255, -i, i)
i = rnd.Next(-10, 10)
b = b + IIf(b + i 255, -i, i)
c = Color.FromArgb(a, r, g, b)
這個問題的本質(zhì)就是隨機二字,無論c/s還是b/s里面的label1 ,只要隨機設(shè)置字體顏色屬性即可。而相關(guān)屬性我相信您肯定知道,關(guān)鍵是怎樣隨機。vb.net里面有一個隨機函數(shù),只要利用該隨機函數(shù),隨機生成相應(yīng)的顏色即可,然后把隨機顏色賦值給label的屬性
文章標題:vb.net隨機顏色 vb中顏色
網(wǎng)站路徑:http://muchs.cn/article28/docsojp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計、網(wǎng)站導(dǎo)航、用戶體驗、網(wǎng)站收錄、企業(yè)建站、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)