node ascii 转换_使用Node.js将图像转换为ASCII Art

node ascii 转换

ASCII Art

There are many people out there that don't appreciate ASCII art;  we call those people "idiots".  ASCII art has been used forever and remains, in my opinion, a feat of programming and creativity.  There's a project called image-to-ascii which doesn't just create ascii art but does so from an image of your choosing.  Baller!

有很多人不喜欢ASCII艺术。 我们称这些人为“白痴”。 在我看来,ASCII艺术已被永久使用,并且仍然是编程和创造力的壮举。 有一个名为“ 图像转ascii”的项目,它不仅可以创建ascii艺术,还可以根据您选择的图像来创建。 鲍尔!

Assuming you've installed dependencies, outputting an image to ASCII art in the console is fairly simple:

假设您已经安装了依赖项,则在控制台中将图像输出为ASCII图像非常简单:


var ImageToAscii = require('image-to-ascii');
ImageToAscii(__dirname + '/logo.png', function(err, converted) {
    console.log(err || converted);
});


Short bit of code for a cool effect.  You'll want to size the image down to less than 200px for best display and even then the ASCII output within the console looks excellent.  As I mentioned in Show Images in Console with Node.js console-png, adding graphical elements to the console can be a nice touch and enhancement from bland text!

简短的代码可带来炫酷效果。 您可能希望将图像缩小到小于200像素,以获得最佳显示效果,即使如此,控制台内的ASCII输出看起来也很出色。 正如我在使用Node.js console-png在控制台显示图像中提到的那样,向控制台添加图形元素可以使平淡的文本变得很不错,并且得到了增强!

翻译自: https://davidwalsh.name/convert-image-ascii-art

node ascii 转换

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
解释一下这段代码 def add_seq_to_prefix_tree(self, root_node, cluster: LogCluster): token_count = len(cluster.log_template_tokens) token_count_str = str(token_count) if token_count_str not in root_node.key_to_child_node: first_layer_node = Node() root_node.key_to_child_node[token_count_str] = first_layer_node else: first_layer_node = root_node.key_to_child_node[token_count_str] cur_node = first_layer_node if token_count == 0: cur_node.cluster_ids = [cluster.cluster_id] return current_depth = 1 for token in cluster.log_template_tokens: if current_depth >= self.max_node_depth or current_depth >= token_count: new_cluster_ids = [] for cluster_id in cur_node.cluster_ids: if cluster_id in self.id_to_cluster: new_cluster_ids.append(cluster_id) new_cluster_ids.append(cluster.cluster_id) cur_node.cluster_ids = new_cluster_ids break if token not in cur_node.key_to_child_node: if self.parametrize_numeric_tokens and self.has_numbers(token): if self.param_str not in cur_node.key_to_child_node: new_node = Node() cur_node.key_to_child_node[self.param_str] = new_node cur_node = new_node else: cur_node = cur_node.key_to_child_node[self.param_str] else: if self.param_str in cur_node.key_to_child_node: if len(cur_node.key_to_child_node) < self.max_children: new_node = Node() cur_node.key_to_child_node[token] = new_node cur_node = new_node else: cur_node = cur_node.key_to_child_node[self.param_str] else: if len(cur_node.key_to_child_node) + 1 < self.max_children: new_node = Node() cur_node.key_to_child_node[token] = new_node cur_node = new_node elif len(cur_node.key_to_child_node) + 1 == self.max_children: new_node = Node() cur_node.key_to_child_node[self.param_str] = new_node cur_node = new_node else: cur_node = cur_node.key_to_child_node[self.param_str] else: cur_node = cur_node.key_to_child_node[token] current_depth += 1
03-23

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值