本文整理汇总了C#中Cairo.Rectangle方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.Rectangle方法的具体用法?C# Cairo.Rectangle怎么用?C# Cairo.Rectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo
的用法示例。
在下文中一共展示了Cairo.Rectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(Cairo.Context cr)
{
cr.Save();
cr.Color = new Color(1.0, 1.0, 1.0);
cr.Rectangle(X0, Y0, X1 - X0, Y1 - Y0);
cr.Fill();
cr.Color = new Color(0.0, 0.0, 0.0);
cr.Rectangle(X0, Y0, X1 - X0, Y1 - Y0);
cr.Stroke();
cr.Restore();
}
示例2: DrawPaper
protected void DrawPaper(Cairo.Context cr, double x, double y, double w, double h)
{
// make the background white with a line around
cr.Rectangle(x+shadowOffset*2,y+shadowOffset*2,w-shadowOffset*2,h-shadowOffset*2);
cr.Color = shadowColor;
cr.Fill();
GetInnerRegion(ref x,ref y,ref w,ref h);
cr.Rectangle(x,y,w,h);
cr.Color = new Cairo.Color(0, 0, 0);
cr.StrokePreserve();
cr.Color = new Cairo.Color(1, 1, 1);
cr.Fill();
}
示例3: draw
static void draw (Cairo.Context gr, int width, int height)
{
gr.Scale (width, height);
gr.LineWidth = 0.04;
LinearGradient pat;
pat = new LinearGradient (0.0, 0.0, 0.0, 1.0);
pat.AddColorStop (1, new Color (0, 0, 0, 1) );
pat.AddColorStop (0, new Color (1, 1, 1, 1) );
gr.Rectangle ( new PointD (0, 0),
1, 1
);
gr.Pattern = pat;
gr.Fill ();
pat.Destroy ();
RadialGradient pat2 = new RadialGradient (0.45, 0.4, 0.1,
0.4, 0.4, 0.5);
pat2.AddColorStop (0, new Color (1, 1, 1, 1) );
pat2.AddColorStop (1, new Color (0, 0, 0, 1) );
gr.Pattern = pat2;
gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
gr.Fill ();
pat2.Destroy ();
}
示例4: ClippedRender
protected override void ClippedRender (Cairo.Context cr)
{
Brush brush = Background;
if (!brush.IsValid) {
return;
}
double x = Double.IsNaN (brush.Width)
? 0
: (RenderSize.Width - brush.Width) * XAlign;
double y = Double.IsNaN (brush.Height)
? 0
: (RenderSize.Height - brush.Height) * YAlign;
cr.Rectangle (0, 0, RenderSize.Width, RenderSize.Height);
cr.ClipPreserve ();
if (x != 0 || y != 0) {
cr.Translate (x, y);
}
cr.Antialias = Cairo.Antialias.None;
brush.Apply (cr);
cr.Fill ();
}
示例5: Fill
public static void Fill(Cairo.Context context, int width, int height, Cairo.Color color)
{
context.NewPath();
context.Color = color;
context.Rectangle(0, 0, width, height);
context.Fill();
}
示例6: draw
static void draw (Cairo.Context gr, int width, int height)
{
int w, h;
ImageSurface image;
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.Arc (0.5, 0.5, 0.3, 0, 2*M_PI);
gr.Clip ();
gr.NewPath ();
image = new ImageSurface("data/e.png");
w = image.Width;
h = image.Height;
gr.Scale (1.0/w, 1.0/h);
image.Show (gr, 0, 0);
image.Destroy();
gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
gr.Clip ();
gr.NewPath ();
gr.Rectangle (new PointD (0, 0), 1, 1);
gr.Fill ();
gr.Color = new Color (0, 1, 0, 1);
gr.MoveTo ( new PointD (0, 0) );
gr.LineTo ( new PointD (1, 1) );
gr.MoveTo ( new PointD (1, 0) );
gr.LineTo ( new PointD (0, 1) );
gr.Stroke ();
}
示例7: OnDrawn
protected override bool OnDrawn(Cairo.Context cr)
{
double step_width = Allocation.Width / (double)steps;
double step_height = Allocation.Height / (double)steps;
double h = 1.0;
double s = 0.0;
for (int xi = 0, i = 0; xi < steps; xi++) {
for (int yi = 0; yi < steps; yi++, i++) {
double bg_b = (double)(i / 255.0);
double fg_b = 1.0 - bg_b;
double x = xi * step_width;
double y = yi * step_height;
cr.Rectangle (x, y, step_width, step_height);
cr.Color = CairoExtensions.ColorFromHsb (h, s, bg_b);
cr.Fill ();
int tw, th;
Pango.Layout layout = new Pango.Layout (PangoContext);
layout.SetText (((int)(bg_b * 255.0)).ToString ());
layout.GetPixelSize (out tw, out th);
cr.Translate (0.5, 0.5);
cr.MoveTo (x + (step_width - tw) / 2.0, y + (step_height - th) / 2.0);
cr.Color = CairoExtensions.ColorFromHsb (h, s, fg_b);
PangoCairoHelper.ShowLayout (cr, layout);
cr.Translate (-0.5, -0.5);
}
}
return true;
}
示例8: OnDrawn
protected override bool OnDrawn(Cairo.Context cr)
{
bool ret = true;
var rect = this.Allocation;
if (rect.Width > 0 && rect.Height > 0)
{
var arrowWidth = popupButton.Allocation.Width;
var arrowPos = rect.Width - arrowWidth;
var arrowSize = 10;
StyleContext.Save();
StyleContext.AddClass("entry");
StyleContext.RenderBackground(cr, 0, 0, rect.Width, rect.Height);
ret = base.OnDrawn(cr);
StyleContext.RenderArrow(cr, Math.PI, arrowPos, (rect.Height - arrowSize) / 2, arrowSize);
cr.SetSourceColor(new Cairo.Color(.8, .8, .8));
cr.Rectangle(arrowPos - 5, 2, 1, rect.Height - 4);
cr.Fill();
Entry.StyleContext.RenderFrame(cr, 0, 0, rect.Width, rect.Height);
StyleContext.Restore();
}
return ret;
}
示例9:
bool IFoldMarginMarker.DrawBackground (TextEditor e, double marginWidth, Cairo.Context cr, Cairo.Rectangle area, DocumentLine documentLine, int line, double x, double y, double lineHeight)
{
if (cache.CurrentSelectedTextMarker != null && cache.CurrentSelectedTextMarker != this)
return false;
cr.Rectangle (x, y, marginWidth, lineHeight);
cr.Color = LineColor.Color;
cr.Fill ();
return true;
}
示例10: DrawBackground
public override bool DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics)
{
if (metrics.SelectionStart > 0)
return true;
cr.SetSourceColor (color);
cr.Rectangle (metrics.TextRenderStartPosition, metrics.LineYRenderStartPosition, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight);
cr.Fill ();
return true;
}
示例11: BasicDraw
public override void BasicDraw(Cairo.Context context)
{
context.Rectangle(DisplayBox.X, DisplayBox.Y,
DisplayBox.Width, DisplayBox.Height);
context.Stroke();
classname.BasicDraw(context);
}
示例12: DrawBackground
public override bool DrawBackground (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
{
if (metrics.SelectionStart > 0)
return true;
cr.Color = color;
cr.Rectangle (metrics.TextRenderStartPosition, y, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight);
cr.Fill ();
return true;
}
示例13: DrawMarginBackground
void DrawMarginBackground (Cairo.Context cr, int line, double x, double y, double lineHeight)
{
if (editor.Caret.Line == line) {
editor.TextViewMargin.DrawCaretLineMarker (cr, x, y, Width, lineHeight);
return;
}
cr.Rectangle (x, y, Width, lineHeight);
cr.SetSourceColor (editor.ColorStyle.LineNumbers.Background);
cr.Fill ();
}
示例14: Render
public virtual void Render(Cairo.Context cr, Layout layout, double x, double y, double w, double h)
{
cr.Save();
cr.Translate (x,y);
// make the background white
cr.Color = new Cairo.Color(1, 1, 1);
cr.Rectangle(0,0,w,h);
cr.Fill();
// calc some values
int lw;
string prefix = "INV-"+InventoryAbbreviation+"-";
string idString = Id.ToString("0000000000");
// basic text stuff
layout.FontDescription = FontDescription.FromString(CalcFont(Layout,layout,h));
layout.Width = (int)(w*Scale.PangoScale);
layout.Alignment = Alignment.Center;
// draw the description
int descH = 0;
if(Layout.UseDescription){
Layout descLayout = layout.Copy();
descLayout.SetText (Description);
descLayout.GetPixelSize(out lw, out descH);
layout.Ellipsize = EllipsizeMode.Middle;
layout.Justify = true;
cr.Color = new Cairo.Color(0, 0, 0);
Pango.CairoHelper.ShowLayout (cr, descLayout);
}
// draw the barcode text
int codeH = 0;
if(Layout.UseBarcodeText){
Layout codeLayout = layout.Copy();
codeLayout.SetText (prefix+idString);
codeLayout.GetPixelSize(out lw, out codeH);
cr.MoveTo(0,h-(double)codeH);
cr.Color = new Cairo.Color(0, 0, 0);
Pango.CairoHelper.ShowLayout (cr, codeLayout);
}
// draw the barcode
if(Layout.UseBarcode){
double barcodeH = h-((double)codeH+(double)descH+Layout.SpacingSize*2);
if(barcodeH>0){
IBarcode bc = new Code128();
bc.WriteString(prefix+idString);
bc.WriteEnd();
RenderBarcode(bc,cr,0,descH+Layout.SpacingSize,w,barcodeH);
}
}
cr.Restore();
}
示例15: DrawFrame
protected override void DrawFrame (Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor)
{
RectangleD rect = DisplayBox;
rect.OffsetDot5();
context.Rectangle(GdkCairoHelper.CairoRectangle(rect));
context.Color = fillColor;
context.FillPreserve();
context.Color = lineColor;
context.LineWidth = lineWidth;
context.Stroke();
}