Skip to content

Commit

Permalink
FractalGen 1.2
Browse files Browse the repository at this point in the history
1. Modify text generator. Now this generating the strings with some sence.
2. Add background color for random text.
  • Loading branch information
username1565 committed Mar 7, 2019
1 parent 8b414b3 commit 1a15dd5
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 56 deletions.
72 changes: 58 additions & 14 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Drawing;

namespace fractalgen
Expand All @@ -15,26 +15,48 @@ static void Main()

class TextGen
{
//who, which, how, [do it]
static string[] who = {
"Царь"
"рассвет", "ропот", "рот", "пенис", "суд", "день", "фрактал", "паскудник", "дебил",
"обоссан", "паршивец", "тварь", "там",
"где-то", "как же", "но, ", "почему", "это же", "дизайнер", "экстремист", "наркоман",
"лезвие", "слегка", "порноактёр", "чебурек", "человек", "бетон", "волюнтарист", "щелчок", "рубака",
"групповод", "медвежоночек", "шахматист", "децибел", "яблочник", "плотоход",
"биточек", "профсоюз", "самолёт-цистерна", "гигантомания", "авиасекстант", "химизатор", "синтез", "сахарин",
};
static string[] which = {
"хочет чип"
"травленый", "ярмарочный",
"двадцатиградусный", "горько-солёный", "садочный", "заседательский", "просветительский",
"безмятежный", "неистовый", "паршивый", "обоссаный", "грядущий", "бредущий", "милый",
"усталый", "нормальный", "паскудный", "растрёпанный", "библиотечный", "убийственный", "позорный",
"безмозглый", "настроенный", "настороженный", "подлинный", "остающийся", "несмеявшийся", "отсталый", "просящий",
"восьмилетний","неохотно","частнопрактикующий","грудастый","взлетающий",
};
static string[] how = {
", потому что"
"на рассвете", "неистово", "пожевывая", "устало", "подлинно", "нормально", "просветительски", "безмозгло",
"размыто", "скомканно", "дёрганно", "головкой", "неловко", "зашкварно", "тайно", "открыто",
"угарно", "попарно", "топорно", "чопорно", "нанотехнологично", "прилично", "лично", "отлично",
"закрыто", "говнисто", "с лопаты", "нормально", "вовек", "троллируя",
"равноправно","электротехнично","псевдоморфозно"
};
static string[] doit = {
"хуй."
"проткнул", "причалил",
"обоссал", "лизал", "топтал", "таскал", "желал", "бежал", "накалывал", "ловил", "гнобил", "топил",
"душил", "ушел", "настал", "хочет", "боится", "ест", "живёт", "умрёт", "омичевал", "напугал", "клонировал",
"разыскивал", "пришел", "обблевал", "насвистывает", "отстал", "целовал", "спит", "убит", "продернулся",
"самоутешился","поделился","раскрасил","вмешался","надкусил",
};

public string Generate(int seed)
{
var r = new Random(seed);
return who[r.Next()%who.Length] + " " + which[r.Next()%which.Length]+ " " + how[r.Next()%how.Length]+ " " + doit[r.Next()%doit.Length];
return (
who[r.Next()%who.Length] + " " + which[r.Next()%which.Length] + " "
+ how[r.Next()%how.Length] + " " + doit[r.Next()%doit.Length]
); //generate text string
}
}

class FractalGen
{
const int cnt = 3;
Expand Down Expand Up @@ -62,19 +84,41 @@ public void GenerateToFile()
var g = Graphics.FromImage(b);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h);
g.DrawString(seed.ToString() + " v1.1 fractalgen", new Font(FontFamily.GenericMonospace, 12), new SolidBrush(Color.Black), 5, 5);

g.DrawString(new TextGen().Generate(seed),
new Font(FontFamily.GenericMonospace, 22), new SolidBrush(Color.Black),w / 2 - w / 12, h - 64);


colors = new Color[2];
colors[0] = Color.FromArgb(r.Next()|0x808080);
colors[1] = Color.FromArgb(r.Next()&0x3f3f3f);
Frac(g, w/2, h/2, h/5, 0, 0);


b.Save(Guid.NewGuid().ToString() + ".png");
var top_text = seed.ToString() + " fractalgen v1.2"; //text in the top
var random_string = new TextGen().Generate(seed); //text in the bottom

//Fill the background for text in the top...
//For font size 12 any symbol have width lesser than 10px and heigth 18px.
g.FillRectangle(
new SolidBrush(Color.White), //color - white, by default
5, //start position for width
5, //start position for heigth
(top_text.Length*10), //10 pixels for each symbol
18 //background height - 18 pixels.
);

//Fill the background for text in the bottom...
//For font size 22 any symbol have width lesser than 19px and heigth 33px.
g.FillRectangle(
new SolidBrush(Color.White), //default - white
(w/3-w/12), //start width
h - 64, //start position for heigth
(random_string.Length*19), //width pixels
33 //height - 33 pixels.
);

g.DrawString(top_text, new Font(FontFamily.GenericMonospace, 12), new SolidBrush(Color.Black), 5, 5); //top text

g.DrawString(random_string,
new Font(FontFamily.GenericMonospace, 22), new SolidBrush(Color.Black), w / 3 - w / 12, h - 64); //bottom text

b.Save(Guid.NewGuid().ToString() + ".png"); //save picture as png-file
}

static float[] Rotate(float[] p, float a)
Expand Down
84 changes: 42 additions & 42 deletions fractalgen.csproj
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{A1228F21-FBA3-4C0B-9771-94B815B0D0BD}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>fractalgen</RootNamespace>
<AssemblyName>fractalgen</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{A1228F21-FBA3-4C0B-9771-94B815B0D0BD}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>fractalgen</RootNamespace>
<AssemblyName>fractalgen</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>

0 comments on commit 1a15dd5

Please sign in to comment.