PeachDrawing

PeachDrawing

RasterRenderContext Class

A RenderContext for drawing directly onto a RasterCanvas canvas with no HTML, CSS, layout, or PDF document involved. CreateCanvas(int, int, double) is the entry point:

using var ctx = new RasterRenderContext();
using var canvas = ctx.CreateCanvas(width: 800, height: 600);
canvas.DrawRectangle(ctx.GetSolidBrush(PaintColor.FromArgb(255, 30, 144, 255)), 50, 50, 200, 100);
canvas.Save(stream, "png", new PngEncoderOptions());
public sealed class RasterRenderContext : PeachDrawing.Core.RenderContext

Inheritance System.Object → RenderContext → RasterRenderContext

Remarks

Font creation goes through TypefaceFont and image decoding through DecodedImage - both PeachDrawing.Core/PeachDrawing’s own types, no PDF backend involved anywhere in the chain.

Constructors  
RasterRenderContext() Creates a render context with every font installed on the machine already registered by name.
Methods  
AddFont(Stream, string) Registers a font directly under fontFamilyName, bypassing CSS @font-face entirely.
CreateCanvas(int, int, double) Creates a standalone RasterCanvas canvas of exactly widthPx by heightPx device pixels. This canvas’s own coordinate convention is plain: one user-space unit is one device pixel, regardless of dpi - a Rect(0, 0, 100, 50) and a font size of 24 both mean exactly that many pixels. dpi is accepted for forward compatibility (a future encoder that tags physical resolution on save) but does not otherwise affect drawing today.
GetCssMediaType(IEnumerable<string>) The CSS media type (e.g. "print", "screen") this render context evaluates media queries against, chosen from mediaTypesAvailable.