【GoLang笔记】A Tour of Go - Exercise: Images

这篇博客介绍了GoLang的学习教程中关于图像处理的练习,要求编写一个返回image.Image接口的图片生成器。内容包括定义自定义Image类型,实现必要的方法如Bounds返回image.Rectangle,ColorModel返回color.RGBAModel,At方法返回颜色值。示例代码提供了参考实现。
摘要由CSDN通过智能技术生成

本笔记是GoLang学习教程的一道习题,题目要求及一种参考实现如下所示。

备注:由于天朝GFW屏蔽了GAE,所以GoLang官网及学习教程需要翻墙才能访问。

Exercise: Images
Remember the picture generator you wrote earlier? Let's write another one, but this time it will return an implementation of image.Image instead of a slice of data.
Define your own Image type, implement the necessary methods, and call pic.ShowImage.
Bounds should return a image.Rectangle, like image.Rect(0, 0, w, h).
ColorModel should return color.RGBAModel.
At should return a color; the value v in the last picture generator corresponds to color.RGBA{v, v, 255, 255} in this one.

参考实现如下:

package main

import (
    "c
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值