1/* 2 3LinePathBuilder 4 5Copyright (c) 2002 OpenBeOS. 6 7Author: 8 Michael Pfeiffer 9 10Permission is hereby granted, free of charge, to any person obtaining a copy of 11this software and associated documentation files (the "Software"), to deal in 12the Software without restriction, including without limitation the rights to 13use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 14of the Software, and to permit persons to whom the Software is furnished to do 15so, subject to the following conditions: 16 17The above copyright notice and this permission notice shall be included in all 18copies or substantial portions of the Software. 19 20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26THE SOFTWARE. 27 28*/ 29 30#ifndef LINE_PATH_BUILDER_H 31#define LINE_PATH_BUILDER_H 32 33#include "SubPath.h" 34#include <InterfaceDefs.h> 35 36class LinePathBuilder 37{ 38 SubPath *fSubPath; 39 float fPenSize; 40 cap_mode fCapMode; 41 join_mode fJoinMode; 42 float fMiterLimit; 43 bool fFirst; 44 45 float PenSize() const { return fPenSize; } 46 cap_mode LineCapMode() const { return fCapMode; } 47 join_mode LineJoinMode() const { return fJoinMode; } 48 float LineMiterLimit() const { return fMiterLimit; } 49 50 bool Vector(BPoint a, BPoint b, float w, BPoint &v); 51 bool Parallel(BPoint a, BPoint b, float w, BPoint &pa, BPoint &pb); 52 bool Cut(BPoint a, BPoint b, BPoint c, BPoint d, BPoint &e); 53 bool Inside(BPoint a, BPoint b, BPoint r); 54 bool InMiterLimit(BPoint a, BPoint b); 55 56 void RoundCap(BPoint a, BPoint b, BPoint ra, BPoint rb, bool start); 57 void RoundJoin(BPoint p[4]); 58 void AddPoint(BPoint p); 59 void Corner(BPoint a, BPoint b, bool start); 60 void Connect(BPoint a, BPoint b, BPoint c); 61 62 bool IdenticalPoints(int i, int j); 63 void OptimizeSubPath(); 64 65 BPoint PointAt(int i); 66 67 68protected: 69 virtual void MoveTo(BPoint p) = 0; 70 virtual void LineTo(BPoint p) = 0; 71 virtual void BezierTo(BPoint p[3]) = 0; 72 virtual void ClosePath(void) = 0; 73 74public: 75 LinePathBuilder(SubPath *subPath, float penSize, cap_mode capMode, join_mode joinMode, float miterLimit); 76 virtual ~LinePathBuilder() { } 77 78 virtual void CreateLinePath(); 79}; 80 81#endif 82