NetSurf
Functions | Variables
plot.c File Reference
#include <stdio.h>
#include "utils/utils.h"
#include "utils/errors.h"
#include "netsurf/plotters.h"
#include "monkey/output.h"
Include dependency graph for plot.c:

Go to the source code of this file.

Functions

static nserror monkey_plot_clip (const struct redraw_context *ctx, const struct rect *clip)
 Sets a clip rectangle for subsequent plot operations. More...
 
static nserror monkey_plot_arc (const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2)
 Plots an arc. More...
 
static nserror monkey_plot_disc (const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
 Plots a circle. More...
 
static nserror monkey_plot_line (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
 Plots a line. More...
 
static nserror monkey_plot_rectangle (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
 Plots a rectangle. More...
 
static nserror monkey_plot_polygon (const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
 Plot a polygon. More...
 
static nserror monkey_plot_path (const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
 Plots a path. More...
 
static nserror monkey_plot_bitmap (const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
 Plot a bitmap. More...
 
static nserror monkey_plot_text (const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
 Text plotting. More...
 

Variables

static const struct plotter_table plotters
 monkey plotter operations table More...
 
const struct plotter_tablemonkey_plotters = &plotters
 

Function Documentation

◆ monkey_plot_arc()

static nserror monkey_plot_arc ( const struct redraw_context ctx,
const plot_style_t style,
int  x,
int  y,
int  radius,
int  angle1,
int  angle2 
)
static

Plots an arc.

plot an arc segment around (x,y), anticlockwise from angle1 to angle2. Angles are measured anticlockwise from horizontal, in degrees.

Parameters
ctxThe current redraw context.
styleStyle controlling the arc plot.
xThe x coordinate of the arc.
yThe y coordinate of the arc.
radiusThe radius of the arc.
angle1The start angle of the arc.
angle2The finish angle of the arc.
Returns
NSERROR_OK on success else error code.

Definition at line 61 of file plot.c.

References MOUT_PLOT, moutf(), and NSERROR_OK.

Here is the call graph for this function:

◆ monkey_plot_bitmap()

static nserror monkey_plot_bitmap ( const struct redraw_context ctx,
struct bitmap bitmap,
int  x,
int  y,
int  width,
int  height,
colour  bg,
bitmap_flags_t  flags 
)
static

Plot a bitmap.

Tiled plot of a bitmap image. (x,y) gives the top left coordinate of an explicitly placed tile. From this tile the image can repeat in all four directions – up, down, left and right – to the extents given by the current clip rectangle.

The bitmap_flags say whether to tile in the x and y directions. If not tiling in x or y directions, the single image is plotted. The width and height give the dimensions the image is to be scaled to.

Parameters
ctxThe current redraw context.
bitmapThe bitmap to plot
xThe x coordinate to plot the bitmap
yThe y coordiante to plot the bitmap
widthThe width of area to plot the bitmap into
heightThe height of area to plot the bitmap into
bgthe background colour to alpha blend into
flagsthe flags controlling the type of plot operation
Returns
NSERROR_OK on success else error code.

Definition at line 215 of file plot.c.

References height, MOUT_PLOT, moutf(), NSERROR_OK, and width.

Here is the call graph for this function:

◆ monkey_plot_clip()

static nserror monkey_plot_clip ( const struct redraw_context ctx,
const struct rect clip 
)
static

Sets a clip rectangle for subsequent plot operations.

Parameters
ctxThe current redraw context.
clipThe rectangle to limit all subsequent plot operations within.
Returns
NSERROR_OK on success else error code.

Definition at line 36 of file plot.c.

References clip(), MOUT_PLOT, moutf(), and NSERROR_OK.

Here is the call graph for this function:

◆ monkey_plot_disc()

static nserror monkey_plot_disc ( const struct redraw_context ctx,
const plot_style_t style,
int  x,
int  y,
int  radius 
)
static

Plots a circle.

Plot a circle centered on (x,y), which is optionally filled.

Parameters
ctxThe current redraw context.
styleStyle controlling the circle plot.
xx coordinate of circle centre.
yy coordinate of circle centre.
radiuscircle radius.
Returns
NSERROR_OK on success else error code.

Definition at line 84 of file plot.c.

References MOUT_PLOT, moutf(), and NSERROR_OK.

Here is the call graph for this function:

◆ monkey_plot_line()

static nserror monkey_plot_line ( const struct redraw_context ctx,
const plot_style_t style,
const struct rect line 
)
static

Plots a line.

plot a line from (x0,y0) to (x1,y1). Coordinates are at centre of line width/thickness.

Parameters
ctxThe current redraw context.
styleStyle controlling the line plot.
lineA rectangle defining the line to be drawn
Returns
NSERROR_OK on success else error code.

Definition at line 105 of file plot.c.

References line(), MOUT_PLOT, moutf(), and NSERROR_OK.

Here is the call graph for this function:

◆ monkey_plot_path()

static nserror monkey_plot_path ( const struct redraw_context ctx,
const plot_style_t pstyle,
const float *  p,
unsigned int  n,
const float  transform[6] 
)
static

Plots a path.

Path plot consisting of cubic Bezier curves. Line and fill colour is controlled by the plot style.

Parameters
ctxThe current redraw context.
pstyleStyle controlling the path plot.
pelements of path
nnunber of elements on path
transformA transform to apply to the path.
Returns
NSERROR_OK on success else error code.

Definition at line 178 of file plot.c.

References MOUT_PLOT, moutf(), NSERROR_OK, plot_style_fixed_to_float, and plot_style_s::stroke_width.

Here is the call graph for this function:

◆ monkey_plot_polygon()

static nserror monkey_plot_polygon ( const struct redraw_context ctx,
const plot_style_t style,
const int *  p,
unsigned int  n 
)
static

Plot a polygon.

Plots a filled polygon with straight lines between points. The lines around the edge of the ploygon are not plotted. The polygon is filled with the non-zero winding rule.

Parameters
ctxThe current redraw context.
styleStyle controlling the polygon plot.
pverticies of polygon
nnumber of verticies.
Returns
NSERROR_OK on success else error code.

Definition at line 154 of file plot.c.

References MOUT_PLOT, moutf(), and NSERROR_OK.

Here is the call graph for this function:

◆ monkey_plot_rectangle()

static nserror monkey_plot_rectangle ( const struct redraw_context ctx,
const plot_style_t style,
const struct rect rect 
)
static

Plots a rectangle.

The rectangle can be filled an outline or both controlled by the plot style The line can be solid, dotted or dashed. Top left corner at (x0,y0) and rectangle has given width and height.

Parameters
ctxThe current redraw context.
styleStyle controlling the rectangle plot.
rectA rectangle defining the line to be drawn
Returns
NSERROR_OK on success else error code.

Definition at line 129 of file plot.c.

References MOUT_PLOT, moutf(), NSERROR_OK, rect::x0, rect::x1, rect::y0, and rect::y1.

Here is the call graph for this function:

◆ monkey_plot_text()

static nserror monkey_plot_text ( const struct redraw_context ctx,
const struct plot_font_style fstyle,
int  x,
int  y,
const char *  text,
size_t  length 
)
static

Text plotting.

Parameters
ctxThe current redraw context.
fstyleplot style for this text
xx coordinate
yy coordinate
textUTF-8 string to plot
lengthlength of string, in bytes
Returns
NSERROR_OK on success else error code.

Definition at line 241 of file plot.c.

References MOUT_PLOT, moutf(), NSERROR_OK, and text().

Here is the call graph for this function:

Variable Documentation

◆ monkey_plotters

const struct plotter_table* monkey_plotters = &plotters

Definition at line 267 of file plot.c.

Referenced by monkey_window_handle_redraw().

◆ plotters

const struct plotter_table plotters
static
Initial value:
= {
.rectangle = monkey_plot_rectangle,
.polygon = monkey_plot_polygon,
.bitmap = monkey_plot_bitmap,
.option_knockout = true,
}
static nserror monkey_plot_disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
Plots a circle.
Definition: plot.c:84
static nserror monkey_plot_polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
Plot a polygon.
Definition: plot.c:154
static nserror monkey_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:36
static nserror monkey_plot_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
Definition: plot.c:105
static nserror monkey_plot_bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
Definition: plot.c:215
static nserror monkey_plot_path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: plot.c:178
static nserror monkey_plot_arc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2)
Plots an arc.
Definition: plot.c:61
static nserror monkey_plot_text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plot.c:241
static nserror monkey_plot_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
Plots a rectangle.
Definition: plot.c:129

monkey plotter operations table

Definition at line 254 of file plot.c.