示例#1
0
文件: dwg.go 项目: lcaballero/img
func (c *Canvas) FillRect(pos, dim *vec.Vec) {
	c.BeginPath()
	c.MoveTo(pos.Pts())
	c.LineTo(pos.X+dim.X, pos.Y)
	c.LineTo(pos.X+dim.X, pos.Y+dim.Y)
	c.LineTo(pos.X, pos.Y+dim.Y)
	c.LineTo(pos.Pts())
	c.Fill()
}
示例#2
0
func (d *Diamonds) render(g *dwg.GraphicContext, h, v *vec.Vec, data chan Occur) {
	for step := range data {
		g.Save()
		g.Rotate(step.Arc)
		g.Translate(90, 0)
		d.drawDiamond(
			g,
			h.Scale(step.Scale, step.Scale),
			v.Scale(step.Scale, step.Scale),
			RgbaColor(150, 140+step.N, 0, step.Opacity),
		)
		g.Restore()
	}
}
示例#3
0
func (g *StarPattern) Star(p, hct *vec.Vec) {
	p1 := p.Translate(0.0, hct.Y)
	g.MoveTo(p.Pts())

	a1 := p1.Translate(-hct.X, hct.Y)
	a2 := a1.Translate(-hct.X, 0.0)
	g.CubicCurveTo(p1.X, p1.Y, a1.X, a1.Y, a2.X, a2.Y)

	b1 := a1.Translate(hct.X, hct.Y)
	b2 := b1.Translate(0.0, hct.Y)
	g.CubicCurveTo(a1.X, a1.Y, b1.X, b1.Y, b2.X, b2.Y)

	c1 := b1.Translate(hct.X, -hct.Y)
	c2 := c1.Translate(hct.X, 0.0)
	g.CubicCurveTo(b1.X, b1.Y, c1.X, c1.Y, c2.X, c2.Y)

	d1 := c1.Translate(-hct.X, -hct.Y)
	d2 := d1.Translate(0.0, -hct.Y)
	g.CubicCurveTo(c1.X, c1.Y, d1.X, d1.Y, d2.X, d2.Y)
}