github.com/unidoc/unidoc@v2.2.0+incompatible/pdf/creator/filled_curve_test.go (about) 1 /* 2 * This file is subject to the terms and conditions defined in 3 * file 'LICENSE.md', which is part of this source code package. 4 */ 5 6 package creator 7 8 import ( 9 "testing" 10 11 "github.com/unidoc/unidoc/pdf/contentstream/draw" 12 ) 13 14 func CreateFillCurve(x0, y0, x1, y1, x2, y2, x3, y3 float64) draw.CubicBezierCurve { 15 return draw.NewCubicBezierCurve(x0, y0, x1, y1, x2, y2, x3, y3) 16 } 17 18 func TestNewFilledCurve(t *testing.T) { 19 filledCurve := NewFilledCurve() 20 filledCurve.FillEnabled = true 21 filledCurve.BorderEnabled = true 22 filledCurve.BorderWidth = 2 23 filledCurve.SetFillColor(ColorGreen) 24 filledCurve.SetBorderColor(ColorBlue) 25 26 // Up Left 27 filledCurve.AppendCurve(CreateFillCurve(300, 300, 230, 350, 200, 280, 220, 220)) 28 // Down Left 29 filledCurve.AppendCurve(CreateFillCurve(225, 240, 240, 180, 260, 160, 300, 180)) 30 // Down Right 31 filledCurve.AppendCurve(CreateFillCurve(305, 170, 335, 165, 350, 185, 365, 220)) 32 // Up Right 33 filledCurve.AppendCurve(CreateFillCurve(365, 240, 385, 315, 350, 325, 300, 300)) 34 // Leaf 35 filledCurve.AppendCurve(CreateFillCurve(300, 300, 290, 350, 295, 370, 300, 390)) 36 37 creator := New() 38 creator.NewPage() 39 creator.Draw(filledCurve) 40 41 err := creator.WriteToFile("/tmp/filledCurve.pdf") 42 if err != nil { 43 t.Errorf("Fail: %v", err) 44 return 45 } 46 }