blob: a6a9f083311d7b73b7128ee9ffbc7a18d8fad762 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2006 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00003 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00004 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00006 */
7
reed@android.com8a1c16f2008-12-17 15:59:43 +00008#ifndef SkStroke_DEFINED
9#define SkStroke_DEFINED
10
reed@google.com04fdaa12012-11-21 15:48:20 +000011#include "SkPath.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000012#include "SkPoint.h"
13#include "SkPaint.h"
14
reed@android.com8a1c16f2008-12-17 15:59:43 +000015/** \class SkStroke
16 SkStroke is the utility class that constructs paths by stroking
17 geometries (lines, rects, ovals, roundrects, paths). This is
18 invoked when a geometry or text is drawn in a canvas with the
19 kStroke_Mask bit set in the paint.
20*/
21class SkStroke {
22public:
23 SkStroke();
24 SkStroke(const SkPaint&);
25 SkStroke(const SkPaint&, SkScalar width); // width overrides paint.getStrokeWidth()
26
27 SkPaint::Cap getCap() const { return (SkPaint::Cap)fCap; }
28 void setCap(SkPaint::Cap);
29
30 SkPaint::Join getJoin() const { return (SkPaint::Join)fJoin; }
31 void setJoin(SkPaint::Join);
32
33 void setMiterLimit(SkScalar);
34 void setWidth(SkScalar);
35
36 bool getDoFill() const { return SkToBool(fDoFill); }
37 void setDoFill(bool doFill) { fDoFill = SkToU8(doFill); }
38
reed@google.com04fdaa12012-11-21 15:48:20 +000039 /**
40 * Stroke the specified rect, winding it in the specified direction..
41 */
42 void strokeRect(const SkRect& rect, SkPath* result,
43 SkPath::Direction = SkPath::kCW_Direction) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +000044 void strokePath(const SkPath& path, SkPath*) const;
45
46 ////////////////////////////////////////////////////////////////
47
48private:
49 SkScalar fWidth, fMiterLimit;
50 uint8_t fCap, fJoin;
51 SkBool8 fDoFill;
52
53 friend class SkPaint;
54};
55
56#endif