public SetSourceRGB ( double r, double g, double b ) : void | ||
r | double | |
g | double | |
b | double | |
return | void |
private void OnDrawPage(object obj, Gtk.DrawPageArgs args) { PrintContext context = args.Context; Cairo.Context cr = context.CairoContext; double width = context.Width; cr.Rectangle(0, 0, width, headerHeight); cr.SetSourceRGB(0.8, 0.8, 0.8); cr.FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.LineWidth = 1; cr.Stroke(); Pango.Layout layout = context.CreatePangoLayout(); Pango.FontDescription desc = Pango.FontDescription.FromString("sans 14"); layout.FontDescription = desc; layout.SetText(fileName); layout.Width = (int)width; layout.Alignment = Pango.Alignment.Center; int layoutWidth, layoutHeight; layout.GetSize(out layoutWidth, out layoutHeight); double textHeight = (double)layoutHeight / (double)pangoScale; cr.MoveTo(width / 2, (headerHeight - textHeight) / 2); Pango.CairoHelper.ShowLayout(cr, layout); string pageStr = String.Format("{0}/{1}", args.PageNr + 1, numPages); layout.SetText(pageStr); layout.Alignment = Pango.Alignment.Right; cr.MoveTo(width - 2, (headerHeight - textHeight) / 2); Pango.CairoHelper.ShowLayout(cr, layout); layout = null; layout = context.CreatePangoLayout(); desc = Pango.FontDescription.FromString("mono"); desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; cr.MoveTo(0, headerHeight + headerGap); int line = args.PageNr * linesPerPage; for (int i = 0; i < linesPerPage && line < numLines; i++) { layout.SetText(lines[line]); Pango.CairoHelper.ShowLayout(cr, layout); cr.RelMoveTo(0, fontSize); line++; } (cr as IDisposable).Dispose(); layout = null; }
protected void OnDrawingarea1ExposeEvent(object o, ExposeEventArgs args) { Console.WriteLine("Exposed"); DrawingArea area = (DrawingArea)o; Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow); int width = area.Allocation.Width; int height = area.Allocation.Height; int radius = (width < height ? width : height); cr.SetSourceRGB(0.0, 0.0, 0.0); cr.Rectangle(0, 0, width, height); cr.Fill(); cr.Translate(this.offsetX, this.offsetY); // move "pointer" cr.Scale(this.scale, this.scale); cr.SetSourceSurface(this.surface, 0, 0); // offset surface cr.Rectangle(0, 0, this.surface.Width, // offset cutout this.surface.Height); cr.Fill(); // apply cr.SetSourceRGB(1.0, 0.0, 0.0); cr.Arc(this.pointX, this.pointY, 2, 0, 2 * Math.PI); cr.Fill(); ((IDisposable)cr.GetTarget()).Dispose(); ((IDisposable)cr).Dispose(); }
//http://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cairo/cookbook/ private static void drawRoundedRectangle(double x, double y, double width, double height, double radius, Cairo.Context g, Cairo.Color color) { g.Save(); if ((radius > height / 2) || (radius > width / 2)) { radius = min(height / 2, width / 2); } g.MoveTo(x, y + radius); g.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2); g.LineTo(x + width - radius, y); g.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0); g.LineTo(x + width, y + height - radius); g.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2); g.LineTo(x + radius, y + height); g.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); g.ClosePath(); g.Restore(); g.SetSourceRGB(color.R, color.G, color.B); g.FillPreserve(); g.SetSourceRGB(0, 0, 0); g.LineWidth = 2; g.Stroke(); }
//http://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cairo/cookbook/ private static void drawRoundedRectangle(double x, double y, double width, double height, double radius, Cairo.Context g, Cairo.Color color) { g.Save(); //manage negative widths if (width < 0) { x += width; //it will shift to the left (width is negative) width *= -1; } if ((radius > height / 2) || (radius > width / 2)) { radius = min(height / 2, width / 2); } g.MoveTo(x, y + radius); g.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2); g.LineTo(x + width - radius, y); g.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0); g.LineTo(x + width, y + height - radius); g.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2); g.LineTo(x + radius, y + height); g.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI); g.ClosePath(); g.Restore(); g.SetSourceRGB(color.R, color.G, color.B); g.FillPreserve(); g.SetSourceRGB(0, 0, 0); g.LineWidth = 2; g.Stroke(); }
//draw bar with specific (w)idth, (h)eight, grayscale (c)olor and fill level public void drawbar(Cairo.Context context, int w, int h, int c, double fill) { context.Save(); context.LineWidth = 0.75; //Fill the area double gray_value = ColorChan(c); context.SetSourceRGB(gray_value, gray_value, gray_value); context.Rectangle(0, 0, w, h); context.Fill(); //White color context.SetSourceRGB(1, 1, 1); //Updated coordinates with offset int h0 = 10, x0 = 10, w0 = w - x0, y0 = (h - 10) / 2, w1 = w0 - x0; context.Rectangle(x0, y0, w1, h0); context.Fill(); //Fill the bar double r = ColorChan(255), g = ColorChan(186), b = ColorChan(0); context.SetSourceRGB(r, g, b); context.Rectangle(x0, y0, w1 * fill, h0); context.Fill(); //Draw shadow of the bar gray_value = 0.2; for (int i = 0; i < 3; ++i) { context.SetSourceRGB(gray_value, gray_value, gray_value); drawshadow(context, x0 + i, y0 + i, w0 + i, h0 + i); context.LineWidth -= 0.2; gray_value += 0.3; } context.Restore(); }
protected void DrawingPlace(object sender, ExposeEventArgs args) { DrawingArea area = (DrawingArea)sender; Cairo.Context cc = Gdk.CairoHelper.Create(area.GdkWindow); cc.SelectFontFace("Sans", Cairo.FontSlant.Italic, Cairo.FontWeight.Bold); cc.SetFontSize(25); cc.MoveTo(15, 20); cc.ShowText("Диаграмма"); cc.MoveTo(330, 40); cc.SetFontSize(15); cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal); cc.ShowText("Выручка"); cc.SetSourceRGB(0.2, 0.23, 0.9); cc.LineWidth = 1; int s = 50; int s_next = 40; int w; int i = 0; int h = 65; foreach (var item in global_1) { w = Convert.ToInt32(item); cc.SetFontSize(15); cc.MoveTo(0, h); cc.SetSourceRGB(0, 0, 0); cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal); cc.ShowText(Convert.ToString(i + 1)); i = i + 1; cc.SetSourceRGB(0.2, 0.23, 0.9); cc.Rectangle(10, s, w, 30); h = h + 40; s = s + s_next; } cc.LineTo(10, 50); cc.LineTo(10, 390); cc.StrokePreserve(); cc.Fill(); cc.LineTo(10, 50); cc.LineTo(390, 50); cc.StrokePreserve(); cc.Fill(); cc.MoveTo(0, 390); cc.SetSourceRGB(0, 0, 0); cc.SetFontSize(15); cc.SelectFontFace("Sans", Cairo.FontSlant.Normal, Cairo.FontWeight.Normal); cc.ShowText("Период"); ((IDisposable)cc).Dispose(); }
public void CreatePng() { const int Width = 480; const int Height = 160; const int CheckSize = 10; const int Spacing = 2; // Create an Image-based surface with data stored in ARGB32 format and a context, // "using" is used here to ensure that they are Disposed once we are done using (ImageSurface surface = new ImageSurface(Format.ARGB32, Width, Height)) using (Context cr = new Cairo.Context(surface)) { // Start drawing a checkerboard int i, j, xcount, ycount; xcount = 0; i = Spacing; while (i < Width) { j = Spacing; ycount = xcount % 2; // start with even/odd depending on row while (j < Height) { if (ycount % 2 != 0) { cr.SetSourceRGB(1, 0, 0); } else { cr.SetSourceRGB(1, 1, 1); } // If we're outside the clip, this will do nothing. cr.Rectangle(i, j, CheckSize, CheckSize); cr.Fill(); j += CheckSize + Spacing; ++ycount; } i += CheckSize + Spacing; ++xcount; } // Select a font to draw with cr.SelectFontFace("serif", FontSlant.Normal, FontWeight.Bold); cr.SetFontSize(64.0); // Select a color (blue) cr.SetSourceRGB(0, 0, 1); // Draw cr.MoveTo(20, 100); cr.ShowText("Hello, World"); surface.WriteToPng("test.png"); } }
protected override bool OnDrawn(Cairo.Context ctx) { // color the screen black ctx.SetSourceRGB(0, 0, 0); ctx.Paint(); // Normally (0,0) is in the corner, but we want it in the middle, so we must translate: ctx.Translate(AllocatedWidth / 2, AllocatedHeight / 2); var bounds = bounds_multiplier * max * new Vector3(1, 1, 1); // we care about the limiting factor, since most orbits will be bounded roughly by a square // but screens are rectangular var scale = Math.Min((AllocatedWidth / 2) * bounds.x, (AllocatedHeight / 2) / bounds.y); ctx.Scale(scale, scale); if (paths == null) { this.ClearPaths(); } order = order.OrderByDescending(x => Vector3.Magnitude(sys[x].position - camera.position)).ToArray(); for (int i = 0; i < sys.Count; i++) { var body = sys[order[i]]; var cl = body.color; ctx.SetSourceRGB(cl.x, cl.y, cl.z); var T = camera.Transform(body.position - sys.origin); //camera.position);// - camera.Transform(sys.origin); var r = radius_multiplier * camera.TransformProjectionRadius(T, body.radius); //body.radius; var pos = camera.TransformProjection(T); ctx.Arc(pos.x, pos.y, r, 0, 2 * Math.PI); ctx.Fill(); Vector3 lastPath; try { lastPath = camera.TransformProjection(camera.Transform(paths[order[i]][0])); } catch (ArgumentOutOfRangeException) { lastPath = Vector3.zero; } ctx.LineWidth = Math.Min(LINE_MULTIPLIER * radius_multiplier * body.radius, LINE_MULTIPLIER * r); foreach (Vector3 p in paths[order[i]]) { pos = camera.TransformProjection(camera.Transform(p)); ctx.MoveTo(lastPath.x, lastPath.y); ctx.LineTo(pos.x, pos.y); ctx.Stroke(); lastPath = pos; } paths[order[i]].Add(body.position - sys.origin); if (paths[order[i]].Count > line_max) { paths[order[i]] = paths[order[i]].TakeLast(line_max).ToList(); } } return(true); }
/// <summary> /// Raises the expose event and draws the map. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Arguments.</param> private void OnExpose(object sender, ExposeEventArgs args) { DrawingArea area = (DrawingArea)sender; Cairo.Context cairoContext = Gdk.CairoHelper.Create(area.GdkWindow); // Draw the background. cairoContext.Rectangle(0, 0, viewWidth, viewHeight); cairoContext.SetSourceRGB(255, 255, 255); cairoContext.StrokePreserve(); cairoContext.Fill(); // Draw the grid. cairoContext.LineWidth = 1.0; cairoContext.LineCap = LineCap.Butt; cairoContext.SetSourceRGB(0, 0, 0); // Columns. int position = cellWidth; for (; position <= viewWidth - cellWidth; position += cellWidth) { // We have to add 0.5 to the x position otherwise Cairo will // smear it across 2 pixels. cairoContext.MoveTo(position + 0.5, 0.0); cairoContext.LineTo(position + 0.5, viewHeight); cairoContext.Stroke(); } // Rows. position = cellHeight; for (; position <= viewHeight - cellHeight; position += cellHeight) { // We have to add 0.5 to the y position otherwise Cairo will // smear it across 2 pixels. cairoContext.MoveTo(0.0, position + 0.5); cairoContext.LineTo(viewWidth, position + 0.5); cairoContext.Stroke(); } if (robotView.Robot.PathPointList.Count > 1) { pathView.Draw(cairoContext, centerX, centerY, 1.0); } robotView.Draw(cairoContext, centerX, centerY, 1.0); landmarkView.Draw(cairoContext, centerX, centerY, 1.0); ((IDisposable)cairoContext.GetTarget()).Dispose(); ((IDisposable)cairoContext).Dispose(); }
private void Render(Clutter.CairoTexture texture, int with_state, bool outwards) { texture.Clear(); Cairo.Context context = texture.Create(); double lwidth = 1; double hlwidth = lwidth * 0.5; //Draw outline rectangles: context.Rectangle(hlwidth, hlwidth, texture.Width - lwidth, texture.Height - lwidth); context.SetSourceRGB(1.0, 1.0, 1.0); context.LineWidth = lwidth; context.StrokePreserve(); double sat = (with_state == 0 ? 0.4 : (with_state == 1 ? 0.6 : 0.8)); context.SetSourceRGB(sat, sat, sat); context.Fill(); double dim = 4; context.MoveTo(-dim, 0); context.LineTo(outwards ? 0 : -dim, outwards ? 0 : dim); context.LineTo(0, dim); context.MoveTo(-dim, dim); context.LineTo(0, 0); context.ClosePath(); Cairo.Path arrow = context.CopyPath(); context.NewPath(); double margin = 2 + hlwidth; PointD center = new PointD(texture.Width * 0.5, texture.Height * 0.5); PointD transl = new PointD(center.X - margin, -(center.Y - margin)); context.LineWidth = lwidth; sat = (with_state == 1 ? 0.0 : 1.0); context.SetSourceRGB(sat, sat, sat); context.Translate(center.X, center.Y); for (int i = 0; i < 4; i++) { context.Rotate(Math.PI * 0.5 * i); context.Translate(transl.X, transl.Y); context.AppendPath(arrow); context.Stroke(); context.Translate(-transl.X, -transl.Y); } ((IDisposable)arrow).Dispose(); ((IDisposable)context.Target).Dispose(); ((IDisposable)context).Dispose(); }
private static void plotArc(int centerx, int centery, int radius, double start, double end, Cairo.Context g, Cairo.Color color) { //pie chart g.MoveTo(centerx, centery); g.Arc(centerx, centery, radius, start * Math.PI, end * Math.PI); g.ClosePath(); g.SetSourceRGB(color.R, color.G, color.B); g.FillPreserve(); g.SetSourceRGB(0, 0, 0); g.LineWidth = 2; g.Stroke(); }
protected override bool OnDrawn(Cairo.Context cr) { if (this.isDirty) { this.Rebuild(); } bool baseDrawnResult = base.OnDrawn(cr); cr.SetFontSize(FONT_HEIGHT); cr.SelectFontFace("Mono", FontSlant.Normal, FontWeight.Normal); cr.Rectangle(0.0, 0.0, this.allocRect.Width, this.allocRect.Height); cr.SetSourceRGB(1, 1, 1); cr.Fill(); var gradient = new LinearGradient(0.0, 0.0, 0.0, this.allocRect.Height); gradient.AddColorStopRgb(0.0, new Color(0.4, 0.4, 0.4)); gradient.AddColorStopRgb(0.1, new Color(1.0, 1.0, 1.0)); gradient.AddColorStopRgb(0.2, new Color(0.6, 0.6, 0.6)); gradient.AddColorStopRgb(1.0, new Color(0.1, 0.1, 0.1)); cr.LineWidth = 1; foreach (var box in this.boxen) { this.RoundedRect(cr, box.Rect, 4.0); cr.SetSource(gradient); cr.FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.Stroke(); int x = (int)(box.Rect.X + TAGBOX_PADDING * 2 + TAGBOX_XSIZE); int y = (int)(box.Rect.Y + box.Rect.Height / 2 + cr.FontExtents.Height / 2 - cr.FontExtents.Descent / 2); cr.MoveTo(x, y); cr.TextPath(box.Tag); cr.SetSourceRGB(1.0, 1.0, 1.0); cr.Fill(); cr.MoveTo(box.Rect.X + TAGBOX_PADDING + TAGBOX_XOFFSET, box.Rect.Y + TAGBOX_PADDING + TAGBOX_XOFFSET); cr.RelLineTo(TAGBOX_XSIZE - TAGBOX_XOFFSET * 2, TAGBOX_XSIZE - TAGBOX_XOFFSET * 2); cr.MoveTo(box.Rect.X + TAGBOX_PADDING + TAGBOX_XOFFSET, box.Rect.Y + TAGBOX_PADDING + TAGBOX_XSIZE - TAGBOX_XOFFSET); cr.RelLineTo(TAGBOX_XSIZE - TAGBOX_XOFFSET * 2, -TAGBOX_XSIZE + TAGBOX_XOFFSET * 2); cr.Stroke(); } return(baseDrawnResult); }
public void CreatePng () { const int Width = 480; const int Height = 160; const int CheckSize = 10; const int Spacing = 2; // Create an Image-based surface with data stored in ARGB32 format and a context, // "using" is used here to ensure that they are Disposed once we are done using (ImageSurface surface = new ImageSurface (Format.ARGB32, Width, Height)) using (Context cr = new Cairo.Context (surface)) { // Start drawing a checkerboard int i, j, xcount, ycount; xcount = 0; i = Spacing; while (i < Width) { j = Spacing; ycount = xcount % 2; // start with even/odd depending on row while (j < Height) { if (ycount % 2 != 0) cr.SetSourceRGB (1, 0, 0); else cr.SetSourceRGB (1, 1, 1); // If we're outside the clip, this will do nothing. cr.Rectangle (i, j, CheckSize, CheckSize); cr.Fill (); j += CheckSize + Spacing; ++ycount; } i += CheckSize + Spacing; ++xcount; } // Select a font to draw with cr.SelectFontFace ("serif", FontSlant.Normal, FontWeight.Bold); cr.SetFontSize (64.0); // Select a color (blue) cr.SetSourceRGB (0, 0, 1); // Draw cr.MoveTo (20, 100); cr.ShowText ("Hello, World"); surface.WriteToPng ("test.png"); } }
private void DrawGrid(Cairo.Context g) { if (daysInMonth < 28 && daysInMonth > 32) { return; } g.SetSourceRGB(0, 0, 0); for (int i = 0; i <= totalColums; i++) { PointD pTop = new PointD(cellWidth * i, 0); PointD pBot = new PointD(cellWidth * i, tableHeight); g.MoveTo(pTop); g.LineTo(pBot); } for (int i = 0; i <= totalRows; i++) { PointD pTop = new PointD(0, cellHeight * i); PointD pBot = new PointD(tableWidth, cellHeight * i); g.MoveTo(pTop); g.LineTo(pBot); } g.ClosePath(); g.Stroke(); }
void ExposeTitle(Cairo.Context c) { // The primary title background c.SetSourceRGBA(0, 0, 0, 0.3); c.Rectangle(0, m_titleOffset, this.Allocation.Width, m_titleHeight); c.Fill(); // The title shadow (lip) c.SetSourceRGBA(0, 0, 0, 0.1); c.Rectangle(0, m_titleOffset + m_titleHeight, this.Allocation.Width, m_titleLip); c.Fill(); // Paint the title text using (var p = Pango.CairoHelper.CreateLayout(c)) { int w = 0, h = 0, pad = 0; p.SetText(m_Title); p.GetPixelSize(out w, out h); pad = (m_titleHeight - h) / 2; c.MoveTo(pad, m_titleOffset + pad); c.SetSourceRGB(1.0, 1.0, 1.0); Pango.CairoHelper.ShowLayout(c, p); } }
/// <summary> /// Dibuja el Grid /// </summary> /// <param name="canvas">Canvas.</param> private void DrawGrid(Cairo.Context canvas) { double maxHeight = Margin.Height; double maxWidth = Margin.Width; double yGap = (maxHeight - Margin.Y) / (NumLineas - 1); double xGap = (maxWidth - Margin.X) / (NumLineas - 1); double x = Margin.X; double y = Margin.Y; canvas.LineWidth = 0.25; canvas.SetSourceRGB(0, 0, 0); // Draw horizontal lines while (y < maxHeight) { canvas.MoveTo(Margin.X, y); canvas.LineTo(maxWidth, y); y += yGap; } // Draw vertical lines while (x < maxWidth + 1) { canvas.MoveTo(x, Margin.Y); canvas.LineTo(x, maxHeight); x += xGap; } canvas.Stroke(); }
void imprime_encabezado(Cairo.Context cr, Pango.Layout layout) { //Gtk.Image image5 = new Gtk.Image(); //image5.Name = "image5"; //image5.Pixbuf = new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "osiris.jpg")); //image5.Pixbuf = new Gdk.Pixbuf("/opt/osiris/bin/OSIRISLogo.jpg"); // en Linux //---image5.Pixbuf.ScaleSimple(128, 128, Gdk.InterpType.Bilinear); //---Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf,1,-30); //---Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(145, 50, Gdk.InterpType.Bilinear),1,1); //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(180, 64, Gdk.InterpType.Hyper),1,1); //cr.Fill(); //cr.Paint(); //cr.Restore(); Pango.FontDescription desc = Pango.FontDescription.FromString("Sans"); //cr.Rotate(90); //Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna fontSize = 8.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; // Letra negrita cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText(classpublic.nombre_empresa); Pango.CairoHelper.ShowLayout(cr, layout); fontSize = 6.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Normal; // Letra normal cr.MoveTo(479 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText("Fech.Rpt:" + (string)DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Pango.CairoHelper.ShowLayout(cr, layout); comienzo_linea += separacion_linea; fontSize = 8.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; // Letra negrita cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText(classpublic.direccion_empresa); Pango.CairoHelper.ShowLayout(cr, layout); fontSize = 6.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Normal; // Letra normal cr.MoveTo(479 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText("N° Page :" + numpage.ToString().Trim()); Pango.CairoHelper.ShowLayout(cr, layout); comienzo_linea += separacion_linea; fontSize = 8.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; // Letra negrita cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText(classpublic.telefonofax_empresa); Pango.CairoHelper.ShowLayout(cr, layout); comienzo_linea += separacion_linea; fontSize = 10.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; // Letra negrita cr.MoveTo(200 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText(departament); Pango.CairoHelper.ShowLayout(cr, layout); layout.FontDescription.Weight = Weight.Normal; // Letra normal fontSize = 6.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; cr.MoveTo(05 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText("Sistema Hospitalario OSIRIS"); Pango.CairoHelper.ShowLayout(cr, layout); // Cambiando el tamaño de la fuente cr.MoveTo(565 * escala_en_linux_windows, 383 * escala_en_linux_windows); cr.LineTo(05, 383); // Linea Horizontal 4 cr.FillExtents(); //. FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.LineWidth = 0.1; cr.Stroke(); }
void imprime_linea_producto(Cairo.Context cr, Pango.Layout layout, string idproducto_, string cantidadaplicada_, string datos_, string preciounitario_, decimal subtotal_, decimal ivaprod_, decimal total_) { fontSize = 7.0; layout = null; layout = context.CreatePangoLayout(); desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; comienzo_linea += separacion_linea; cr.MoveTo(006 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText(idproducto_); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(075 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText(cantidadaplicada_); Pango.CairoHelper.ShowLayout(cr, layout); if (datos_.Length > 61) { cr.MoveTo(110 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText((string)datos_.Substring(0, 60)); Pango.CairoHelper.ShowLayout(cr, layout); } else { cr.MoveTo(110 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText((string)datos_); Pango.CairoHelper.ShowLayout(cr, layout); } if ((bool)rptconprecio == true) { cr.MoveTo(380 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText(preciounitario_); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(430 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText(subtotal_.ToString("N").PadLeft(10)); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(480 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText(ivaprod_.ToString("N").PadLeft(10)); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(530 * escala_en_linux_windows, comienzo_linea * escala_en_linux_windows); layout.SetText(total_.ToString("N").PadLeft(10)); Pango.CairoHelper.ShowLayout(cr, layout); } cr.MoveTo(565 * escala_en_linux_windows, (comienzo_linea - 2) * escala_en_linux_windows); cr.LineTo(05, (comienzo_linea - 2) * escala_en_linux_windows); cr.FillExtents(); //. FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.LineWidth = 0.1; cr.Stroke(); }
protected override bool OnExposeEvent(EventExpose evnt) { using (Cairo.Context ctx = CairoHelper.Create(evnt.Window)) { int dx = (int)((double)Allocation.Width * dividerPosition); ctx.LineWidth = 1; ctx.Rectangle(0, 0, dx, Allocation.Height); ctx.SetSourceColor(LabelBackgroundColor); ctx.Fill(); ctx.Rectangle(dx, 0, Allocation.Width - dx, Allocation.Height); ctx.SetSourceRGB(1, 1, 1); ctx.Fill(); if (PropertyContentRightPadding > 0) { ctx.Rectangle(Allocation.Width - PropertyContentRightPadding, 0, PropertyContentRightPadding, Allocation.Height); ctx.SetSourceColor(LabelBackgroundColor); ctx.Fill(); ctx.MoveTo(Allocation.Width - PropertyContentRightPadding + 0.5, 0); ctx.RelLineTo(0, Allocation.Height); ctx.SetSourceColor(DividerColor); ctx.Stroke(); } ctx.MoveTo(dx + 0.5, 0); ctx.RelLineTo(0, Allocation.Height); ctx.SetSourceColor(DividerColor); ctx.Stroke(); int y = 0; Draw(ctx, rows, dx, PropertyLeftPadding, ref y); } return(base.OnExposeEvent(evnt)); }
public override void Draw(Cairo.Context cr, double xPos, double yPos, PrintLayer layer) { if (_regionSettings != null) { xPos += _regionSettings.Indent; if (layer == PrintLayer.Background && _regionSettings.HasBackground) { TextExtents extents = GetExtents(cr); // If there is a background, draw it here. cr.SetSourceRGB(_regionSettings.Background.Red, _regionSettings.Background.Green, _regionSettings.Background.Blue); cr.Rectangle(xPos , yPos - extents.Height - extents.YAdvance , extents.Width - _regionSettings.Indent , extents.Height + extents.YAdvance); cr.Fill(); } else if (layer == PrintLayer.Text) { xPos += _regionSettings.PaddingLeft; yPos -= _regionSettings.PaddingBottom; } } _children.VerticalDraw(cr, xPos, yPos, layer); }
private static void plotArc(int centerx, int centery, int radius, double start, double end, Cairo.Context g, Cairo.Color color) { //pie chart g.MoveTo(centerx, centery); g.Arc(centerx, centery, radius, start * Math.PI, end * Math.PI); //commented because gets ugly on last radius line (specially if angle is low) //g.ClosePath(); g.SetSourceRGB(color.R, color.G, color.B); g.FillPreserve(); g.SetSourceRGB(0, 0, 0); g.LineWidth = 2; g.Stroke(); }
protected void UpdateTexture () { text.SetSurfaceSize ((uint) (Width+MarginX),(uint) (Height+MarginY)); text.Clear (); Cairo.Context context = text.Create (); double lwidth = 1; double hlwidth = lwidth*0.5; double width = Width - lwidth; double height = Height - lwidth; double radius = Math.Min(marginX, marginY)*0.75; if ((radius > height / 2) || (radius > width / 2)) radius = Math.Min(height / 2, width / 2); context.MoveTo (hlwidth, hlwidth + radius); context.Arc (hlwidth + radius, hlwidth + radius, radius, Math.PI, -Math.PI / 2); context.LineTo (hlwidth + width - radius, hlwidth); context.Arc (hlwidth + width - radius, hlwidth + radius, radius, -Math.PI / 2, 0); context.LineTo (hlwidth + width, hlwidth + height - radius); context.Arc (hlwidth + width - radius, hlwidth + height - radius, radius, 0, Math.PI / 2); context.LineTo (hlwidth + radius, hlwidth + height); context.Arc (hlwidth + radius, hlwidth + height - radius, radius, Math.PI / 2, Math.PI); context.ClosePath (); context.LineWidth = lwidth; context.SetSourceRGB (1.0,1.0,1.0); context.Stroke (); ((IDisposable) context.Target).Dispose (); ((IDisposable) context).Dispose (); }
protected override void CreatePassiveTexture(Clutter.CairoTexture texture, int with_state) { texture.Clear(); Cairo.Context context = texture.Create(); double lwidth = 1; double hlwidth = lwidth * 0.5; //Draw outline rectangles: DrawSmallCovers(context, texture.Width, texture.Height, lwidth); //Draw play icon: context.MoveTo((texture.Width - lwidth) * 0.5, 0.3 * (texture.Height - lwidth)); context.LineTo((texture.Width - lwidth) * 0.5, texture.Height - hlwidth); context.LineTo(texture.Width - hlwidth, 0.65 * (texture.Height - lwidth)); context.ClosePath(); context.LineWidth = lwidth; double sat = (with_state == 0 ? 0.4 : (with_state == 1 ? 0.6 : 0.8)); context.SetSourceRGBA(sat, sat, sat, 1.0); context.FillPreserve(); context.SetSourceRGB(1.0, 1.0, 1.0); context.Stroke(); ((IDisposable)context.Target).Dispose(); ((IDisposable)context).Dispose(); }
/// <summary> /// Draw the robot taking into account the center x and y position of the map which /// will be different from the true center x and y positions on the drawing context. /// This method will result in a red wheeled robot with black tyres being drawn at /// the robots location on the map. /// /// The scale value is currently unused but it could be useful if the map was scaled /// in some way for example a mini-map may be 10 times smaller than the original /// results in 1:10 scale robot. /// </summary> /// <param name="cairoContext">Cairo context to draw to (assuming a map).</param> /// <param name="centerX">Center x position of map to draw onto.</param> /// <param name="centerY">Center y position of map to draw onto.</param> /// <param name="scale">Scale currently unused.</param> public void Draw(Cairo.Context cairoContext, int centerX, int centerY, double scale) { // Scale up to centimeters. int width = (int)(robot.Width * 100); int height = (int)(robot.Height * 100); int x = (int)(robot.X * 100); int y = (int)(robot.Y * 100); // Set a red colour. cairoContext.SetSourceRGB(255, 0, 0); cairoContext.LineWidth = 1.0; cairoContext.LineCap = LineCap.Butt; cairoContext.Translate(centerX + x, centerY - y); cairoContext.Rotate(relativeRotation); // Rotate the robot based on its orientation in radians. // Draw the robot as a triangle. cairoContext.MoveTo(0, -height / 2); cairoContext.LineTo(-width / 2, height / 2); cairoContext.LineTo(width / 2, height / 2); cairoContext.LineTo(0, -height / 2); cairoContext.Stroke(); // Reset the drawing context. cairoContext.Rotate(-relativeRotation); cairoContext.Translate(-(centerX + x), -(centerY - y)); }
void RenderBackground(Cairo.Context context, Gdk.Rectangle region) { region.Inflate(-Padding, -Padding); context.RenderOuterShadow(new Gdk.Rectangle(region.X + 10, region.Y + 15, region.Width - 20, region.Height - 15), Padding, 3, .25); context.RoundedRectangle(region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 5); using (var lg = new LinearGradient(0, region.Y, 0, region.Bottom)) { lg.AddColorStop(0, new Cairo.Color(.36, .53, .73)); lg.AddColorStop(1, new Cairo.Color(.21, .37, .54)); context.SetSource(lg); context.FillPreserve(); } context.Save(); context.Translate(IconPosition.X, IconPosition.Y); context.Scale(0.75, 0.75); Gdk.CairoHelper.SetSourcePixbuf(context, starburst, -starburst.Width / 2, -starburst.Height / 2); context.FillPreserve(); context.Restore(); context.LineWidth = 1; context.SetSourceRGB(.29, .47, .67); context.Stroke(); }
protected override void CreateActiveTexture(Clutter.CairoTexture texture, int with_state) { texture.Clear(); Cairo.Context context = texture.Create(); double lwidth = 1; double hlwidth = lwidth * 0.5; //Draw outline rectangles: DrawSmallCovers(context, texture.Width, texture.Height, lwidth); //Draw stop icon: double dim = Math.Min(texture.Width * 0.6 - hlwidth, texture.Height * 0.6 - hlwidth); context.Rectangle(texture.Width * 0.4, texture.Height * 0.4, dim, dim); context.LineWidth = lwidth; double sat = (with_state == 0 ? 0.4 : (with_state == 1 ? 0.6 : 0.8)); context.SetSourceRGBA(sat, sat, sat, 1.0); context.FillPreserve(); context.SetSourceRGB(1.0, 1.0, 1.0); context.Stroke(); ((IDisposable)context.Target).Dispose(); ((IDisposable)context).Dispose(); }
/// <summary> /// Draw the specified cairoContext, centerX, centerY and scale. /// </summary> /// <param name="cairoContext">Cairo context.</param> /// <param name="centerX">Center x.</param> /// <param name="centerY">Center y.</param> /// <param name="scale">Scale.</param> public void Draw(Cairo.Context cairoContext, int centerX, int centerY, double scale) { cairoContext.SetSourceRGB(0, 0, 200); cairoContext.LineWidth = 1.0; cairoContext.LineCap = LineCap.Butt; //cairoContext.MoveTo (OriginalX, -OriginalY); //int x = centerX; //Console.WriteLine ("point: " + (robot.PathPointList [robot.PathPointList.Count-1] [1]*100)); //if (30 <= (robot.PathPointList [robot.PathPointList.Count - 1] [1] * 100)) //{ //robot.Halt (); //Console.WriteLine ("\n\n Has Gone 30cm \n\n"); //} for (int i = 1; i < robot.PathPointList.Count; i++) { cairoContext.MoveTo(centerX + (robot.PathPointList [i - 1] [0] * 100), centerY - (robot.PathPointList [i - 1] [1] * 100)); cairoContext.LineTo(centerX + (robot.PathPointList [i] [0] * 100), centerY - (robot.PathPointList [i] [1] * 100)); // Console.WriteLine (path[0]*100+" , "+ path[1]*100); cairoContext.Stroke(); } foreach (double[] path in robot.PathPointList) { //cairoContext.MoveTo (centerX - (path[0] * 100), centerY - (path[1] * 100)); } }
void imprime_encabezado(Cairo.Context cr, Pango.Layout layout) { desc = Pango.FontDescription.FromString("Sans"); //cr.Rotate(90); //Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna fontSize = 8.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; // Letra negrita cr.MoveTo(05 * escala_en_linux_windows, 05 * escala_en_linux_windows); layout.SetText(classpublic.nombre_empresa); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(05 * escala_en_linux_windows, 15 * escala_en_linux_windows); layout.SetText(classpublic.direccion_empresa); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(05 * escala_en_linux_windows, 25 * escala_en_linux_windows); layout.SetText(classpublic.telefonofax_empresa); Pango.CairoHelper.ShowLayout(cr, layout); fontSize = 6.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; cr.MoveTo(479 * escala_en_linux_windows, 05 * escala_en_linux_windows); layout.SetText("Fech.Rpt:" + (string)DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(479 * escala_en_linux_windows, 15 * escala_en_linux_windows); layout.SetText("N° Page :"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(05 * escala_en_linux_windows, 35 * escala_en_linux_windows); layout.SetText("Sistema Hospitalario OSIRIS"); Pango.CairoHelper.ShowLayout(cr, layout); // Cambiando el tamaño de la fuente fontSize = 10.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; // Letra negrita cr.MoveTo(225 * escala_en_linux_windows, 35 * escala_en_linux_windows); layout.SetText("REPORTE DE PAGO/ABONOS"); Pango.CairoHelper.ShowLayout(cr, layout); fontSize = 8.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; if (rango1 == "" || rango2 == "") { cr.MoveTo(235 * escala_en_linux_windows, 45 * escala_en_linux_windows); layout.SetText("Todas Las Fechas"); Pango.CairoHelper.ShowLayout(cr, layout); } else { if (rango1 == rango2) { cr.MoveTo(235 * escala_en_linux_windows, 45 * escala_en_linux_windows); layout.SetText("FECHA: " + rango1); Pango.CairoHelper.ShowLayout(cr, layout); } else { cr.MoveTo(235 * escala_en_linux_windows, 45 * escala_en_linux_windows); layout.SetText("Rango del " + rango1 + " al " + rango2); Pango.CairoHelper.ShowLayout(cr, layout); } } fontSize = 7.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Normal; // Letra normal // Creando el Cuadro de Titulos para colocar el nombre del usuario cr.Rectangle(05 * escala_en_linux_windows, 55 * escala_en_linux_windows, 565 * escala_en_linux_windows, 15 * escala_en_linux_windows); cr.FillExtents(); //. FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.LineWidth = 0.5; cr.Stroke(); /* * ContextoImp.MoveTo(26,720); ContextoImp.Show("FOLIO"); * ContextoImp.MoveTo(56,720); ContextoImp.Show("MONTO"); * ContextoImp.MoveTo(93,720); ContextoImp.Show("F. ABONO"); * ContextoImp.MoveTo(134,720); ContextoImp.Show("Nº. REC."); * ContextoImp.MoveTo(171,720); ContextoImp.Show("PID Y NOMBRE DEL PACIENTE"); * ContextoImp.MoveTo(351,720); ContextoImp.Show("CONCEPTO"); * ContextoImp.MoveTo(501,720); ContextoImp.Show("FORMA DE PAGO"); */ }
public void Draw(Cairo.Context cr, Cairo.Rectangle rectangle) { if (IsSeparator) { cr.NewPath(); double x = Math.Ceiling(rectangle.X + rectangle.Width / 2) + 0.5; cr.MoveTo(x, rectangle.Y + 0.5 + 2); cr.RelLineTo(0, rectangle.Height - 1 - 4); cr.ClosePath(); cr.SetSourceColor(parent.Style.Dark(StateType.Normal).ToCairoColor()); cr.LineWidth = 1; cr.Stroke(); return; } if (Active || HoverPosition.X >= 0) { if (Active) { cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); using (var gr = new LinearGradient(rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) { gr.AddColorStop(0, Tabstrip.ActiveGradientStart); gr.AddColorStop(1, Tabstrip.ActiveGradientEnd); cr.SetSource(gr); } cr.Fill(); cr.Rectangle(rectangle.X + 0.5, rectangle.Y + 0.5, rectangle.Width - 1, rectangle.Height - 1); cr.SetSourceRGBA(1, 1, 1, 0.05); cr.LineWidth = 1; cr.Stroke(); } else if (HoverPosition.X >= 0) { cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); using (var gr = new LinearGradient(rectangle.X, rectangle.Y, rectangle.X, rectangle.Y + rectangle.Height)) { var c1 = Tabstrip.ActiveGradientStart; var c2 = Tabstrip.ActiveGradientEnd; c1.A = 0.2; c2.A = 0.2; gr.AddColorStop(0, c1); gr.AddColorStop(1, c2); cr.SetSource(gr); } cr.Fill(); } } if (Active) { cr.SetSourceRGB(1, 1, 1); } else { cr.SetSourceColor(parent.Style.Text(StateType.Normal).ToCairoColor()); } cr.MoveTo(rectangle.X + (rectangle.Width - w) / 2, (rectangle.Height - h) / 2); Pango.CairoHelper.ShowLayout(cr, layout); }
void imprime_encabezado(Cairo.Context cr, Pango.Layout layout) { //image5.Pixbuf = new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "osiris.jpg")); //image5.Pixbuf = new Gdk.Pixbuf("/opt/osiris/bin/OSIRISLogo.jpg"); // en Linux //image5.Pixbuf.ScaleSimple(128, 128, Gdk.InterpType.Bilinear); //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf,1,-30); //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(145, 50, Gdk.InterpType.Bilinear),1,1); //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(180, 64, Gdk.InterpType.Hyper),1,1); //cr.Fill(); //cr.Paint(); //cr.Restore(); Pango.FontDescription desc = Pango.FontDescription.FromString("Sans"); //cr.Rotate(90); //Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna fontSize = 8.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; // Letra negrita cr.MoveTo(05 * escala_en_linux_windows, 05 * escala_en_linux_windows); layout.SetText(classpublic.nombre_empresa); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(05 * escala_en_linux_windows, 15 * escala_en_linux_windows); layout.SetText(classpublic.direccion_empresa); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(05 * escala_en_linux_windows, 25 * escala_en_linux_windows); layout.SetText(classpublic.telefonofax_empresa); Pango.CairoHelper.ShowLayout(cr, layout); fontSize = 6.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; cr.MoveTo(650 * escala_en_linux_windows, 05 * escala_en_linux_windows); layout.SetText("Fech.Rpt:" + (string)DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(650 * escala_en_linux_windows, 15 * escala_en_linux_windows); layout.SetText("N° Page :" + numpage.ToString().Trim()); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(05 * escala_en_linux_windows, 35 * escala_en_linux_windows); layout.SetText("Sistema Hospitalario OSIRIS"); Pango.CairoHelper.ShowLayout(cr, layout); // Cambiando el tamaño de la fuente fontSize = 10.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; cr.MoveTo(240 * escala_en_linux_windows, 25 * escala_en_linux_windows); layout.SetText(titulo); Pango.CairoHelper.ShowLayout(cr, layout); // Creando el Cuadro de Titulos cr.Rectangle(05 * escala_en_linux_windows, 50 * escala_en_linux_windows, 750 * escala_en_linux_windows, 15 * escala_en_linux_windows); cr.FillExtents(); //. FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.LineWidth = 0.5; cr.Stroke(); fontSize = 7.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; // Letra negrita cr.MoveTo(09 * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("ID Producto"); Pango.CairoHelper.ShowLayout(cr, layout); //cr.MoveTo(74*escala_en_linux_windows,53*escala_en_linux_windows); layout.SetText("Ingreso"); Pango.CairoHelper.ShowLayout (cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 1) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("ENE"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 2) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("FEB"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 3) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("MAR"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 4) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("ABR"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 5) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("MAY"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 6) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("JUN"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 7) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("JUL"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 8) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("AGO"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 9) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("SEP"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 10) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("OCT"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 11) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("NUV"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(comienzo_mese + (espacio_mese * 12) * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("DIC"); Pango.CairoHelper.ShowLayout(cr, layout); layout.FontDescription.Weight = Weight.Normal; // Letra Normal }
void imprime_encabezado(Cairo.Context cr, Pango.Layout layout) { //Gtk.Image image5 = new Gtk.Image(); //image5.Name = "image5"; //image5.Pixbuf = new Gdk.Pixbuf(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "osiris.jpg")); //image5.Pixbuf = new Gdk.Pixbuf("/opt/osiris/bin/OSIRISLogo.jpg"); // en Linux //image5.Pixbuf.ScaleSimple(128, 128, Gdk.InterpType.Bilinear); //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf,1,-30); //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(145, 50, Gdk.InterpType.Bilinear),1,1); //Gdk.CairoHelper.SetSourcePixbuf(cr,image5.Pixbuf.ScaleSimple(180, 64, Gdk.InterpType.Hyper),1,1); //cr.Fill(); //cr.Paint(); //cr.Restore(); Pango.FontDescription desc = Pango.FontDescription.FromString("Sans"); //cr.Rotate(90); //Imprimir Orizontalmente rota la hoja cambian las posiciones de las lineas y columna fontSize = 8.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; // Letra negrita cr.MoveTo(05 * escala_en_linux_windows, 05 * escala_en_linux_windows); layout.SetText(classpublic.nombre_empresa); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(05 * escala_en_linux_windows, 15 * escala_en_linux_windows); layout.SetText(classpublic.direccion_empresa); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(05 * escala_en_linux_windows, 25 * escala_en_linux_windows); layout.SetText(classpublic.telefonofax_empresa); Pango.CairoHelper.ShowLayout(cr, layout); fontSize = 6.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; cr.MoveTo(650 * escala_en_linux_windows, 05 * escala_en_linux_windows); layout.SetText("Fech.Rpt:" + (string)DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(650 * escala_en_linux_windows, 15 * escala_en_linux_windows); layout.SetText("N° Page :" + numpage.ToString().Trim()); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(05 * escala_en_linux_windows, 35 * escala_en_linux_windows); layout.SetText("Sistema Hospitalario OSIRIS"); Pango.CairoHelper.ShowLayout(cr, layout); // Cambiando el tamaño de la fuente fontSize = 10.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; cr.MoveTo(240 * escala_en_linux_windows, 25 * escala_en_linux_windows); layout.SetText("REPORTE OCUPACION HOSPITALARIA"); Pango.CairoHelper.ShowLayout(cr, layout); // Creando el Cuadro de Titulos cr.Rectangle(05 * escala_en_linux_windows, 50 * escala_en_linux_windows, 750 * escala_en_linux_windows, 15 * escala_en_linux_windows); cr.FillExtents(); //. FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.LineWidth = 0.5; cr.Stroke(); fontSize = 7.0; desc.Size = (int)(fontSize * pangoScale); layout.FontDescription = desc; layout.FontDescription.Weight = Weight.Bold; // Letra negrita cr.MoveTo(09 * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("Folio."); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(74 * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("Orden"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(114 * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("Codigo"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(300 * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("Descripcion"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(400 * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("CostoUni"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(480 * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("Fecha"); Pango.CairoHelper.ShowLayout(cr, layout); cr.MoveTo(570 * escala_en_linux_windows, 53 * escala_en_linux_windows); layout.SetText("Surtir"); Pango.CairoHelper.ShowLayout(cr, layout); //cr.MoveTo(570*escala_en_linux_windows,53*escala_en_linux_windows); layout.SetText("Autoz"); Pango.CairoHelper.ShowLayout (cr, layout); //cr.MoveTo(570*escala_en_linux_windows,53*escala_en_linux_windows); layout.SetText("%Gana"); Pango.CairoHelper.ShowLayout (cr, layout); //cr.MoveTo(570*escala_en_linux_windows,53*escala_en_linux_windows); layout.SetText("SubAlmacen"); Pango.CairoHelper.ShowLayout (cr, layout); //cr.MoveTo(570*escala_en_linux_windows,53*escala_en_linux_windows); layout.SetText("Compro"); Pango.CairoHelper.ShowLayout (cr, layout); //cr.MoveTo(570*escala_en_linux_windows,53*escala_en_linux_windows); layout.SetText("Medico"); Pango.CairoHelper.ShowLayout (cr, layout); layout.FontDescription.Weight = Weight.Normal; // Letra Normal }
public static void DrawPoints(List<PointD> points,Context cr) { foreach (PointD p in points){ cr.MoveTo(p); cr.SetSourceRGB (0.3, 0.3, 0.3); cr.Arc (p.X, p.Y, 2, 0, 2 * Math.PI); cr.Fill (); } }
public static void Draw(Context grw, Line line) { var color = AppController.Instance.Config.LineColor; grw.SetSourceRGB ( color.Red, color.Green, color.Blue); var segments = AppController.Instance.Surface.Segments; var s1 = segments.FirstOrDefault (s => s.Position.X == line.Input.X && s.Position.Y == line.Input.Y); var s2 = segments.FirstOrDefault (s => s.Position.X == line.Output.X && s.Position.Y == line.Output.Y); if (s1 == null || s2 == null) { return; } //todo : use one func. var start = s1.Connectors .FirstOrDefault (p => p.Marker == line.InputMarker); //todo : use one func. var stop = s2.Connectors .FirstOrDefault (p => p.Marker == line.OutputMarker); if (start == null || stop == null) { return; } grw.MoveTo ( start.Center.GeometryX, start.Center.GeometryY); if (line.Input.X == line.Output.X || line.Input.Y == line.Output.Y) { grw.LineTo ( stop.Center.GeometryX, stop.Center.GeometryY); } else { grw.LineTo ( stop.Center.GeometryX, start.Center.GeometryY); grw.LineTo ( stop.Center.GeometryX, stop.Center.GeometryY); } grw.Stroke(); }
public void draw(Context cr) { Triangle t = model.tri; switch (model.alignment) { case ActiveTriangle.TriangleAlignment.ChaoticEvil: cr.SetSourceRGB (0.5, 0, 0); break; case ActiveTriangle.TriangleAlignment.TrueNeutral: cr.SetSourceRGB (0, 0.8, 0); break; default: cr.SetSourceRGB (1.0, 1.0, 0); break; } cr.LineWidth = 1.1; cr.MoveTo (t.a); cr.LineTo (t.b); cr.MoveTo (t.b); cr.LineTo (t.c); cr.MoveTo (t.c); cr.LineTo (t.a); cr.Stroke (); cr.Fill(); Tuple<PointD,PointD,PointD,PointD> points; points = model.getSharpestPointAndAssociatedMidpointAndDullestPoints (); PointD sharpest = points.Item1; PointD midPoint = points.Item2; cr.SetSourceRGB (1.0, 0.3, 0.3); cr.Arc (sharpest.X, sharpest.Y, 2, 0, 2 * Math.PI); cr.Fill (); cr.Arc (midPoint.X, midPoint.Y, 2, 0, 2 * Math.PI); cr.Fill (); }
void FillChecks (Context cr, int x, int y, int width, int height) { int CHECK_SIZE = 32; cr.Save (); Surface check; using (var target = cr.GetTarget ()) { check = target.CreateSimilar (Content.Color, 2 * CHECK_SIZE, 2 * CHECK_SIZE); } // draw the check using (Context cr2 = new Context (check)) { cr2.Operator = Operator.Source; cr2.SetSourceRGB (0.4, 0.4, 0.4); cr2.Rectangle (0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE); cr2.Fill (); cr2.SetSourceRGB (0.7, 0.7, 0.7); cr2.Rectangle (x, y, CHECK_SIZE, CHECK_SIZE); cr2.Fill (); cr2.Rectangle (x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE); cr2.Fill (); } // Fill the whole surface with the check SurfacePattern check_pattern = new SurfacePattern (check); check_pattern.Extend = Extend.Repeat; cr.SetSource (check_pattern); cr.Rectangle (0, 0, width, height); cr.Fill (); check_pattern.Dispose (); check.Dispose (); cr.Restore (); }
public static void Draw(Context grw, LineElement line) { if (line.Foregraund != null) { grw.SetSourceRGB ( line.Foregraund.Red, line.Foregraund.Green, line.Foregraund.Blue); } grw.MoveTo( line.Start.GeometryX, line.Start.GeometryY); grw.LineTo( line.End.GeometryX, line.End.GeometryY); grw.Stroke(); }
public static void DrawVertexStructure(VertexStructure vs, Context cr) { VertexStructure head = vs; int i = 0; do { cr.MoveTo (vs.v); cr.SetSourceRGB (0, 0, 0.8); cr.Arc (vs.v.X, vs.v.Y, 2, 0, 2 * Math.PI); cr.Fill (); cr.LineWidth = 1; cr.MoveTo (vs.v); cr.LineTo(vs.next.v); cr.Stroke(); vs = vs.next; //Logger.Log("Meh..." + i); i++; } while(!ReferenceEquals(vs,head)); }
public static void Draw (Context grw, ArcElement arc) { if (arc.Foregraund != null) { grw.SetSourceRGB ( arc.Foregraund.Red, arc.Foregraund.Green, arc.Foregraund.Blue); } grw.Arc ( arc.Center.GeometryX, arc.Center.GeometryY, arc.GeometryRadius, arc.ArcStart, arc.ArcStop); grw.Stroke (); }
public CellRendererSurface(int width, int height) { // TODO: Respect cell padding (Xpad and Ypad). SetFixedSize (width, height); transparent = new Cairo.ImageSurface (Cairo.Format.ARGB32, width, height); Cairo.Color gray = new Cairo.Color (.75, .75, .75); // Create checkerboard background int grid_width = 4; using (Cairo.Context g = new Cairo.Context (transparent)) { g.SetSourceRGB (1, 1, 1); g.Paint (); for (int y = 0; y < height; y += grid_width) for (int x = 0; x < width; x += grid_width) if ((x / grid_width % 2) + (y / grid_width % 2) == 1) g.FillRectangle (new Cairo.Rectangle (x, y, grid_width, grid_width), gray); } }
public static void Draw(Context grw, Connector con) { var c = con.Selected ? AppController.Instance.Config.SelectedConnectorColor : !con.ConnectedTo.Any() ? con.Foregraund : AppController.Instance.Config.ConnectedColor; if ( c != null) { grw.SetSourceRGB ( c.Red, c.Green, c.Blue); } grw.Arc ( con.Center.GeometryX, con.Center.GeometryY, con.GeometryRadius, 0, 2 * Math.PI); grw.StrokePreserve (); grw.Fill (); }
private void DrawGrid(Context g) { g.SetSourceRGB (0.05, 0.05, 0.05); g.SetDash (new double[] {4, 4}, 2); g.LineWidth = 1; for (int i = 1; i < 4; i++) { g.MoveTo (i * size / 4, 0); g.LineTo (i * size / 4, size); g.MoveTo (0, i * size / 4); g.LineTo (size, i * size / 4); } g.MoveTo (0, size - 1); g.LineTo (size - 1, 0); g.Stroke (); g.SetDash (new double[] {}, 0); }
public static void GenerateGraph (List <ResultDbEntry> resultList, string filename) { // FIXME Exception if more than 50 results... ImageSurface surface = new ImageSurface (Format.Rgb24, 103, 52); Context context = new Context (surface); // Fill with grad LinearGradient grad = new LinearGradient (0.0, 0.0, 0.0, 52.0); grad.AddColorStopRgb (0.0, new Color (1.0, 1.0, 1.0)); grad.AddColorStopRgb (1.0, new Color (0.8, 0.8, 0.9)); context.Pattern = grad; context.Paint (); // Frame context.SetSourceRGB (0, 0, 0); context.LineWidth = 1.0; context.Rectangle (0.5, 0.5, 102.0, 51.0); context.Stroke (); long denominator = (long) (FindBiggestResult (resultList) * 1.2); context.LineWidth = 1.5; // FIXME Reverse to copy resultList.Reverse (); double x = 100.5 - ((resultList.Count - 1) * 2.0); bool hasPrevResult = false; long prevResult = 0; foreach (ResultDbEntry entry in resultList) { if (entry.Failure) { x += 2.0; continue; } double sz = ((double) entry.Time / denominator) * 50.0; if (hasPrevResult && UtilFu.GetValueDifference (prevResult, entry.Time) > 0.1) context.SetSourceRGB (1.0, 0.0, 0.0); else if (hasPrevResult && UtilFu.GetValueDifference (prevResult, entry.Time) < -0.1) context.SetSourceRGB (0.0, 1.0, 0.0); else context.SetSourceRGB (0.4, 0.4, 0.4); context.MoveTo (x, 51); context.LineTo (x, 51 - sz); context.Stroke (); x += 2.0; hasPrevResult = true; prevResult = entry.Time; } surface.WriteToPng (filename); resultList.Reverse (); ((IDisposable) context).Dispose (); ((IDisposable) surface).Dispose (); }
void OnExpose(object sender, ExposeEventArgs args) { area = (DrawingArea) sender; cr = Gdk.CairoHelper.Create(area.GdkWindow); cr.LineWidth = 2; cr.SetSourceRGB(0.7, 0.2, 0.0); cr.Translate(width/2, height/2); cr.Rectangle(pX , pY, width, height); //cr.Arc(pX, pY, (width < height ? width : height) / 2 - 10, 0, 2*Math.PI); cr.StrokePreserve(); cr.SetSourceRGB(0.3, 0.4, 0.6); cr.Fill(); pX=pY=4; //drawInterfaceEth(); drawInterfaceUps(); ((IDisposable) cr.Target).Dispose(); ((IDisposable) cr).Dispose(); }
public override void DrawBackground(MonoTextEditor editor, Context cr, LineMetrics metrics, int startOffset, int endOffset) { int x1 = editor.LocationToPoint(editor.OffsetToLocation(this.Offset), false).X; int x2 = editor.LocationToPoint(editor.OffsetToLocation(this.Offset + this.Length), false).X; cr.Rectangle(x1, metrics.LineYRenderStartPosition + 0.5, x2 - x1, metrics.LineHeight - 1); cr.SetSourceRGB(1.0, 1.0, 0.0); cr.Fill(); }
protected void Draw(Context cr) { double x, y; double radius; int i; int hours, minutes, seconds; x = Allocation.Width / 2; y = Allocation.Height / 2; radius = Math.Min(Allocation.Width / 2, Allocation.Height / 2) - 5; /* clock back */ cr.Arc(x, y, radius, 0, 2 * Math.PI); cr.SetSourceRGB(1, 1, 1); cr.FillPreserve(); cr.SetSourceRGB(0, 0, 0); cr.Stroke(); /* clock ticks */ for (i = 0; i < 12; i++) { double inset; cr.Save(); /* stack-pen-size */ if (i % 3 == 0) { inset = 0.2 * radius; } else { inset = 0.1 * radius; cr.LineWidth *= 0.5; } cr.MoveTo( x + (radius - inset) * Math.Cos (i * Math.PI / 6), y + (radius - inset) * Math.Sin (i * Math.PI / 6)); cr.LineTo( x + radius * Math.Cos (i * Math.PI / 6), y + radius * Math.Sin (i * Math.PI / 6)); cr.Stroke(); cr.Restore(); /* stack-pen-size */ } /* clock hands */ hours = DateTime.Now.Hour; minutes = DateTime.Now.Minute; seconds = DateTime.Now.Second; /* hour hand: * the hour hand is rotated 30 degrees (pi/6 r) per hour + * 1/2 a degree (pi/360 r) per minute */ cr.Save(); cr.LineWidth *= 2.5; cr.MoveTo(x, y); cr.LineTo(x + radius / 2 * Math.Sin (Math.PI / 6 * hours + Math.PI / 360 * minutes), y + radius / 2 * -Math.Cos (Math.PI / 6 * hours + Math.PI / 360 * minutes)); cr.Stroke(); cr.Restore(); /* minute hand: * the minute hand is rotated 6 degrees (pi/30 r) per minute */ cr.MoveTo(x, y); cr.LineTo(x + radius * 0.75 * Math.Sin (Math.PI / 30 * minutes), y + radius * 0.75 * -Math.Cos (Math.PI / 30 * minutes)); cr.Stroke(); /* seconds hand: * operates identically to the minute hand */ cr.Save(); cr.SetSourceRGB(1, 0, 0); /* red */ cr.MoveTo(x, y); cr.LineTo(x + radius * 0.7 * Math.Sin (Math.PI / 30 * seconds), y + radius * 0.7 * -Math.Cos (Math.PI / 30 * seconds)); cr.Stroke(); cr.Restore(); }
public void DrawSingle(Complex[] points) { N = points.Length; using (Context context = new Context(Surface)) { double min = double.PositiveInfinity, max = double.NegativeInfinity, val; for (int i = 0; i < points.Length; i++) { val = _valueExtractor (points [i]) * 1.2; if(val < min) { min = val; } if(val > max) { max = val; } } DrawAxes (context, min, max); context.SetSourceRGB (0.0, 0.0, 1.0); for (int i = 0; i < points.Length; i++) { DrawPoint (context, i, _valueExtractor(points [i])); } } DrawExpose (null, null); }
public static void Draw (Context grw, TextElement text) { double dY = 0; if (text.Foregraund != null) { grw.SetSourceRGB ( text.Foregraund.Red, text.Foregraund.Green, text.Foregraund.Blue); } grw.SelectFontFace ( text.FontFamily, FontSlant.Normal, (FontWeight)text.Weight); grw.SetFontSize (text.ScaledFontSize); var te = grw.TextExtents (text.Text); double dX = 0; if (text.Align != null) { switch (text.Align.ToLowerInvariant()) { case AlignType.Center: dX = 0.5 * te.Width; break; case AlignType.Right: dX = te.Width; break; case AlignType.Left: dX = 0; break; default: return; } } if (text.VAlign != null) { switch (text.VAlign.ToLowerInvariant ()) { case VAlignType.Top: dY = te.YBearing; break; case VAlignType.Center: dY = 0.5 * te.YBearing; break; case VAlignType.Bottom: dY = 0; break; default: return; } } grw.MoveTo ( text.Start.GeometryX - dX, text.Start.GeometryY - dY); grw.ShowText (text.FormattedText); grw.Stroke (); }
private void DrawAxes(Context context, double min, double max) { context.Rectangle(0, 0, Width, Height); context.SetSourceRGB(Background.R, Background.G, Background.B); context.Fill(); int y = ValueToY (0); context.LineWidth = 1; context.SetSourceRGB(0.0, 0.0, 0.0); context.MoveTo (44, y); context.LineTo (Width, y); context.StrokePreserve(); context.MoveTo (50, 0); context.LineTo (50, Height); context.StrokePreserve(); KeyValuePair<double, string>[] ax = _axis.AxisSteps (min, max); foreach (var a in ax) { y = ValueToY (a.Key); context.MoveTo (44, y); context.LineTo (56, y); context.StrokePreserve(); context.MoveTo (40, y - 1); _axis.Text (context, a.Value, HorizontalTextAlignment.Right); } }
private void DrawHistArea(Context context, double xl, double yl, int i, int j, double value) { Color c = HistColor (value); context.SetSourceRGB (c.R, c.G, c.B); context.MoveTo ((int)(j * xl + 50), (int)(i * yl)); context.LineTo ((int)((j + 1) * xl + 50), (int)(i * yl)); context.LineTo ((int)((j + 1) * xl + 50), (int)((i + 1) * yl)); context.LineTo ((int)(j * xl + 50), (int)((i + 1) * yl)); context.LineTo ((int)(j * xl + 50), (int)(i * yl)); context.StrokePreserve (); context.MoveTo ((int)((j + .5) * xl + 50), (int)((i + .5) * yl)); context.Fill (); }
public static void Draw(Context grw, Arc3PointsElement arc) { const double eps = 0.000001; double arcStart; double arcEnd; if (arc.Foregraund != null) { grw.SetSourceRGB( arc.Foregraund.Red, arc.Foregraund.Green, arc.Foregraund.Blue); } var arcCenter = new PointD(0, 0); var yDeltaA = arc.Middle.GeometryY - arc.Start.GeometryY; var xDeltaA = arc.Middle.GeometryX - arc.Start.GeometryX; var yDeltaB = arc.End.GeometryY - arc.Middle.GeometryY; var xDeltaB = arc.End.GeometryX - arc.Middle.GeometryX; //common case - no perpendicular & collinear lines if ((Math.Abs(xDeltaA) > eps) && (Math.Abs(xDeltaB) > eps) && (Math.Abs(yDeltaA) > eps) && (Math.Abs(yDeltaB) > eps)) { var aSlope = yDeltaA / xDeltaA; var bSlope = yDeltaB / xDeltaB; if (Math.Abs(aSlope - bSlope) <= eps) { //throw new ArgumentException("3 points lie at one line"); return; } arcCenter.X = (aSlope * bSlope * (arc.Start.GeometryY - arc.End.GeometryY) + bSlope * (arc.Start.GeometryX + arc.Middle.GeometryX) - aSlope * (arc.Middle.GeometryX + arc.End.GeometryX)) / (2 * (bSlope - aSlope)); arcCenter.Y = -1 * (arcCenter.X - (arc.Start.GeometryX + arc.Middle.GeometryX) / 2) / aSlope + (arc.Start.GeometryY + arc.Middle.GeometryY) / 2; } else { //vertical or horizontal cases if (Math.Abs(xDeltaA) <= eps) { //1st is vertical if (Math.Abs(xDeltaB) <= eps) { //2nd is vertical too //throw new ArgumentException("Both lines are vertical"); return; } if (Math.Abs(yDeltaB) > eps) { // 2nd is not horizontal //throw new NotImplementedException("Only first vertical"); return; } //square angle arcCenter.X = 0.5 * (arc.Middle.GeometryX + arc.End.GeometryX); arcCenter.Y = 0.5 * (arc.Start.GeometryY + arc.Middle.GeometryY); } if (Math.Abs(yDeltaA) <= eps) { //1st is horizontal if (Math.Abs(yDeltaB) <= eps) { //2nd is horizontal too //throw new ArgumentException("Both line are horizontal"); return; } if (Math.Abs(xDeltaB) > eps) { //1st is not horizontal //throw new NotImplementedException("Only first horizontal"); return; } //square angle arcCenter.X = 0.5 * (arc.Start.GeometryX + arc.Middle.GeometryX); arcCenter.Y = 0.5 * (arc.Middle.GeometryY + arc.End.GeometryY); } } //radius var arcRadius = Math.Sqrt(Math.Pow(arc.Start.GeometryX - arcCenter.X, 2) + Math.Pow(arc.Start.GeometryY - arcCenter.Y, 2)); //arc angles var xStartDelta = arc.Start.GeometryX - arcCenter.X; var yStartDelta = arc.Start.GeometryY - arcCenter.Y; var xEndDelta = arc.End.GeometryX - arcCenter.X; var yEndDelta = arc.End.GeometryY - arcCenter.Y; //start of arc if (Math.Abs(xStartDelta) < eps) { if (yStartDelta < 0.0) { arcStart = -0.5 * Math.PI; } else { arcStart = 0.5 * Math.PI; } } else { arcStart = Math.Atan2(yStartDelta, xStartDelta); } //end of arc if (Math.Abs(xEndDelta) < eps) { if (yEndDelta < 0.0) { arcEnd = -0.5 * Math.PI; } else { arcEnd = 0.5 * Math.PI; } } else { arcEnd = Math.Atan2(yEndDelta, xEndDelta); } if (Math.Sign((arc.Middle.GeometryX - arc.Start.GeometryX) * (arc.Middle.GeometryY - arc.End.GeometryY) - (arc.Middle.GeometryY - arc.Start.GeometryY) * (arc.Middle.GeometryX - arc.End.GeometryX)) < 0) { grw.Arc( arcCenter.X, arcCenter.Y, arcRadius, arcStart, arcEnd); } else { grw.ArcNegative( arcCenter.X, arcCenter.Y, arcRadius, arcStart, arcEnd); } grw.Stroke(); }
public void DrawCube(Context cr, int CubePxSize, bool Coloring) { logger.Debug("Начали рисовать куб {0}", Name); int PxWidth = CubesH * CubePxSize; int PxHeight = CubesV * CubePxSize; //Фон if(Coloring) { cr.Rectangle(0, 0, PxWidth, PxHeight); //cr.SetSourceRGB(1, 0.9, 0.6); cr.SetSourceRGB(0.77254902, 0.631372549, 0.435294118); cr.Fill(); } //Куб double vratio = (double) PxHeight / SvgImage.Dimensions.Height; double hratio = (double) PxWidth / SvgImage.Dimensions.Width; double ratio = Math.Min(vratio, hratio); cr.Scale(ratio, ratio); SvgImage.RenderCairo(cr); logger.Debug("Закончили рисовать куб."); }
private void clearDrawArea(Context cr) { cr.Rectangle (new Rectangle(new Point(0,0),width,height)); cr.SetSourceRGB (0.8, 0.8, 0.3); cr.Fill (); }
private ImageSurface GenerateStub() { ImageSurface stub = new ImageSurface (Format.ARGB32, 600, 300); Context cairo = new Context(stub); cairo.IdentityMatrix (); cairo.Scale (600,300); cairo.Rectangle (0, 0, 1, 1); cairo.SetSourceRGB (1,1,1); cairo.Fill (); cairo.MoveTo (0.14, 0.5); cairo.SetFontSize (0.08); cairo.SetSourceRGB (0, 0, 0); cairo.ShowText ("Загрузите подложку"); cairo.Dispose (); return stub; }
void DrawGrid(Context cr, int CubePxSize) { cr.SetSourceRGB(0.321568627, 0.235294118, 0.235294118); cr.SetDash(new double[]{2.0, 3.0}, 0.0); for (int x = 0; x <= CubesH; x++) { cr.MoveTo(x * CubePxSize, 0); cr.LineTo(x * CubePxSize, CubePxSize * CubesV); } for (int y = 0; y <= CubesV; y++) { cr.MoveTo(0, y * CubePxSize); cr.LineTo(CubesH * CubePxSize, CubePxSize * y); } cr.Stroke(); }
public void draw(Context cr) { PointD p = model.position; cr.Save(); cr.Translate (p.X-image.Width/2, p.Y-image.Height/2); cr.SetSource(image); cr.Paint(); cr.Restore(); cr.MoveTo(p); cr.SetSourceRGB (0.3, 1.0, 0.3); cr.Arc (p.X, p.Y, 5, 0, 2 * Math.PI); cr.Fill (); }
protected void removeDotsFromScreen() { //Redraw all of the grid if (clear) { using (Context ctx = new Context (surface)) { //Set Background Color ctx.SetSourceRGB (0, 0, 0); ctx.Rectangle (0, 0, 500, 500); ctx.Fill (); //Draw Axis Lines for (int i = 0; i < (int)(divisions); i++) { float curX = Math.Abs (param_Min_x) + Math.Abs (param_Max_x); float divCount = (500) / divisions; divCount *= i; curX = divCount; //If Middle Color Green if (i == ((int)divisions / 2)) { R = 0; G = 1; B = 0; } else { R = 0.5F; G = 0.5F; B = 0.5F; } //Draw Vertical Lines DrawLine (ctx, new PointD ((int)(curX), 0), new PointD ((int)(curX), 500)); //Draw Horizontal Lines DrawLine (ctx, new PointD (0, (int)(curX)), new PointD (500, (int)(curX))); } } clear = false; dArea.QueueDraw (); } }
private void DrawAxes(Context context, double min, double max) { context.Rectangle(0, 0, Width, Height); context.Color = Background; context.Fill(); context.LineWidth = 1; context.SetSourceRGB(0.0, 0.0, 0.0); context.MoveTo (0, Height / 2); context.LineTo (Width, Height / 2); context.StrokePreserve(); context.MoveTo (Width / 2, 0); context.LineTo (Width / 2, Height); context.StrokePreserve(); KeyValuePair<double, string>[] ax = _axis.AxisSteps (min, max); double y; foreach (var a in ax) { y = a.Key / _axis.YLimUp * Height / 2 + Height / 2; context.MoveTo (Width / 2 - 6, y); context.LineTo (Width / 2 + 6, y); context.StrokePreserve(); context.MoveTo (y, Height / 2 - 6); context.LineTo (y, Height / 2 + 6); context.StrokePreserve(); if (a.Key != 0) { context.MoveTo (Width / 2 - 10, Height - (y - 1)); _axis.Text (context, a.Value, HorizontalTextAlignment.Right); context.MoveTo (y - 1, Height / 2 + 10); _axis.Text (context, a.Value, HorizontalTextAlignment.Center, VerticalTextAlignment.Top); } else { //context.MoveTo (Width / 2 + 5, Height / 2 + 5); //_axis.Text (context, a.Value, HorizontalTextAlignment.Left, VerticalTextAlignment.Top); } } }
public Document NewDocument(Gdk.Size imageSize, bool transparent) { Document doc = CreateAndActivateDocument (null, imageSize); doc.Workspace.CanvasSize = imageSize; // Start with an empty white layer Layer background = doc.AddNewLayer (Catalog.GetString ("Background")); if (!transparent) { using (Cairo.Context g = new Cairo.Context (background.Surface)) { g.SetSourceRGB (1, 1, 1); g.Paint (); } } doc.Workspace.History.PushNewItem (new BaseHistoryItem (Stock.New, Catalog.GetString ("New Image"))); doc.IsDirty = false; PintaCore.Actions.View.ZoomToWindow.Activate (); return doc; }
protected override bool OnDrawn (Context cr) { int w, h; this.GdkWindow.GetSize (out w, out h); var bounds = new Xwt.Rectangle (0.5, 0.5, w - 1, h - 1); var black = Xwt.Drawing.Color.FromBytes (0xee, 0xee, 0xee); // We clear the surface with a transparent color if possible if (supportAlpha) cr.SetSourceRGBA (1.0, 1.0, 1.0, 0.0); else cr.SetSourceRGB (1.0, 1.0, 1.0); cr.Operator = Operator.Source; cr.Paint (); var calibratedRect = RecalibrateChildRectangle (bounds); // Fill it with one round rectangle RoundRectangle (cr, calibratedRect, radius); cr.LineWidth = 1; // Triangle // We first begin by positionning ourselves at the top-center or bottom center of the previous rectangle var arrowX = bounds.Center.X + arrowDelta; var arrowY = arrowPosition == Xwt.Popover.Position.Top ? calibratedRect.Top + cr.LineWidth : calibratedRect.Bottom; cr.MoveTo (arrowX, arrowY); // We draw the rectangle path DrawTriangle (cr); // We use it cr.SetSourceRGBA (black.Red, black.Green, black.Blue, black.Alpha); cr.StrokePreserve (); cr.SetSourceRGBA (BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A); cr.Fill (); return base.OnDrawn (cr); }
void Draw (Context cr, int width, int height) { double radius = 0.5 * Math.Min (width, height) - 10; int xc = width / 2; int yc = height / 2; Surface overlay, punch, circles; using (var target = cr.GetTarget ()) { overlay = target.CreateSimilar (Content.ColorAlpha, width, height); punch = target.CreateSimilar (Content.Alpha, width, height); circles = target.CreateSimilar (Content.ColorAlpha, width, height); } FillChecks (cr, 0, 0, width, height); cr.Save (); // Draw a black circle on the overlay using (Context cr_overlay = new Context (overlay)) { cr_overlay.SetSourceRGB (0.0, 0.0, 0.0); OvalPath (cr_overlay, xc, yc, radius, radius); cr_overlay.Fill (); // Draw 3 circles to the punch surface, then cut // that out of the main circle in the overlay using (Context cr_tmp = new Context (punch)) Draw3Circles (cr_tmp, xc, yc, radius, 1.0); cr_overlay.Operator = Operator.DestOut; cr_overlay.SetSourceSurface (punch, 0, 0); cr_overlay.Paint (); // Now draw the 3 circles in a subgroup again // at half intensity, and use OperatorAdd to join up // without seams. using (Context cr_circles = new Context (circles)) { cr_circles.Operator = Operator.Over; Draw3Circles (cr_circles, xc, yc, radius, 0.5); } cr_overlay.Operator = Operator.Add; cr_overlay.SetSourceSurface (circles, 0, 0); cr_overlay.Paint (); } cr.SetSourceSurface (overlay, 0, 0); cr.Paint (); overlay.Dispose (); punch.Dispose (); circles.Dispose (); }