Drawing pixel "misses" now
but looks like something is awry in how rectangles are being drawn.
This commit is contained in:
parent
71ab8b249d
commit
be0c529381
@ -86,7 +86,8 @@ func (me *Canvas) Rectangle(x, y, halfWidth, halfHeight float64) error {
|
||||
hs := me.factorY(f2 * halfHeight)
|
||||
|
||||
if ws <= 1 && hs <= 1 {
|
||||
return me.Pixel(x, y)
|
||||
me.Pixel(x, y)
|
||||
return nil
|
||||
}
|
||||
|
||||
draw.Draw(me.img, image.Rect(int(xs-ws/f2), int(ys-hs/f2), int(ws), int(hs)),
|
||||
@ -95,8 +96,11 @@ func (me *Canvas) Rectangle(x, y, halfWidth, halfHeight float64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *Canvas) Pixel(x, y float64) error {
|
||||
return nil
|
||||
func (me *Canvas) Pixel(x, y float64) {
|
||||
originX, originY := int(me.scaleX(x)), int(me.scaleY(y))
|
||||
draw.Draw(me.img, image.Rect(originX, originY, originX+1, originY+1),
|
||||
&image.Uniform{image.White}, image.ZP, draw.Src)
|
||||
me.window.FlushImage()
|
||||
}
|
||||
|
||||
func (me *Canvas) Draw() error {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package algs4
|
||||
|
||||
type Point2D struct {
|
||||
X float64
|
||||
Y float64
|
||||
Canvas *Canvas
|
||||
X float64
|
||||
Y float64
|
||||
|
||||
canvas *Canvas
|
||||
}
|
||||
|
||||
func NewPoint2D(x, y float64, canvas *Canvas) *Point2D {
|
||||
@ -12,12 +13,13 @@ func NewPoint2D(x, y float64, canvas *Canvas) *Point2D {
|
||||
}
|
||||
|
||||
return &Point2D{
|
||||
X: x,
|
||||
Y: y,
|
||||
Canvas: canvas,
|
||||
X: x,
|
||||
Y: y,
|
||||
|
||||
canvas: canvas,
|
||||
}
|
||||
}
|
||||
|
||||
func (me *Point2D) Draw() {
|
||||
return
|
||||
me.canvas.Pixel(me.X, me.Y)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user