通过 C# 生成 ascii 艺术

发布于 2024-09-13 06:17:27 字数 121 浏览 2 评论 0原文

我曾经为一份工作做过编程测试,其中涉及用 C# 制作 ASCii 艺术作品。我在这方面做得并不好,因为我对用 C#(或任何编程知识)执行此操作几乎没有想法或经验。

.NET 中是否有任何值得了解/练习的资源或类?

I once did a programming test for a job, which involved producing ASCii art in C#. I didn't really do well at this, as I had little idea or experience of doing this in C# (or in any programming knowledge).

Are there any resources or classes in .NET that would be worth knowing/practising on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

爱给你人给你 2024-09-20 06:17:27

ASCII 艺术非常通用,但如果您想生成 ASCII 横幅或标题,那么我已将流行的 Figlet 字体生成移植到 .NET:

https://github.com/drewnoakes/figgle

它非常易于使用,并且可以在 NuGet 上获得几乎所有 .NET 版本(netstandard1.3 及更高版本,所以 .NET Framework 以及 .NET Core、Xamarin 等...)。

            _ _          __    __           _     _   _ 
  /\  /\___| | | ___    / / /\ \ \___  _ __| | __| | / \
 / /_/ / _ \ | |/ _ \   \ \/  \/ / _ \| '__| |/ _` |/  /
/ __  /  __/ | | (_) |   \  /\  / (_) | |  | | (_| /\_/ 
\/ /_/ \___|_|_|\___( )   \/  \/ \___/|_|  |_|\__,_\/   
                    |/       

制作通过:

Console.WriteLine( 
    FiggleFonts.Ogre.Render("Hello, World!"));

ASCII art is pretty general, but if you want to produce an ASCII banner or heading then I've ported the popular FIGlet font generation to .NET:

https://github.com/drewnoakes/figgle

It's very easy to use, and available on NuGet for almost every version of .NET (netstandard1.3 and above, so .NET Framework as well as .NET Core, Xamarin, etc...).

            _ _          __    __           _     _   _ 
  /\  /\___| | | ___    / / /\ \ \___  _ __| | __| | / \
 / /_/ / _ \ | |/ _ \   \ \/  \/ / _ \| '__| |/ _` |/  /
/ __  /  __/ | | (_) |   \  /\  / (_) | |  | | (_| /\_/ 
\/ /_/ \___|_|_|\___( )   \/  \/ \___/|_|  |_|\__,_\/   
                    |/       

Produced via:

Console.WriteLine( 
    FiggleFonts.Ogre.Render("Hello, World!"));
恋竹姑娘 2024-09-20 06:17:27

阅读这篇文章
http://www.c-sharpcorner.com/UploadFile/dheenu27/ ImageToASCIIconverter03022007164455PM/ImageToASCIIconverter.aspx

它允许您上传将转换为 ASCII 艺术的图像:) 非常酷的东西。

CodeProject 也有一个示例
http://www.codeproject.com/KB/web-image/ascii_art_with_c_。 ASPX

Have a read at this post
http://www.c-sharpcorner.com/UploadFile/dheenu27/ImageToASCIIconverter03022007164455PM/ImageToASCIIconverter.aspx

It allows you to upload an image which will be converted into ASCII art :) Pretty cool stuff.

CodeProject has a sample too
http://www.codeproject.com/KB/web-image/ascii_art_with_c_.aspx

孤云独去闲 2024-09-20 06:17:27

经过一番研究,我发现最好的方法是:

1.转到文本到 ASCII 艺术生成器 (TAAG)

2. 输入您的文字。

3.更改设置以使文本看起来适合您。

输入图片此处描述

3. 单击“选择并复制”

在此处输入图像描述

4. 在C# 代码类型如下:

string text = @"// Your copied ASCII code";
Console.WriteLine(text);

确保在引号前添加 @ 符号,以便格式保持不变,否则编辑器会给您带来很多错误。

After some research I found out that the best way to do it is this:

1. go to Text to ASCII Art Generator (TAAG).

2. type your text.

3. Change the settings to make the text look right to you.

enter image description here

3. click "Select & Copy"

enter image description here

4. In the C# code type this:

string text = @"// Your copied ASCII code";
Console.WriteLine(text);

Make sure you add the @ sign before the quotes so that the formatting stays the same, otherwise the editor will give you lots of errors.

Saygoodbye 2024-09-20 06:17:27

要了解完整的 ASCII“谱”,应该了解 ASCII 图表,也称为 ASCII 表。

http://www.asciitable.com/

知道了这一点,就可以获取在 codeproject 链接中找到的代码并用它创造一些“独特”的东西。 :-)

如果你仔细想想,它只是一个“查找”表,你可以从中提取一个值并做你想做的任何事情。

To understand the full ASCII "spectrum" one should know about the ASCII Chart, also known as the ASCII Table.

http://www.asciitable.com/

Knowing that, one could take code found in the codeproject link and make something "unique" with it. :-)

If you think about it, it's just a "look-up" table and you can pull a value out of it and do anything you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文