<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>solo VB.NET - Visual Basic .Net &#187; Degrade</title>
	<atom:link href="http://www.solovb.net/index.php/tag/degrade/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.solovb.net</link>
	<description>Visual Basic.NET, VB.NET, Programación, Tutoriales, Ejemplos</description>
	<lastBuildDate>Mon, 02 Jan 2012 14:30:00 +0000</lastBuildDate>
	<language>es-ES</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Panel con colores en degrade &#8211; (Gradient)</title>
		<link>http://www.solovb.net/index.php/2009/03/11/panel-con-colores-en-degrade-gradient/</link>
		<comments>http://www.solovb.net/index.php/2009/03/11/panel-con-colores-en-degrade-gradient/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 14:16:23 +0000</pubDate>
		<dc:creator>Eliseo</dc:creator>
				<category><![CDATA[Controles]]></category>
		<category><![CDATA[Ejemplos]]></category>
		<category><![CDATA[Funciones]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[Colores]]></category>
		<category><![CDATA[Degrade]]></category>
		<category><![CDATA[Gradient]]></category>
		<category><![CDATA[Panel]]></category>

		<guid isPermaLink="false">http://www.solovb.net/?p=295</guid>
		<description><![CDATA[Quiero mostrarles en esta oportunidad una forma muy sencilla de tener un panel mucho más vistoso con un degradé de dos colores.
]]></description>
				<content:encoded><![CDATA[<p>Quiero mostrarles en esta oportunidad una forma muy sencilla de tener un panel mucho más vistoso con un degradé de dos colores en <a href="http://www.solovb.net">visual basic .net</a>.</p>
<p>Para el ejemplo necesitamos un formulario y un panel, tal como se muestra en la siguiente figura:</p>
<p><img class="alignnone" src="/images/panelColor001.jpg" alt="" width="257" height="204" /></p>
<p>luego damos doble clic sobre el panel y nos vamos al evento paint del panel en la vista de código, y en este evento colocamos el siguiente código:</p>
<pre class="brush: vbnet; ruler: false; first-line: 1; highlight: [0]">
Dim y As Integer = 0
Dim x As Integer = 0
Dim ancho As Integer = Me.Width
Dim alto As Integer = Me.Height
Dim color1 As Color
Dim color2 As Color</code>

color1 = Color.DarkRed
color2 = Color.LightCoral

Dim colorear As New _
LinearGradientBrush( _
New Point(x, y), New Point(x + ancho, y), _
color1, color2)
e.Graphics.FillRectangle(colorear, _
x, y, ancho, alto)
y += alto + 10
</pre>
<p>Para que este código funcione deberemos agregar una referencia a Drawing2D como se muestra a continuación:</p>
<pre class="brush: vbnet; ruler: false; first-line: 1; highlight: [0]">
Imports System.Drawing.Drawing2D
</pre>
<p>Al ejecutar el programa deberíamos ver un formulario con un aspecto similar al de la siguiente figura:</p>
<p><img class="alignnone" src="/images/panelColor002.jpg" alt="" width="257" height="204" /></p>
<p>Cambiando los valores de las variables color1 y color2 pueden cambiar los resultados a su gusto.</p>
<p>También quiero dejarles a continuación un par de variantes para reemplaar el código del evento paint del panel y obtener distintos resultados&#8230; espero que los prueben y les agrade&#8230;</p>
<p>Variante 1</p>
<pre class="brush: vbnet; ruler: false; first-line: 1; highlight: [0]">
Dim y As Integer = 0
Dim x As Integer = 0
Dim ancho As Integer = Me.Width
Dim alto As Integer = Me.Height
Dim color1 As Color
Dim color2 As Color

color1 = Color.DarkRed
color2 = Color.LightCoral

Dim black_white_brush As New _
LinearGradientBrush( _
New Point(x, y), New Point(x + ancho, y), _
color1, color2)

Dim color_blend As New ColorBlend(3)
color_blend.Colors = New Color() {color1, color2, color1}
color_blend.Positions = New Single() {0.0, 0.2, 1.0}
black_white_brush.InterpolationColors = color_blend
e.Graphics.FillRectangle(black_white_brush, _
x, y, ancho, alto)
</pre>
<p>Variante 2</p>
<pre class="brush: vbnet; ruler: false; first-line: 1; highlight: [0]">
Dim y As Integer = 0
Dim x As Integer = 0
Dim ancho As Integer = Me.Width
Dim alto As Integer = Me.Height
Dim color1 As Color
Dim color2 As Color</code>

color1 = Color.DarkRed
color2 = Color.LightCoral

Dim colorear As New _
LinearGradientBrush( _
New Point(x, y), New Point(x + ancho, y), _
color1, color2)

Dim diag_brush As New _
LinearGradientBrush( _
New Point(x, y), New Point(x + ancho, y + alto), _
color1, color2)
e.Graphics.FillRectangle(diag_brush, _
x, y, ancho, alto)
</pre>
<p>Si te sirvieron, por favor, deja un comentario. Saludos</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solovb.net/index.php/2009/03/11/panel-con-colores-en-degrade-gradient/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
