mysql的吉祥物_用Go语言绘制Go语言地鼠吉祥物

Go语言是谷歌2009发布的第二款开源编程语言。Go语言专门针对多处理器系统应用程序的编程进行了优化,使用Go编译的程序可以媲美C或C++代码的速度,而且更加安全、支持并行进程。但Go语言除了擅长处理服务器端任务外,它还可以用来做图。

package main

import (

"log"

"github.com/fogleman/pt/pt"

)

func main() {

scene := pt.Scene{}

wall := pt.SpecularMaterial(pt.HexColor(0xFCFAE1), 2)

scene.Add(pt.NewSphere(pt.Vector{4, 7, 3}, 2, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))

scene.Add(pt.NewCube(pt.Vector{-30, -1, -30}, pt.Vector{-8, 10, 30}, wall))

scene.Add(pt.NewCube(pt.Vector{-30, -1, -30}, pt.Vector{30, 0.376662, 30}, wall))

material := pt.GlossyMaterial(pt.Color{}, 1.5, pt.Radians(30))

mesh, err := pt.LoadOBJ("examples/gopher.obj", material)

if err != nil {

log.Fatalln("LoadOBJ error:", err)

}

mesh.SmoothNormals()

scene.Add(mesh)

camera := pt.LookAt(pt.Vector{8, 3, 0.5}, pt.Vector{-1, 2.5, 0.5}, pt.Vector{0, 1, 0}, 45)

pt.IterativeRender("out%03d.png", 10, &scene, &camera, 2560/4, 1440/4, -1, 16, 4)

}

上面这都简洁的只有几行的代码运行后会输出什么结果?也许会让你吃惊。不信的话,你可以运行一下,运行时方法是:

go run examples/gopher.go

输出的结果是这样的:

687474703a2f2f692e696d6775722e636f6d2f62755346376d352e706e67.png.jpg

多么漂亮的地鼠呀,这个地鼠可不是一般的地鼠,它是Go语言的吉祥物。几句简单的代码就能生成这么漂亮的图案真是神奇吧。这写代码的作者是Michael Fogleman,除了这个地鼠外,下面这几个图片也是用Go语言绘制出来的,是不是有点不可思议?

687474703a2f2f692e696d6775722e636f6d2f6d3664726439732e706e67.png.jpg

687474703a2f2f692e696d6775722e636f6d2f667838436776792e706e67.png.jpg

687474703a2f2f692e696d6775722e636f6d2f59706e335743492e706e67.png.jpg

687474703a2f2f692e696d6775722e636f6d2f795665696c35472e706e67.png.jpg

687474703a2f2f692e696d6775722e636f6d2f32504e765467452e706e67.png.jpg

有疑问加站长微信联系(非本文作者)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值