<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] > [有價值的參考博客](https://blog.golang.org/image-draw) ## draw 語法 ``` // dst 繪圖的背景圖。 // r 是背景圖的繪圖區域 // src 是要繪制的圖 // sp 是 src 對應的繪圖開始點(繪制的大小 r變量定義了) // mask 是繪圖時用的蒙版,控制替換圖片的方式。 // mp 是繪圖時蒙版開始點(繪制的大小 r變量定義了) // op Op is a Porter-Duff compositing operator func DrawMask(dst Image, r image.Rectangle, src image.Image, sp image.Point, mask image.Image, mp image.Point, op Op) // 第函數Draw是沒有使用蒙版mask的調用方法,它內部其實就是調用的mask為 nil的方法。 func Draw(dst Image, r image.Rectangle, src image.Image, sp image.Point, op Op) { ``` ## 示例 ### 矩形填充顏色 ``` m := image.NewRGBA(image.Rect(0, 0, 640, 480)) blue := color.RGBA{B: 255, A: 255} draw.Draw(m, m.Bounds(), &image.Uniform{C: blue}, image.ZP, draw.Src) ``` ### 拷貝圖片的一部分 ``` r := image.Rectangle{Min: dp, Max: dp.Add(sr.Size())} // 獲得更換區域 draw.Draw(dst, r, src, sr.Min, draw.Src) ``` ### 復制整個圖片 ``` func main() { const width = 130 const height = 50 im := image.NewGray(image.Rectangle{Max: image.Point{X: width, Y: height}}) for x := 0; x < width; x++ { for y := 0; y < height; y++ { dist := math.Sqrt(math.Pow(float64(x-width/2), 2)/3+math.Pow(float64(y-height/2), 2)) / (height / 1.5) * 255 var gray uint8 if dist > 255 { gray = 255 } else { gray = uint8(dist) } im.SetGray(x, y, color.Gray{Y: 255 - gray}) } } pi := image.NewPaletted(im.Bounds(), []color.Color{ color.Gray{Y: 255}, color.Gray{Y: 160}, color.Gray{Y: 70}, color.Gray{Y: 35}, color.Gray{Y: 0}, }) draw.DrawMask() draw.FloydSteinberg.Draw(pi, im.Bounds(), im, image.ZP) shade := []string{" ", "?", "?", "▓", "█"} for i, p := range pi.Pix { fmt.Print(shade[p]) if (i+1)%width == 0 { fmt.Print("\n") } } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看