也容易,如果是黑白三個(gè)顏色加上相同的漸變量,彩色的是起始顏色的三個(gè)分量與終止顏色的對(duì)應(yīng)三個(gè)分量的差值,再除于相同的份數(shù),就得出三原色各自的步進(jìn)量。

成都創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的藍(lán)山網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
窗體上放個(gè)圖片框試試下面代碼:
Private?Sub?PictureBox1_Paint(ByVal?sender?As?Object,?ByVal?e?As?System.Windows.Forms.PaintEventArgs)?Handles?PictureBox1.Paint
Dim?startColor?As?Color?=?Color.Red
Dim?endColor?As?Color?=?Color.Green
Dim?s?As?String?=?"vb.net?如何使文字能漸變顏色,就是顏色慢慢變淡然后在慢慢恢復(fù)?"
Dim?Steps?As?Integer?=?s.Length?\?2
Dim?StepR?As?Integer?=?(CInt(endColor.R)?-?startColor.R)?\?Steps
Dim?StepG?As?Integer?=?(CInt(endColor.G)?-?startColor.G)?\?Steps
Dim?StepB?As?Integer?=?(CInt(endColor.B)?-?startColor.B)?\?Steps
Dim?R?As?Integer?=?startColor.R
Dim?G?As?Integer?=?startColor.G
Dim?B?As?Integer?=?startColor.B
Dim?drawFont?As?New?System.Drawing.Font("Arial",?16)
Dim?X?As?Integer?=?50
For?i?As?Integer?=?1?To?Steps
Dim?drawBrush?As?New?SolidBrush(Color.FromArgb(R,?G,?B))
e.Graphics.DrawString(s.Substring(i?-?1,?1),?drawFont,?drawBrush,?X,?50.0)
X?+=?18
R?+=?StepR
G?+=?StepG
B?+=?StepB
Next
For?i?As?Integer?=?1?To?Steps
Dim?drawBrush?As?New?SolidBrush(Color.FromArgb(R,?G,?B))
e.Graphics.DrawString(s.Substring(i?+?Steps?-?1,?1),?drawFont,?drawBrush,?X,?50.0)
X?+=?18
R?-=?StepR
G?-=?StepG
B?-=?StepB
Next
End Sub
VB可使用Point方法來(lái)獲取圖片指定點(diǎn)的顏色。
Point 方法
按照長(zhǎng)整數(shù),返回在 Form 或 PictureBox 上所指定磅的紅-綠-藍(lán) (RGB) 顏色。
語(yǔ)法
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
Label控件是沒(méi)有辦法實(shí)現(xiàn)多種顏色的文字的,只能用RichTextBox來(lái)實(shí)現(xiàn),而且你的自定義格式字符串也沒(méi)有結(jié)尾的,這樣很不好,至少也要red紅色字/redyellow黃色字/yellow,而且實(shí)現(xiàn)也很麻煩的,下面的代碼我沒(méi)有檢測(cè)正確性,有錯(cuò)誤的自己改一改吧
Dim colortag() as string
dim colors() as color
const txt as string="red紅色字/redyellow黃色字/yellow"
private sub Form_Load(object sender,eventargs e)handles mybase.load
colortag(0)="red":Colortag(1)="yellow"
colors(0)=color.red:colors(1)=color.yellow
richtextbox1.text=txt
for i as integer=0 to colortag.lenght-1
dim tag as string="" colortag(i) ""
dim endtag as string="/" colortag(i) ""
dim find as integer=1
do
find=instr(find,txt,tag)+tag.lenght
if(find0)then
dim find1 as integer=instr(find,txt,endtag)
richtextbox1.SelectionStart=find
richtextbox1.selectionlenght=find1-find
richtextbox1.selectioncolor=colors(i)
find=find1
else
exit do
end if
loop
next
end sub
繪制線條采用Draw開(kāi)頭的方法,顏色參數(shù)用Pen類;
繪制有填充色的封閉圖形采用Fill開(kāi)頭的方法,顏色參數(shù)用Brush類;
例如:
'繪制一個(gè)實(shí)心圓,該圓在:直線x=200,y=200,x=200+100,y=200+100所劃矩形區(qū)域內(nèi)
Me.CreateGraphics.FillEllipse(New SolidBrush(Color.Orange), 200, 200, 100, 100)
'繪制一個(gè)空心圓,該圓在:直線x=200,y=200,x=200+100,y=200+100所劃矩形區(qū)域內(nèi)
Me.CreateGraphics.DrawEllipse(New Pen(Color.Black), 200, 200, 100, 100)
新聞標(biāo)題:關(guān)于vb.net色的信息
URL鏈接:http://chinadenli.net/article20/dojiico.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司、網(wǎng)站制作、ChatGPT、商城網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)