DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T g

⟦f3927d664⟧ TextFile

    Length: 2924 (0xb6c)
    Types: TextFile
    Names: »gxfixed.h«

Derivation

└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
    └─⟦ff23ba0e6⟧ »./ghostscript-1.3.tar.Z« 
        └─⟦a24a58cd3⟧ 
            └─⟦this⟧ »gxfixed.h« 

TextFile

/* Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
   Distributed by Free Software Foundation, Inc.

This file is part of Ghostscript.

Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing.  Refer
to the Ghostscript General Public License for full details.

Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License.  A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities.  It should be in a file named COPYING.  Among other
things, the copyright notice and this notice must be preserved on all
copies.  */

/* gxfixed.h */
/* Fixed-point arithmetic for GhostScript */

/* Coordinates are generally represented internally by fixed-point */
/* quantities: integers don't lend themselves to dithering, */
/* and floating point arithmetic is slow. */
typedef long fixed;
/* 12 bits of fraction provides both for accurate dithering and for */
/* a sufficiently large range of coordinates. */
#define _fixed_shift 12
#define _fixed_scale (1<<_fixed_shift)

/* Most operations can be done directly on fixed-point quantities: */
/* addition, subtraction, shifting, multiplication or division by */
/* (integer) constants; assignment, assignment with zero; */
/* comparison, comparison against zero. */
/* Multiplication and division by floats is OK if the result is */
/* explicitly cast back to fixed. */
/* Conversion to and from int and float types must be done explicitly. */
/* Note that if we are casting a fixed to a float in a context where */
/* only ratios and not actual values are involved, we don't need to take */
/* the scale factor into account: we can simply cast to float directly. */
#define int2fixed(i) ((fixed)(i)<<_fixed_shift)
#define fixed2int(x) ((int)((x)>>_fixed_shift))
#define fixed2int_rounded(x) ((int)(((x)+(1<<(_fixed_shift-1)))>>_fixed_shift))
#define fixed2int_ceiling(x) ((int)(((x)+((1<<_fixed_shift)-1))>>_fixed_shift))
#define fixed2long(x) ((long)((x)>>_fixed_shift))
#define fixed2long_rounded(x) ((long)(((x)+(1<<(_fixed_shift-1)))>>_fixed_shift))
#define fixed2long_ceiling(x) ((long)(((x)+((1<<_fixed_shift)-1))>>_fixed_shift))
#define float2fixed(f) ((fixed)((f)*(float)_fixed_scale))
#define fixed2float(x) ((float)((x)*(1.0/_fixed_scale)))

/* Rounding on fixeds */
#define fixed_rounded(x) (((x)+(1<<(_fixed_shift-1)))&(-1L<<_fixed_shift))

/* A point with fixed coordinates */
typedef struct gs_fixed_point_s {
	fixed x, y;
} gs_fixed_point;

/* A rectangle with fixed coordinates */
typedef struct gs_fixed_rect_s {
	fixed xmin, ymin, xmax, ymax;
} gs_fixed_rect;