Remove Drawer interface and unecessary draw2dkit
This commit is contained in:
parent
93c5712ecc
commit
b07a8ba2e0
3 changed files with 1 additions and 147 deletions
18
draw2d.go
18
draw2d.go
|
@ -84,10 +84,7 @@
|
|||
// - https://github.com/vdobler/chart: basic charts in Go
|
||||
package draw2d
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
)
|
||||
import "image/color"
|
||||
|
||||
// FillRule defines the type for fill rules
|
||||
type FillRule int
|
||||
|
@ -150,10 +147,6 @@ type StrokeStyle struct {
|
|||
Dash []float64
|
||||
}
|
||||
|
||||
// FillStyle is an empty interface you may want to use SolidFillStyle
|
||||
type FillStyle interface {
|
||||
}
|
||||
|
||||
// SolidFillStyle define style attributes for a solid fill style
|
||||
type SolidFillStyle struct {
|
||||
// Color defines the line color
|
||||
|
@ -233,12 +226,3 @@ type ImageScaling struct {
|
|||
// ScalingPolicy defines the scaling policy to applied to the image
|
||||
ScalingPolicy ScalingPolicy
|
||||
}
|
||||
|
||||
// Drawer can fill and stroke a path
|
||||
type Drawer interface {
|
||||
Matrix() *Matrix
|
||||
Fill(path *Path, style FillStyle)
|
||||
Stroke(path *Path, style StrokeStyle)
|
||||
Text(text string, x, y float64, style TextStyle)
|
||||
Image(image image.Image, x, y float64, scaling ImageScaling)
|
||||
}
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
package draw2dkit
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/llgcode/draw2d"
|
||||
)
|
||||
|
||||
// Droid draws a droid at specified position
|
||||
func Droid(drawer draw2d.Drawer, x, y float64, fillStyle draw2d.FillStyle, strokeStyle draw2d.StrokeStyle) {
|
||||
strokeStyle.LineCap = draw2d.RoundCap
|
||||
strokeStyle.Width = 5
|
||||
|
||||
path := &draw2d.Path{}
|
||||
|
||||
// head
|
||||
path.ArcTo(x+80, y+70, 50, 50, 180*(math.Pi/180), 360*(math.Pi/180))
|
||||
drawer.Fill(path, fillStyle)
|
||||
drawer.Stroke(path, strokeStyle)
|
||||
|
||||
path.Clear()
|
||||
path.MoveTo(x+60, y+25)
|
||||
path.LineTo(x+50, y+10)
|
||||
path.MoveTo(x+100, y+25)
|
||||
path.LineTo(x+110, y+10)
|
||||
drawer.Stroke(path, strokeStyle)
|
||||
|
||||
// left eye
|
||||
path.Clear()
|
||||
Circle(path, x+60, y+45, 5)
|
||||
drawer.Fill(path, fillStyle)
|
||||
drawer.Stroke(path, strokeStyle)
|
||||
|
||||
// right eye
|
||||
path.Clear()
|
||||
Circle(path, x+100, y+45, 5)
|
||||
drawer.Fill(path, fillStyle)
|
||||
drawer.Stroke(path, strokeStyle)
|
||||
|
||||
// body
|
||||
path.Clear()
|
||||
RoundedRectangle(path, x+30, y+75, x+30+100, y+75+90, 10, 10)
|
||||
drawer.Fill(path, fillStyle)
|
||||
drawer.Stroke(path, strokeStyle)
|
||||
|
||||
path.Clear()
|
||||
Rectangle(path, x+30, y+75, x+30+100, y+75+80)
|
||||
drawer.Fill(path, fillStyle)
|
||||
drawer.Stroke(path, strokeStyle)
|
||||
|
||||
// left arm
|
||||
path.Clear()
|
||||
RoundedRectangle(path, x+5, y+80, x+5+20, y+80+70, 10, 10)
|
||||
drawer.Fill(path, fillStyle)
|
||||
drawer.Stroke(path, strokeStyle)
|
||||
|
||||
// right arm
|
||||
path.Clear()
|
||||
RoundedRectangle(path, x+135, y+80, x+135+20, y+80+70, 10, 10)
|
||||
drawer.Fill(path, fillStyle)
|
||||
drawer.Stroke(path, strokeStyle)
|
||||
|
||||
// left leg
|
||||
path.Clear()
|
||||
RoundedRectangle(path, x+50, y+150, x+50+20, y+150+50, 10, 10)
|
||||
drawer.Fill(path, fillStyle)
|
||||
drawer.Stroke(path, strokeStyle)
|
||||
|
||||
// right leg
|
||||
path.Clear()
|
||||
RoundedRectangle(path, x+90, y+150, x+90+20, y+150+50, 10, 10)
|
||||
drawer.Fill(path, fillStyle)
|
||||
drawer.Stroke(path, strokeStyle)
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
// Copyright 2010 The draw2d Authors. All rights reserved.
|
||||
// created: 21/11/2010 by Laurent Le Goff
|
||||
|
||||
package draw2dkit
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"github.com/llgcode/draw2d"
|
||||
)
|
||||
|
||||
// Gopher draw a gopher using a GraphicContext thanks to https://github.com/golang-samples/gopher-vector/
|
||||
func Gopher(gc draw2d.GraphicContext, x, y, w, h float64) {
|
||||
// Initialize Stroke Attribute
|
||||
gc.SetLineWidth(3)
|
||||
gc.SetLineCap(draw2d.RoundCap)
|
||||
gc.SetStrokeColor(color.Black)
|
||||
|
||||
// Left hand
|
||||
// <path fill-rule="evenodd" clip-rule="evenodd" fill="#F6D2A2" stroke="#000000" stroke-width="3" stroke-linecap="round" d="
|
||||
// M10.634,300.493c0.764,15.751,16.499,8.463,23.626,3.539c6.765-4.675,8.743-0.789,9.337-10.015
|
||||
// c0.389-6.064,1.088-12.128,0.744-18.216c-10.23-0.927-21.357,1.509-29.744,7.602C10.277,286.542,2.177,296.561,10.634,300.493"/>
|
||||
gc.SetFillColor(color.RGBA{0xF6, 0xD2, 0xA2, 0xff})
|
||||
gc.MoveTo(10.634, 300.493)
|
||||
rCubicCurveTo(gc, 0.764, 15.751, 16.499, 8.463, 23.626, 3.539)
|
||||
rCubicCurveTo(gc, 6.765, -4.675, 8.743, -0.789, 9.337, -10.015)
|
||||
rCubicCurveTo(gc, 0.389, -6.064, 1.088, -12.128, 0.744, -18.216)
|
||||
rCubicCurveTo(gc, -10.23, -0.927, -21.357, 1.509, -29.744, 7.602)
|
||||
gc.CubicCurveTo(10.277, 286.542, 2.177, 296.561, 10.634, 300.493)
|
||||
gc.FillStroke()
|
||||
|
||||
// <path fill-rule="evenodd" clip-rule="evenodd" fill="#C6B198" stroke="#000000" stroke-width="3" stroke-linecap="round" d="
|
||||
// M10.634,300.493c2.29-0.852,4.717-1.457,6.271-3.528"/>
|
||||
gc.MoveTo(10.634, 300.493)
|
||||
rCubicCurveTo(gc, 2.29, -0.852, 4.717, -1.457, 6.271, -3.528)
|
||||
gc.Stroke()
|
||||
|
||||
// Left Ear
|
||||
// <path fill-rule="evenodd" clip-rule="evenodd" fill="#6AD7E5" stroke="#000000" stroke-width="3" stroke-linecap="round" d="
|
||||
// M46.997,112.853C-13.3,95.897,31.536,19.189,79.956,50.74L46.997,112.853z"/>
|
||||
gc.MoveTo(46.997, 112.853)
|
||||
gc.CubicCurveTo(-13.3, 95.897, 31.536, 19.189, 79.956, 50.74)
|
||||
gc.LineTo(46.997, 112.853)
|
||||
gc.Close()
|
||||
gc.Stroke()
|
||||
}
|
||||
|
||||
func rQuadCurveTo(path draw2d.PathBuilder, dcx, dcy, dx, dy float64) {
|
||||
x, y := path.LastPoint()
|
||||
path.QuadCurveTo(x+dcx, y+dcy, x+dx, y+dy)
|
||||
}
|
||||
|
||||
func rCubicCurveTo(path draw2d.PathBuilder, dcx1, dcy1, dcx2, dcy2, dx, dy float64) {
|
||||
x, y := path.LastPoint()
|
||||
path.CubicCurveTo(x+dcx1, y+dcy1, x+dcx2, y+dcy2, x+dx, y+dy)
|
||||
}
|
Loading…
Reference in a new issue