Sync
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
var i interface{} = "hello"
|
||||
|
||||
s := i.(string)
|
||||
fmt.Println(s)
|
||||
|
||||
fmt.Printf("%v- %T\n", s, s)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"golang.org/x/tour/pic"
|
||||
"image"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
type Image struct{
|
||||
w, h int
|
||||
}
|
||||
|
||||
func (i Image) Bounds() image.Rectangle {
|
||||
return image.Rect(0, 0, i.w, i.h)
|
||||
}
|
||||
|
||||
func (i Image) ColorModel() color.Model {
|
||||
return color.RGBAModel
|
||||
}
|
||||
|
||||
func (i Image) At(x, y int) color.Color {
|
||||
v := uint8(x^y)
|
||||
return color.RGBA{v, v, 255, 255}
|
||||
}
|
||||
|
||||
func main() {
|
||||
m := Image{320, 240}
|
||||
pic.ShowImage(m)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
module exercise-images.go
|
||||
|
||||
go 1.24.5
|
||||
|
||||
require golang.org/x/tour v0.1.0
|
||||
@@ -0,0 +1,2 @@
|
||||
golang.org/x/tour v0.1.0 h1:OWzbINRoGf1wwBhKdFDpYwM88NM0d1SL/Nj6PagS6YE=
|
||||
golang.org/x/tour v0.1.0/go.mod h1:DUZC6G8mR1AXgXy73r8qt/G5RsefKIlSj6jBMc8b9Wc=
|
||||
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
)
|
||||
|
||||
func main() {
|
||||
m := image.NewRGBA(image.Rect(0, 0, 100, 100))
|
||||
fmt.Println(m.Bounds())
|
||||
fmt.Println(m.At(0, 0).RGBA())
|
||||
}
|
||||
Reference in New Issue
Block a user