9fans.net/go@v0.0.5/draw/ellipse.go (about) 1 package draw 2 3 func doellipse(cmd byte, dst *Image, c Point, xr, yr, thick int, src *Image, sp Point, alpha uint32, phi int, op Op) { 4 setdrawop(dst.Display, op) 5 a := dst.Display.bufimage(1 + 4 + 4 + 2*4 + 4 + 4 + 4 + 2*4 + 2*4) 6 a[0] = cmd 7 bplong(a[1:], dst.id) 8 bplong(a[5:], src.id) 9 bplong(a[9:], uint32(c.X)) 10 bplong(a[13:], uint32(c.Y)) 11 bplong(a[17:], uint32(xr)) 12 bplong(a[21:], uint32(yr)) 13 bplong(a[25:], uint32(thick)) 14 bplong(a[29:], uint32(sp.X)) 15 bplong(a[33:], uint32(sp.Y)) 16 bplong(a[37:], alpha) 17 bplong(a[41:], uint32(phi)) 18 } 19 20 // Ellipse draws in dst an ellipse centered on c with horizontal and vertical 21 // semiaxes a and b. The source is aligned so sp in src corresponds to c in dst. 22 // The ellipse is drawn with thickness 1+2*thick. 23 func (dst *Image) Ellipse(c Point, a, b, thick int, src *Image, sp Point) { 24 dst.Display.mu.Lock() 25 defer dst.Display.mu.Unlock() 26 doellipse('e', dst, c, a, b, thick, src, sp, 0, 0, SoverD) 27 } 28 29 // EllipseOp is like Ellipse but specifies an explicit Porter-Duff operator. 30 func (dst *Image) EllipseOp(c Point, a, b, thick int, src *Image, sp Point, op Op) { 31 dst.Display.mu.Lock() 32 defer dst.Display.mu.Unlock() 33 doellipse('e', dst, c, a, b, thick, src, sp, 0, 0, op) 34 } 35 36 // FillEllipse is like Ellipse but fills the ellipse rather than outlining it. 37 func (dst *Image) FillEllipse(c Point, a, b int, src *Image, sp Point) { 38 dst.Display.mu.Lock() 39 defer dst.Display.mu.Unlock() 40 doellipse('E', dst, c, a, b, 0, src, sp, 0, 0, SoverD) 41 } 42 43 // FillEllipseOp is like FillEllipse but specifies an explicit Porter-Duff operator. 44 func (dst *Image) FillEllipseOp(c Point, a, b int, src *Image, sp Point, op Op) { 45 dst.Display.mu.Lock() 46 defer dst.Display.mu.Unlock() 47 doellipse('E', dst, c, a, b, 0, src, sp, 0, 0, op) 48 } 49 50 // Arc is like Ellipse but draws only that portion of the ellipse starting at angle alpha 51 // and extending through an angle of phi. The angles are measured in degrees 52 // counterclockwise from the positive x axis. 53 func (dst *Image) Arc(c Point, a, b, thick int, src *Image, sp Point, alpha, phi int) { 54 dst.Display.mu.Lock() 55 defer dst.Display.mu.Unlock() 56 doellipse('e', dst, c, a, b, thick, src, sp, uint32(alpha)|1<<31, phi, SoverD) 57 } 58 59 // ArcOp is like Arc but specifies an explicit Porter-Duff operator. 60 func (dst *Image) ArcOp(c Point, a, b, thick int, src *Image, sp Point, alpha, phi int, op Op) { 61 dst.Display.mu.Lock() 62 defer dst.Display.mu.Unlock() 63 doellipse('e', dst, c, a, b, thick, src, sp, uint32(alpha)|1<<31, phi, op) 64 } 65 66 // FillArc is like Arc but fills the sector with the source color. 67 func (dst *Image) FillArc(c Point, a, b int, src *Image, sp Point, alpha, phi int) { 68 dst.Display.mu.Lock() 69 defer dst.Display.mu.Unlock() 70 doellipse('E', dst, c, a, b, 0, src, sp, uint32(alpha)|1<<31, phi, SoverD) 71 } 72 73 // FillArcOp is like FillArc but specifies an explicit Porter-Duff operator. 74 func (dst *Image) FillArcOp(c Point, a, b int, src *Image, sp Point, alpha, phi int, op Op) { 75 dst.Display.mu.Lock() 76 defer dst.Display.mu.Unlock() 77 doellipse('E', dst, c, a, b, 0, src, sp, uint32(alpha)|1<<31, phi, op) 78 }