glenda.party
term% ls -F
term% cat index.txt
BITBLT(2)                     System Calls Manual                    BITBLT(2)



NAME
       bitblt, bitbltclip, clipline, point, segment, polysegment, arc, circle,
       disc, ellipse, texture, border,  string,  strsize,  strwidth,  Fcode  -
       graphics functions

SYNOPSIS
       #include <u.h>
       #include <libg.h>

       void  bitblt(Bitmap *db, Point dp, Bitmap *sb,
                 Rectangle sr, Fcode f)

       int   bitbltclip(void *)

       int   clipline(Rectangle r, Point *p0, Point *p1)

       void  point(Bitmap *b, Point p, int v, Fcode f)

       void  segment(Bitmap *b, Point p, Point q, int v, Fcode f)

       void  polysegment(Bitmap *b, int n, Point *pp, int v, Fcode f)

       void  circle(Bitmap *b, Point p, int r, int v, Fcode f)

       void  disc(Bitmap *b, Point p, int r, int v, Fcode)

       void  arc(Bitmap *b, Point p0, Point p1, Point p2, int v, Fcode f)

       void  ellipse(Bitmap *b, Point p, int a, int b, int v, Fcode f)

       void  texture(Bitmap *b, Rectangle r, Bitmap *t, Fcode f)

       void  border(Bitmap *b, Rectangle r, int w, Fcode f)

       Point string(Bitmap *b, Point p, Font *ft, char *s, Fcode f)

       Point strsize(Font *ft, char *s)

       long  strwidth(Font *ft, char *s)

       enum Fcode {
               Zero,     DnorS,    DandnotS, notS,
               notDandS, notD,     DxorS,    DnandS,
               DandS,    DxnorS,   D,        DornotS,
               S,        notDorS,  DorS,     F,
       } Fcode;

DESCRIPTION
       Bitblt  (bit-block transfer) takes bits from rectangle sr in the source
       Bitmap sb and overlays them on a congruent rectangle with the min  cor‐
       ner at point dp in the destination bitmap, db.  The f parameter defines
       each destination pixel as a function of the source and destination pix‐
       els.   The  sixteen codes in Fcode give all possible boolean operations
       on the source S and destination D.  The code values may be expressed as
       boolean  operations  on  the values S and D.  For example, D|S computes
       the result as the logical or of the destination pixel's old  value  and
       the  overlaying  source pixel's value.  If pixels are more than one bit
       deep, the operations are still bitwise.  The Zero and F codes result in
       new pixel values that are all zeros or all ones, respectively.

       If the source and destination bitmaps have different depths, the source
       rectangle is first converted to have the same depth as the destination,
       as  follows: conversion to a smaller number of bits per pixel is accom‐
       plished by taking the desired number of high order bits; conversion  to
       a  larger number of bits per pixel is accomplished by putting the small
       value into the high order bits, and replicating it  as  many  times  as
       necessary to fill the lower order bits.

       All  of  the  drawing graphics functions clip the rectangle against the
       source and destination bitmaps' clip rectangles, so  that  only  pixels
       within  the  destination  bitmap  are changed and none are changed that
       would have come from areas outside the source bitmap.  Bitbltclip takes
       a  pointer to the first argument of a bitblt argument list and clips dp
       and sr so the resulting bitblt is confined to the source  and  destina‐
       tion  bitmaps.  It returns one if the x and y dimensions of the result‐
       ing bitblt are positive; zero otherwise.

       Point changes the value of the destination point p in bitmap b  accord‐
       ing  to function code f.  The source is a pixel with value v.  The con‐
       stant ~0 represents the maximum pixel value.

       Segment, circle, disc, and ellipse all draw in bitmap b  with  function
       code  f and a source pixel with value v.  Arc draws a circular arc cen‐
       tered on p0, traveling clockwise from p1 to p2 or a point on the circle
       near  p2.   Segment draws a line segment in bitmap b from point p to q.
       The segment is half-open: p is the first point of the segment and q  is
       the  first  point beyond the segment, so adjacent segments sharing end‐
       points abut.  Polysegment draws the n-1 segments joining the  n  points
       in  the  array  pointed to by pp.  Clipline clips the line segment from
       *p0 to *p1 (p0 is closed, p1 is open) to rectangle r, adjusting p0  and
       p1  so  that the segment is within the rectangle and *p1 is closed.  It
       returns 0 if none of the segment is in the rectangle, 1 otherwise.

       Circle draws a circle with radius r and center at point p.  Disc is the
       same  except  that  it fills the circle.  Ellipse draws an ellipse with
       horizontal semi-axis a and vertical semi-axis b.

       Border draws, with function f in bitmap b, the rectangular outline with
       lines of width w fitting just inside rectangle r.

       Texture  draws, with function f in bitmap b, a texture using the bitmap
       specified by t.  The texture bitmap is aligned on b's coordinate system
       so that (0,0) in both coordinate systems coincide, and then t is repli‐
       cated to form a tiling of b.  The tiling is clipped to rectangle  r  in
       b, and then transferred to b using the specified function.

       String  draws  the  text  characters  given  by the null-terminated UTF
       string s into bitmap b, using font ft.  The upper left  corner  of  the
       first  character  (i.e., a point that is ft->ascent above the baseline)
       is placed at point p, and subsequent characters are placed on the  same
       baseline,  displaced  to  the  right by the previous character's width.
       The individual characters are bitblt'ed  into  the  destination,  using
       drawing function f.  String returns the point after the final character
       of s; this can be outside b if the string was clipped.

       If a character in the string would have zero width,  either  explicitly
       or  because  no  image is present for the character in the font, string
       replaces it with the image of the character with value zero (tradition‐
       ally  a  `Peter  face').  If that character has zero width, string will
       get a fatal error.

       The bounding box for text to be drawn with string in  font  ft  can  be
       found  with  strsize; it returns the max point of the bounding box, as‐
       suming a min point of (0,0).  Strwidth returns the x-component  of  the
       max point.

SOURCE
       /sys/src/libg

SEE ALSO
       graphics(2), utf(6), add(2)

DIAGNOSTICS
       These routines call the graphics error function on fatal errors.



                                                                     BITBLT(2)