为圆形图形分配颜色 [英] Assign color to a circle graphic

查看:100
本文介绍了为圆形图形分配颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过代码在屏幕上创建一个圆,并让用户通过使用Scroll控件将值分配给Color.FromArgb(A,R中的A,R,G和B的值来更改圆的颜色. ,G,B)表达式.
我想分配Rcolor = Color.FromArgb(A,R,G,B).

这是我的代码段:

I am trying to create a circle on a screen from code and have the user change the color of the circle by using Scroll controls to assign values to A, R, G, and B in the Color.FromArgb(A, R, G, B) expression.
I would like to assign Rcolor = Color.FromArgb(A, R, G, B).

Here is my code snippet:

Public Sub MakeCircle ()

Dim ShowCircles As Graphics
Dim PenColorR As New Pen(Color.Red)
ShowCircles = Me.CreateGraphics 
ShowCircles.DrawEllipse(PenColorR, 430 - AdjSepH, 450, 68, 86)  


上面的代码可以正常工作,在屏幕上创建一个红色圆圈.
这也适用:

将PenColorColor设置为新的Pen(Color.FromArgb(255,255,0,0))

但是,如果我尝试将FromArgb分配给这样的变量,则会触发错误消息...


The above code actually works, creating a red circle on the screen.
This also works:

Dim PenColorR As New Pen(Color.FromArgb(255, 255, 0, 0))

BUT, if I try to assign FromArgb to a variable like so, error messages are triggered...

<br />
Dim Rcolor As Color = Color.FromArgb(255, 255, 0, 0)<br />
Dim PenColorR As New Pen(Color.Rcolor)



将PenColorColor用作新的Pen(Rcolor)

那么有没有办法将Color.FromArgb(255,255,0,0)分配给变量(Rcolor)并用于给图形着色?
希望这个问题清楚!!
谢谢
Gary Vogel


Or
Dim PenColorR As New Pen(Rcolor)

So is there way to assign Color.FromArgb(255, 255, 0, 0) to a variable (Rcolor) and use to color the graphics???

Hope this question is clear!!
Thanks
Gary Vogel

推荐答案

您的以下代码不应触发任何错误.

Your code below shouldn''t trigger any error.

Dim Rcolor As Color = Color.FromArgb(255, 255, 0, 0)
Dim PenColorR As New Pen(Rcolor)


这有多尴尬?我对尝试过的VB10众神发誓
昏暗的PenColorR作为新的Pen(Rcolor)
上次几次,它不起作用...错误的错误消息!!!
今天早上不知何故,您是对的...奏效了!!!
所以,谢谢您让我走上正确的路!!
加里五世
How embarrassing is this?? I swear by the VB10 Gods that I tried
Dim PenColorR as New Pen(Rcolor)
several times last time and it would not work...cryptic error messages!!!
Somehow this morning, you are right...it worked!!!

So thanks for keeping me on the right path!!
Gary V


这篇关于为圆形图形分配颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆