当前位置:网站首页>用Go+绘制爱心给心爱的她表白
用Go+绘制爱心给心爱的她表白
2022-07-03 00:35:00 【无 羡ღ】
实现的效果

️Go+语言介绍
Go+在2020年7月刚问世时,其slogan是
“为数据科学而生”。而在Go+1.0版迈出商业化第一步时,slogan变成三位一体的“for engineering, STEM education, and data science”。
“for engineering”致力于让工程师可以使用简洁、容易掌握的语言去工作,这在纷繁复杂的工程技术领域是非常重要的进化。
“for STEM education”希望青少年从小学就能学习一门工程语言,以便于在将来的工作中延续使用。目前,儿童接触的第一门编程语言通常是Scratch,很难终身受用。
“for data science”让工程师和数据科学家可以用相同的语言去对话,这在以数据驱动创新的未来尤为重要。
go+语言特点
Go+ 非常有意思的一点,它是唯一一个选择了双引擎的语言,既支持静态编译,也支持可解析执行。
为什么要做双引擎呢?因为我认为程序员和数据科学家的诉求是不一样的,数据科学家喜欢单步执行,大家可以在心中回想一下你见过的数学软件,包括 SAS、MATLAB,数学软件交互都是单步执行的方式。
这并不是因为数据科学家懒。程序员理解程序逻辑是可以放在脑子里的,我们脑子里知道程序逻辑写得对不对。但数据科学家做计算的时候,不能知道计算结果对不对,因为人的计算能力比计算机弱太多了,所以一定要单步执行看到计算结果,才能知道自己下一步应该怎么办,这是数据科学家和程序员工作模式完全不同的一个点。
因为他是在做计算而不是在做一种程序逻辑,所以他很难不去做单步执行。
但当数据科学家建了一种模型,最终要使用了,这时他仍然希望最终交付的是最大化的执行效率,他一定不希望代码运行很慢,所以这个时候他就又需要静态编译执行,这也是为什么 Go+ 希望设计成双引擎,因为调试阶段和生产使用阶段,工作模式完全不一样。
Go+环境搭建
安装 Git 工具
Git 官网地址:https://git-scm.com/download/win
选择版本(我电脑是32位):


选择路径:

安装后,在cmd控制台出入:
git version,显示版本号表示安装成功。
安装 Go+
官方 GitHub 地址:https://github.com/goplus/gop
我们这边使用 Git工具下载安装Go+,在cmd控制台出入:
git clone https://github.com/goplus/gop.git安装中

配置环境变量(我的电脑 -> 属性 -> 高级环境变量 -> 环境变量 -> 新建系统变量)
在path中添加%gop%\bin,中间的gop就是我们前面用的变量名。
绘制爱心
环境搭建好了,接下来创建一个.txt的文件,把代码复制进去后,修改后缀为.gop
package main
import (
"flag"
"fmt"
"math"
"strings"
"time"
)
func main() {
// MYWORD My word
var head string
var tail string
var MYWORD string
var sep string
var zoom float64
flag.StringVar(&head, "head", "There are some words I wana tell you:", "A sentence printed on the head") //添加开头要写的话
flag.StringVar(&tail, "tail", "\t\t\t\t--- Your lover", "A sentence printed on the tail") //添加结尾要写的话
flag.StringVar(&MYWORD, "words", "Dear, I love you forever!", "The words you want to talk") //爱心中的内容
flag.StringVar(&sep, "sep", " ", "The separator")
flag.Float64Var(&zoom, "zoom", 1.0, "Zoom setting")
flag.Parse()
chars := strings.Split(MYWORD, sep)
time.Sleep(time.Duration(1) * time.Second)
fmt.Println(head)
fmt.Println()
time.Sleep(time.Duration(1) * time.Second)
for _, char := range chars {
allChar := make([]string, 0)
for y := 12 * zoom; y > -12*zoom; y-- {
lst := make([]string, 0)
lstCon := ""
for x := -30 * zoom; x < 30*zoom; x++ {
x2 := float64(x)
y2 := float64(y)
formula := math.Pow(math.Pow(x2*0.04/zoom, 2)+math.Pow(y2*0.1/zoom, 2)-1, 3) - math.Pow(x2*0.04/zoom, 2)*math.Pow(y2*0.1/zoom, 3)
if formula <= 0 {
index := int(x) % len(char)
if index >= 0 {
lstCon += string(char[index])
} else {
lstCon += string(char[int(float64(len(char))-math.Abs(float64(index)))])
}
} else {
lstCon += " "
}
}
lst = append(lst, lstCon)
allChar = append(allChar, lst...)
}
for _, text := range allChar {
fmt.Printf("%s\n", text)
}
}
time.Sleep(time.Duration(1) * time.Second)
fmt.Println("\t\t\t\t", tail)
}
边栏推荐
- 合并K个已排序的链表
- Kubernetes resource object introduction and common commands (V) - (NFS & PV & PVC)
- Leetcode-241: designing priorities for operational expressions
- Is there a free text to speech tool to help recommend?
- 1.12 - 指令
- (C语言)数据的存储
- leetcode-1964:找出到每个位置为止最长的有效障碍赛跑路线
- MySQL multi table joint deletion
- [C language] branch and loop statements (Part 1)
- [shutter] image component (configure local GIF image resources | load placeholder with local resources)
猜你喜欢

2022 list of manufacturers of Chinese 3D vision enterprises (guided positioning and sorting scenes)

Vulkan practice first bullet

Illustrated network: what is virtual router redundancy protocol VRRP?

leetcode-2280:表示一个折线图的最少线段数
![[C language] branch and loop statements (Part 1)](/img/47/6efcc59bd26e26f66c698635c26c8b.png)
[C language] branch and loop statements (Part 1)

这不平凡的两年,感谢我们一直在一起!

1.11 - bus

Vulkan performance and refinement
![[shutter] image component (the placeholder | transparent_image transparent image plug-in is loaded into the memory)](/img/73/19e2e0fc5ea6f05e34584ba40a452d.jpg)
[shutter] image component (the placeholder | transparent_image transparent image plug-in is loaded into the memory)

Liad: the consumer end of micro LED products is first targeted at TVs above 100 inches. At this stage, it is still difficult to enter a smaller size
随机推荐
Leetcode-2115: find all the dishes that can be made from the given raw materials
Foundations of data science is free to download
[shutter] image component (load network pictures | load static pictures | load local pictures | path | provider plug-in)
【AutoSAR 十一 通信相关机制】
Leetcode-1964: find the longest effective obstacle race route to each position
Callback event after the antv X6 node is dragged onto the canvas (stepping on a big hole record)
Machine learning: numpy version linear regression predicts Boston house prices
文件操作IO-Part2
【AutoSAR 十 IO架构】
leetcode-241:为运算表达式设计优先级
【AutoSAR 九 C/S原理架构】
2022.2.14 resumption
Lex & yacc & bison & flex configuration problems
图解网络:什么是虚拟路由器冗余协议 VRRP?
Vulkan performance and refinement
Is there a free text to speech tool to help recommend?
世平信息首席科学家吕喆:构建以数据和人员为中心的安全能力
利亚德:Micro LED 产品消费端首先针对 100 英寸以上电视,现阶段进入更小尺寸还有难度
FPGA - 7系列 FPGA内部结构之Clocking -04- 多区域时钟
Leetcode 294. Flip game II (game theory)