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)
|
hs := me.factorY(f2 * halfHeight)
|
||||||
|
|
||||||
if ws <= 1 && hs <= 1 {
|
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)),
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me *Canvas) Pixel(x, y float64) error {
|
func (me *Canvas) Pixel(x, y float64) {
|
||||||
return nil
|
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 {
|
func (me *Canvas) Draw() error {
|
||||||
|
@ -3,7 +3,8 @@ package algs4
|
|||||||
type Point2D struct {
|
type Point2D struct {
|
||||||
X float64
|
X float64
|
||||||
Y float64
|
Y float64
|
||||||
Canvas *Canvas
|
|
||||||
|
canvas *Canvas
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPoint2D(x, y float64, canvas *Canvas) *Point2D {
|
func NewPoint2D(x, y float64, canvas *Canvas) *Point2D {
|
||||||
@ -14,10 +15,11 @@ func NewPoint2D(x, y float64, canvas *Canvas) *Point2D {
|
|||||||
return &Point2D{
|
return &Point2D{
|
||||||
X: x,
|
X: x,
|
||||||
Y: y,
|
Y: y,
|
||||||
Canvas: canvas,
|
|
||||||
|
canvas: canvas,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me *Point2D) Draw() {
|
func (me *Point2D) Draw() {
|
||||||
return
|
me.canvas.Pixel(me.X, me.Y)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user