First support fόr RadialGradientPaint in Graphics.setPaint

This commit is contained in:
smallsql 2013-01-19 10:45:42 +00:00
Π ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ 2433855645
ΠšΠΎΠΌΠΌΠΈΡ‚ 35a59490c6
1 ΠΈΠ·ΠΌΠ΅Π½Ρ‘Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ²: 49 Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠΉ ΠΈ 0 ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠΉ

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -1486,6 +1486,55 @@ namespace ikvm.awt
return;
}
if (paint is java.awt.RadialGradientPaint )
{
java.awt.RadialGradientPaint gradient = (java.awt.RadialGradientPaint)paint;
GraphicsPath path = new GraphicsPath();
SizeF size = GetSize();
PointF center = J2C.ConvertPoint(gradient.getCenterPoint());
//path.AddEllipse(center.X + size.Width * 2, center.Y + size.Height * 2, size.Width * 4, size.Height * 4);
//path.AddEllipse(center.X - size.Width / 2, center.Y - size.Height / 2, size.Width, size.Height);
float radius = gradient.getRadius();
int factor = (int)Math.Ceiling(Math.Max(size.Width, size.Height) / radius);
float diameter = radius * factor;
path.AddEllipse(center.X - diameter, center.Y - diameter, diameter * 2, diameter * 2);
java.awt.Color[] javaColors = gradient.getColors();
float[] fractions = gradient.getFractions();
ColorBlend colorBlend = new ColorBlend(javaColors.Length * factor);
Color[] colors = colorBlend.Colors;
float[] positions = colorBlend.Positions;
int length = javaColors.Length;
for (int f = 0; f < factor; f++)
{
int off = f * length;
for (int c = 0, j = length - 1; j >= 0; )
{
if (f == 0)
{
positions[c] = (1 - fractions[j]) / factor;
colors[c++] = J2C.ConvertColor(javaColors[j--]);//composite.GetColor(javaColors[i]);
}
else
{
positions[off + c] = (1 + f - fractions[j--]) / factor;
colors[off + c] = colors[c++];
}
}
}
PathGradientBrush pathBrush = new PathGradientBrush(path);
pathBrush.CenterPoint = center;
pathBrush.InterpolationColors = colorBlend;
brush = pathBrush;
pen.Brush = brush;
return;
}
throw new NotImplementedException("setPaint("+paint.GetType().FullName+")");
}