-
Notifications
You must be signed in to change notification settings - Fork 70
/
raster.go
62 lines (47 loc) · 1.57 KB
/
raster.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2023, Cogent Core. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Based on https://github.com/srwiley/rasterx:
// Copyright 2018 by the rasterx Authors. All rights reserved.
// Created 2018 by S.R.Wiley
package raster
//go:generate core generate
import (
"image"
"golang.org/x/image/math/fixed"
)
// Raster is the interface for rasterizer types. It extends the [Adder]
// interface to include LineF and JoinF functions.
type Raster interface {
Adder
LineF(b fixed.Point26_6)
JoinF()
}
// Adder is the interface for types that can accumulate path commands
type Adder interface {
// Start starts a new curve at the given point.
Start(a fixed.Point26_6)
// Line adds a line segment to the path
Line(b fixed.Point26_6)
// QuadBezier adds a quadratic bezier curve to the path
QuadBezier(b, c fixed.Point26_6)
// CubeBezier adds a cubic bezier curve to the path
CubeBezier(b, c, d fixed.Point26_6)
// Closes the path to the start point if closeLoop is true
Stop(closeLoop bool)
}
// Scanner is the interface for path generating types
type Scanner interface {
Start(a fixed.Point26_6)
Line(b fixed.Point26_6)
Draw()
GetPathExtent() fixed.Rectangle26_6
SetBounds(w, h int)
// SetColor sets the color used for rendering.
SetColor(color image.Image)
SetWinding(useNonZeroWinding bool)
Clear()
// SetClip sets an optional clipping rectangle to restrict rendering only to
// that region. If rect is zero (image.Rectangle{}), then clipping is disabled.
SetClip(rect image.Rectangle)
}