raster

package
v0.0.0-...-eb57d45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2012 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Copyright 2011 The draw2d Authors. All rights reserved. created: 27/05/2011 by Laurent Le Goff

Copyright 2011 The draw2d Authors. All rights reserved. created: 27/05/2011 by Laurent Le Goff

Copyright 2011 The draw2d Authors. All rights reserved. created: 27/05/2011 by Laurent Le Goff

Copyright 2011 The draw2d Authors. All rights reserved. created: 27/05/2011 by Laurent Le Goff

Index

Constants

View Source
const (
	SUBPIXEL_SHIFT = 3
	SUBPIXEL_COUNT = 1 << SUBPIXEL_SHIFT
)
View Source
const (
	FIXED_SHIFT      = 16
	FIXED_FLOAT_COEF = 1 << FIXED_SHIFT
)
View Source
const (
	SLOPE_FIX_SHIFT = 8
	SLOPE_FIX_STEP  = 1 << SLOPE_FIX_SHIFT
	SLOPE_FIX_MASK  = SLOPE_FIX_STEP - 1
)

! Fixed point math inevitably introduces rounding error to the DDA. The error is

  • fixed every now and then by a separate fix value. The defines below set these.
View Source
const (
	POLYGON_CLIP_NONE = iota
	POLYGON_CLIP_LEFT
	POLYGON_CLIP_RIGHT
	POLYGON_CLIP_TOP
	POLYGON_CLIP_BOTTOM
)

Variables

View Source
var SUBPIXEL_OFFSETS_SAMPLE_16 = [16]float64{
	1.0 / 16,
	8.0 / 16,
	4.0 / 16,
	15.0 / 16,
	11.0 / 16,
	2.0 / 16,
	6.0 / 16,
	14.0 / 16,
	10.0 / 16,
	3.0 / 16,
	7.0 / 16,
	12.0 / 16,
	0.0 / 16,
	9.0 / 16,
	5.0 / 16,
	13.0 / 16,
}
View Source
var SUBPIXEL_OFFSETS_SAMPLE_32 = [32]float64{
	28.0 / 32,
	13.0 / 32,
	6.0 / 32,
	23.0 / 32,
	0.0 / 32,
	17.0 / 32,
	10.0 / 32,
	27.0 / 32,
	4.0 / 32,
	21.0 / 32,
	14.0 / 32,
	31.0 / 32,
	8.0 / 32,
	25.0 / 32,
	18.0 / 32,
	3.0 / 32,
	12.0 / 32,
	29.0 / 32,
	22.0 / 32,
	7.0 / 32,
	16.0 / 32,
	1.0 / 32,
	26.0 / 32,
	11.0 / 32,
	20.0 / 32,
	5.0 / 32,
	30.0 / 32,
	15.0 / 32,
	24.0 / 32,
	9.0 / 32,
	2.0 / 32,
	19.0 / 32,
}
View Source
var SUBPIXEL_OFFSETS_SAMPLE_32_FIXED = [32]Fix{
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[0] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[1] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[2] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[3] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[4] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[5] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[6] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[7] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[8] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[9] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[10] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[11] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[12] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[13] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[14] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[15] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[16] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[17] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[18] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[19] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[20] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[21] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[22] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[23] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[24] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[25] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[26] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[27] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[28] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[29] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[30] * FIXED_FLOAT_COEF),
	Fix(SUBPIXEL_OFFSETS_SAMPLE_32[31] * FIXED_FLOAT_COEF),
}
View Source
var SUBPIXEL_OFFSETS_SAMPLE_8 = [8]float64{
	5.0 / 8,
	0.0 / 8,
	3.0 / 8,
	6.0 / 8,
	1.0 / 8,
	4.0 / 8,
	7.0 / 8,
	2.0 / 8,
}

Functions

func Bresenham

func Bresenham(img draw.Image, color color.Color, x0, y0, x1, y1 int)

func PolylineBresenham

func PolylineBresenham(img draw.Image, c color.Color, s ...float64)

Types

type Fix

type Fix int32

type NON_ZERO_MASK_DATA_UNIT

type NON_ZERO_MASK_DATA_UNIT uint8

type Polygon

type Polygon []float64

type PolygonEdge

type PolygonEdge struct {
	X, Slope            float64
	FirstLine, LastLine int
	Winding             int16
}

type PolygonScanEdge

type PolygonScanEdge struct {
	FirstLine, LastLine int
	Winding             int16
	X                   Fix
	Slope               Fix
	SlopeFix            Fix
	NextEdge            *PolygonScanEdge
}

! A more optimized representation of a polygon edge.

type Rasterizer8BitsSample

type Rasterizer8BitsSample struct {
	MaskBuffer    []SUBPIXEL_DATA
	WindingBuffer []NON_ZERO_MASK_DATA_UNIT

	Width           int
	BufferWidth     int
	Height          int
	ClipBound       [4]float64
	RemappingMatrix [6]float64
}

func NewRasterizer8BitsSample

func NewRasterizer8BitsSample(width, height int) *Rasterizer8BitsSample
width and height define the maximum output size for the filler.

* The filler will output to larger bitmaps as well, but the output will * be cropped.

func (*Rasterizer8BitsSample) RenderEvenOdd

func (r *Rasterizer8BitsSample) RenderEvenOdd(img *image.RGBA, color *color.RGBA, polygon *Polygon, tr [6]float64)

func (*Rasterizer8BitsSample) RenderNonZeroWinding

func (r *Rasterizer8BitsSample) RenderNonZeroWinding(img *image.RGBA, color *color.RGBA, polygon *Polygon, tr [6]float64)

* Renders the polygon with non-zero winding fill. * param aTarget the target bitmap. * param aPolygon the polygon to render. * param aColor the color to be used for rendering. * param aTransformation the transformation matrix.

type SUBPIXEL_DATA

type SUBPIXEL_DATA uint8

type VertexData

type VertexData struct {
	X, Y      float64
	ClipFlags int
	Line      int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL