本文整理汇总了C#中MatterHackers.Agg.VertexSource.RoundedRect.normalize_radius方法的典型用法代码示例。如果您正苦于以下问题:C# RoundedRect.normalize_radius方法的具体用法?C# RoundedRect.normalize_radius怎么用?C# RoundedRect.normalize_radius使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatterHackers.Agg.VertexSource.RoundedRect
的用法示例。
在下文中一共展示了RoundedRect.normalize_radius方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDraw
public override void OnDraw(Graphics2D graphics2D)
{
ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());
ScanlineRasterizer ras = new ScanlineRasterizer();
scanline_unpacked_8 sl = new scanline_unpacked_8();
ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage);
clippingProxy.clear(new RGBA_Floats(0, 0, 0));
m_profile.text_size(8.0);
// draw a background to show how the alpha is working
int RectWidth = 32;
int xoffset = 238;
int yoffset = 171;
ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 7; j++)
{
if ((i + j) % 2 != 0)
{
VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth + xoffset, j * RectWidth + yoffset,
(i + 1) * RectWidth + xoffset, (j + 1) * RectWidth + yoffset, 2);
rect.normalize_radius();
ras.add_path(rect);
scanlineRenderer.RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(.9, .9, .9));
}
}
}
double ini_scale = 1.0;
Transform.Affine mtx1 = Affine.NewIdentity();
mtx1 *= Affine.NewScaling(ini_scale, ini_scale);
mtx1 *= Affine.NewTranslation(center_x, center_y);
VertexSource.Ellipse e1 = new MatterHackers.Agg.VertexSource.Ellipse();
e1.init(0.0, 0.0, 110.0, 110.0, 64);
Transform.Affine mtx_g1 = Affine.NewIdentity();
mtx_g1 *= Affine.NewScaling(ini_scale, ini_scale);
mtx_g1 *= Affine.NewScaling(m_SaveData.m_scale, m_SaveData.m_scale);
mtx_g1 *= Affine.NewScaling(m_scale_x, m_scale_y);
mtx_g1 *= Affine.NewRotation(m_SaveData.m_angle);
mtx_g1 *= Affine.NewTranslation(m_SaveData.m_center_x, m_SaveData.m_center_y);
mtx_g1.invert();
RGBA_Bytes[] color_profile = new RGBA_Bytes[256]; // color_type is defined in pixel_formats.h
for (int i = 0; i < 256; i++)
{
color_profile[i] = new RGBA_Bytes(m_spline_r.spline()[i],
m_spline_g.spline()[i],
m_spline_b.spline()[i],
m_spline_a.spline()[i]);
}
VertexSourceApplyTransform t1 = new VertexSourceApplyTransform(e1, mtx1);
IGradient innerGradient = null;
switch (m_GradTypeRBox.SelectedIndex)
{
case 0:
innerGradient = new gradient_radial();
break;
case 1:
innerGradient = new gradient_diamond();
break;
case 2:
innerGradient = new gradient_x();
break;
case 3:
innerGradient = new gradient_xy();
break;
case 4:
innerGradient = new gradient_sqrt_xy();
break;
case 5:
innerGradient = new gradient_conic();
break;
}
IGradient outerGradient = null;
switch (m_GradWrapRBox.SelectedIndex)
{
case 0:
outerGradient = new gradient_reflect_adaptor(innerGradient);
break;
case 1:
outerGradient = new gradient_repeat_adaptor(innerGradient);
break;
//.........这里部分代码省略.........
示例2: OnDraw
public override void OnDraw(Graphics2D graphics2D)
{
ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());
if (!didInit)
{
didInit = true;
OnInitialize();
}
if (m_gamma.Value != m_old_gamma)
{
m_gamma_lut.SetGamma(m_gamma.Value);
ImageIO.LoadImageData("spheres.bmp", m_SourceImage);
//m_SourceImage.apply_gamma_dir(m_gamma_lut);
m_old_gamma = m_gamma.Value;
}
ImageBuffer pixf = new ImageBuffer();
switch (widgetsSubImage.BitDepth)
{
case 24:
pixf.Attach(widgetsSubImage, new BlenderBGR());
break;
case 32:
pixf.Attach(widgetsSubImage, new BlenderBGRA());
break;
default:
throw new NotImplementedException();
}
ImageClippingProxy clippingProxy = new ImageClippingProxy(pixf);
clippingProxy.clear(new RGBA_Floats(1, 1, 1));
if (m_trans_type.SelectedIndex < 2)
{
// For the affine parallelogram transformations we
// calculate the 4-th (implicit) point of the parallelogram
m_quad.SetXN(3, m_quad.GetXN(0) + (m_quad.GetXN(2) - m_quad.GetXN(1)));
m_quad.SetYN(3, m_quad.GetYN(0) + (m_quad.GetYN(2) - m_quad.GetYN(1)));
}
ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
// draw a background to show how the alpha is working
int RectWidth = 70;
int xoffset = 50;
int yoffset = 50;
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 7; j++)
{
if ((i + j) % 2 != 0)
{
VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth + xoffset, j * RectWidth + yoffset,
(i + 1) * RectWidth + xoffset, (j + 1) * RectWidth + yoffset, 2);
rect.normalize_radius();
g_rasterizer.add_path(rect);
scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(.2, .2, .2));
}
}
}
//--------------------------
// Render the "quad" tool and controls
g_rasterizer.add_path(m_quad);
scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0, 0.3, 0.5, 0.1));
// Prepare the polygon to rasterize. Here we need to fill
// the destination (transformed) polygon.
g_rasterizer.SetVectorClipBox(0, 0, Width, Height);
g_rasterizer.reset();
int b = 0;
g_rasterizer.move_to_d(m_quad.GetXN(0) - b, m_quad.GetYN(0) - b);
g_rasterizer.line_to_d(m_quad.GetXN(1) + b, m_quad.GetYN(1) - b);
g_rasterizer.line_to_d(m_quad.GetXN(2) + b, m_quad.GetYN(2) + b);
g_rasterizer.line_to_d(m_quad.GetXN(3) - b, m_quad.GetYN(3) + b);
//typedef agg::span_allocator<color_type> span_alloc_type;
span_allocator sa = new span_allocator();
image_filter_bilinear filter_kernel = new image_filter_bilinear();
ImageFilterLookUpTable filter = new ImageFilterLookUpTable(filter_kernel, true);
ImageBufferAccessorClamp source = new ImageBufferAccessorClamp(m_SourceImage);
stopwatch.Restart();
switch (m_trans_type.SelectedIndex)
{
case 0:
{
/*
agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
interpolator_type interpolator(tr);
//.........这里部分代码省略.........
示例3: OnDraw
public override void OnDraw(Graphics2D graphics2D)
{
ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());
int width = (int)widgetsSubImage.Width;
int height = (int)widgetsSubImage.Height;
if (numMasksSlider.Value != sliderValue)
{
generate_alpha_mask(width, height);
sliderValue = numMasksSlider.Value;
}
rasterizer.SetVectorClipBox(0, 0, width, height);
unsafe
{
alphaMaskImageBuffer.AttachBuffer(alphaByteArray, 0, width, height, width, 8, 1);
MatterHackers.Agg.Image.AlphaMaskAdaptor imageAlphaMaskAdaptor = new MatterHackers.Agg.Image.AlphaMaskAdaptor(widgetsSubImage, alphaMask);
ImageClippingProxy alphaMaskClippingProxy = new ImageClippingProxy(imageAlphaMaskAdaptor);
ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage);
Affine transform = Affine.NewIdentity();
transform *= Affine.NewTranslation(-lionShape.Center.x, -lionShape.Center.y);
transform *= Affine.NewScaling(lionScale, lionScale);
transform *= Affine.NewRotation(angle + Math.PI);
transform *= Affine.NewSkewing(skewX / 1000.0, skewY / 1000.0);
transform *= Affine.NewTranslation(Width / 2, Height / 2);
clippingProxy.clear(new RGBA_Floats(1, 1, 1));
ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
// draw a background to show how the mask is working better
int RectWidth = 30;
for (int i = 0; i < 40; i++)
{
for (int j = 0; j < 40; j++)
{
if ((i + j) % 2 != 0)
{
VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth, j * RectWidth, (i + 1) * RectWidth, (j + 1) * RectWidth, 0);
rect.normalize_radius();
// Drawing as an outline
rasterizer.add_path(rect);
scanlineRenderer.render_scanlines_aa_solid(clippingProxy, rasterizer, scanlineCache, new RGBA_Bytes(.9, .9, .9));
}
}
}
//int x, y;
// Render the lion
VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, transform);
scanlineRenderer.RenderSolidAllPaths(alphaMaskClippingProxy, rasterizer, scanlineCache, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);
/*
// Render random Bresenham lines and markers
agg::renderer_markers<amask_ren_type> m(r);
for(i = 0; i < 50; i++)
{
m.line_color(agg::rgba8(randGenerator.Next() & 0x7F,
randGenerator.Next() & 0x7F,
randGenerator.Next() & 0x7F,
(randGenerator.Next() & 0x7F) + 0x7F));
m.fill_color(agg::rgba8(randGenerator.Next() & 0x7F,
randGenerator.Next() & 0x7F,
randGenerator.Next() & 0x7F,
(randGenerator.Next() & 0x7F) + 0x7F));
m.line(m.coord(randGenerator.Next() % width), m.coord(randGenerator.Next() % height),
m.coord(randGenerator.Next() % width), m.coord(randGenerator.Next() % height));
m.marker(randGenerator.Next() % width, randGenerator.Next() % height, randGenerator.Next() % 10 + 5,
agg::marker_e(randGenerator.Next() % agg::end_of_markers));
}
// Render random anti-aliased lines
double w = 5.0;
agg::line_profile_aa profile;
profile.width(w);
typedef agg::renderer_outline_aa<amask_ren_type> renderer_type;
renderer_type ren(r, profile);
typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
rasterizer_type ras(ren);
ras.round_cap(true);
for(i = 0; i < 50; i++)
{
ren.Color = agg::rgba8(randGenerator.Next() & 0x7F,
randGenerator.Next() & 0x7F,
randGenerator.Next() & 0x7F,
//255));
(randGenerator.Next() & 0x7F) + 0x7F);
ras.move_to_d(randGenerator.Next() % width, randGenerator.Next() % height);
ras.line_to_d(randGenerator.Next() % width, randGenerator.Next() % height);
//.........这里部分代码省略.........
示例4: OnDraw
public override void OnDraw(Graphics2D graphics2D)
{
ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());
IImageByte backBuffer = widgetsSubImage;
GammaLookUpTable gamma = new GammaLookUpTable(m_gamma.Value);
IRecieveBlenderByte NormalBlender = new BlenderBGRA();
IRecieveBlenderByte GammaBlender = new BlenderGammaBGRA(gamma);
ImageBuffer rasterNormal = new ImageBuffer();
rasterNormal.Attach(backBuffer, NormalBlender);
ImageBuffer rasterGamma = new ImageBuffer();
rasterGamma.Attach(backBuffer, GammaBlender);
ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal);
ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma);
clippingProxyNormal.clear(m_white_on_black.Checked ? new RGBA_Floats(0, 0, 0) : new RGBA_Floats(1, 1, 1));
ScanlineRasterizer ras = new ScanlineRasterizer();
ScanlineCachePacked8 sl = new ScanlineCachePacked8();
VertexSource.Ellipse e = new VertexSource.Ellipse();
// TODO: If you drag the control circles below the bottom of the window we get an exception. This does not happen in AGG.
// It needs to be debugged. Turning on clipping fixes it. But standard agg works without clipping. Could be a bigger problem than this.
//ras.clip_box(0, 0, width(), height());
// Render two "control" circles
e.init(m_x[0], m_y[0], 3, 3, 16);
ras.add_path(e);
ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127));
e.init(m_x[1], m_y[1], 3, 3, 16);
ras.add_path(e);
scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127));
double d = m_offset.Value;
// Creating a rounded rectangle
VertexSource.RoundedRect r = new VertexSource.RoundedRect(m_x[0] + d, m_y[0] + d, m_x[1] + d, m_y[1] + d, m_radius.Value);
r.normalize_radius();
// Drawing as an outline
if (!m_DrawAsOutlineCheckBox.Checked)
{
Stroke p = new Stroke(r);
p.width(1.0);
ras.add_path(p);
}
else
{
ras.add_path(r);
}
scanlineRenderer.render_scanlines_aa_solid(clippingProxyGamma, ras, sl, m_white_on_black.Checked ? new RGBA_Bytes(255, 255, 255) : new RGBA_Bytes(0, 0, 0));
base.OnDraw(graphics2D);
}
示例5: OnDraw
public override void OnDraw(Graphics2D graphics2D)
{
GammaLookUpTable gamma = new GammaLookUpTable(m_gamma.Value);
IRecieveBlenderByte NormalBlender = new BlenderBGRA();
IRecieveBlenderByte GammaBlender = new BlenderGammaBGRA(gamma);
ImageBuffer rasterNormal = new ImageBuffer(NewGraphics2D().DestImage, NormalBlender);
ImageBuffer rasterGamma = new ImageBuffer(NewGraphics2D().DestImage, GammaBlender);
ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal);
ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma);
clippingProxyNormal.clear(new RGBA_Floats(0, 0, 0));
ScanlineRasterizer ras = new ScanlineRasterizer();
ScanlineCachePacked8 sl = new ScanlineCachePacked8();
VertexSource.Ellipse e = new VertexSource.Ellipse();
// TODO: If you drag the control circles below the bottom of the window we get an exception. This does not happen in AGG.
// It needs to be debugged. Turning on clipping fixes it. But standard agg works without clipping. Could be a bigger problem than this.
//ras.clip_box(0, 0, width(), height());
// Render two "control" circles
e.init(m_x[0], m_y[0], 3, 3, 16);
ras.add_path(e);
ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127));
e.init(m_x[1], m_y[1], 3, 3, 16);
ras.add_path(e);
scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127));
// Creating a rounded rectangle
VertexSource.RoundedRect r = new VertexSource.RoundedRect(m_x[0], m_y[0], m_x[1], m_y[1], 10);
r.normalize_radius();
// Drawing as an outline
Stroke p = new Stroke(r);
p.width(1.0);
ras.add_path(p);
//Renderer.RenderSolid(clippingProxyGamma, ras, sl, new RGBA_Bytes(0, 0, 0));
scanlineRenderer.render_scanlines_aa_solid(clippingProxyGamma, ras, sl, new RGBA_Bytes(255, 1, 1));
/*
int i;
// radial line test
//-------------------------
dashed_line<rasterizer_type,
renderer_scanline_type,
scanline_type> dash(ras, ren_sl, sl);
double cx = width() / 2.0;
double cy = height() / 2.0;
ren_sl.color(agg::rgba(1.0, 1.0, 1.0, 0.2));
for(i = 180; i > 0; i--)
{
double n = 2.0 * agg::pi * i / 180.0;
dash.draw(cx + min(cx, cy) * sin(n), cy + min(cx, cy) * cos(n),
cx, cy,
1.0, (i < 90) ? i : 0.0);
}
typedef agg::gradient_x gradient_func_type;
typedef agg::span_interpolator_linear<> interpolator_type;
typedef agg::span_allocator<color_type> span_allocator_type;
typedef agg::pod_auto_array<color_type, 256> color_array_type;
typedef agg::span_gradient<color_type,
interpolator_type,
gradient_func_type,
color_array_type> span_gradient_type;
typedef agg::renderer_scanline_aa<renderer_base_type,
span_allocator_type,
span_gradient_type> renderer_gradient_type;
gradient_func_type gradient_func; // The gradient function
agg::trans_affine gradient_mtx; // Affine transformer
interpolator_type span_interpolator(gradient_mtx); // Span interpolator
span_allocator_type span_allocator; // Span Allocator
color_array_type gradient_colors; // The gradient colors
span_gradient_type span_gradient(span_interpolator,
gradient_func,
gradient_colors,
0, 100);
renderer_gradient_type ren_gradient(ren_base, span_allocator, span_gradient);
dashed_line<rasterizer_type,
renderer_gradient_type,
scanline_type> dash_gradient(ras, ren_gradient, sl);
//.........这里部分代码省略.........