Added support for getting & setting location of Renderer.

This commit is contained in:
Sander Schobers 2022-05-01 12:05:17 +00:00
parent ddf9476920
commit f56c5dd389
3 changed files with 20 additions and 0 deletions

View File

@ -287,6 +287,15 @@ func (r *Renderer) Line(p, q geom.PointF32, color color.Color, thickness float32
allg5.DrawLine(p.X, p.Y, q.X, q.Y, newColor(color), thickness)
}
func (r *Renderer) Location() geom.Point {
x, y := r.disp.Position()
return geom.Pt(x, y)
}
func (r *Renderer) Move(to geom.Point) {
r.disp.SetPosition(to.X, to.Y)
}
func (r *Renderer) mustGetBitmap(t ui.Texture) *allg5.Bitmap {
texture, ok := t.(*texture)
if !ok {

View File

@ -374,6 +374,15 @@ func (r *Renderer) Line(p, q geom.PointF32, color color.Color, thickness float32
r.renderer.DrawLineF(p.X, p.Y, q.X, q.Y)
}
func (r *Renderer) Location() geom.Point {
x, y := r.window.GetPosition()
return geom.Pt(int(x), int(y))
}
func (r *Renderer) Move(to geom.Point) {
r.window.SetPosition(int32(to.X), int32(to.Y))
}
func (r *Renderer) Rectangle(rect geom.RectangleF32, c color.Color, thickness float32) {
r.SetDrawColorGo(c)
if rect.Dx() == 0 { // SDL doesn't draw a 1 px wide line when Dx() == 0 && thickness == 1

View File

@ -31,6 +31,8 @@ type Renderer interface {
DrawTexturePointOptions(t Texture, p geom.PointF32, opts DrawOptions)
FillRectangle(r geom.RectangleF32, c color.Color)
Line(p, q geom.PointF32, color color.Color, thickness float32)
Location() geom.Point
Move(geom.Point)
Rectangle(r geom.RectangleF32, c color.Color, thickness float32)
RenderTo(Texture)
RenderToDisplay()