本文整理匯總了Golang中image.Rectangle.Canon方法的典型用法代碼示例。如果您正苦於以下問題:Golang Rectangle.Canon方法的具體用法?Golang Rectangle.Canon怎麽用?Golang Rectangle.Canon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類image.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Canon方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: saneRectangle
func saneRectangle(rect image.Rectangle) image.Rectangle {
rect = rect.Canon()
width, height := rect.Dx(), rect.Dy()
if width < 1 || width > 4096 || height < 1 || height > 4096 {
return image.Rect(0, 0, 16, 16)
}
return rect
}
示例2: convertRect
func convertRect(rect image.Rectangle) C.SDL_Rect {
rect = rect.Canon()
return C.SDL_Rect{
C.Sint16(rect.Min.X),
C.Sint16(rect.Min.Y),
C.Uint16(rect.Max.X - rect.Min.X),
C.Uint16(rect.Max.Y - rect.Min.Y),
}
}
示例3: Draw
// Draw creates an image of the function in the domain.
func Draw(fnc ColorMap, size image.Rectangle, domain *ComplexRect) image.Image {
size = size.Canon()
// Clever vector hack to move the Min corner to 0,0
size = size.Sub(size.Min)
// For now, use RGBA as image type
img := image.NewRGBA(size)
// max x and y guaranteed to be size of rectangle
x := size.Dx()
y := size.Dy()
dx := domain.dx() / float64(x)
dy := domain.dy() / float64(y)
// Get the initial x vals
base_x := domain.left()
base_y := domain.bottom()
for i := 0; i <= x; i++ {
for j := 0; j <= y; j++ {
point := complex(base_x+float64(i)*dx, base_y+float64(j)*dy)
img.Set(i, j, fnc(point))
}
}
return img
}
示例4: DonutCoords
func DonutCoords(x, y int, r image.Rectangle) (int, int) {
r = r.Canon()
x = (int(math.Mod(float64(x), float64(r.Dx())))+r.Dx())%r.Dx() + r.Min.X
y = (int(math.Mod(float64(y), float64(r.Dy())))+r.Dy())%r.Dy() + r.Min.Y
return x, y
}
示例5: SubImage
// SubImage extracts a rectangular subset of draw.Image as a separate draw.Image
// with a translated origin to the rectangles canonicalized Min point.
func SubImage(img draw.Image, r image.Rectangle) draw.Image {
return &subimage{
Image: img,
bounds: img.Bounds().Intersect(r.Canon()),
}
}