{"id":293,"date":"2012-12-11T17:22:17","date_gmt":"2012-12-11T22:22:17","guid":{"rendered":"http:\/\/dragonlordwarlock.com\/blog\/?p=293"},"modified":"2014-10-01T22:41:10","modified_gmt":"2014-10-02T03:41:10","slug":"fractal-tree-c-logo-output","status":"publish","type":"post","link":"https:\/\/dragonlordwarlock.com\/blog\/?p=293","title":{"rendered":"Fractal Tree C++ Logo Output"},"content":{"rendered":"<pre class=\"theme:epicgeeks font-size:14 nums:false nums-toggle:false lang:c++ decode:true \" title=\"Fractal Tree C++\">#include &lt;cstdio&gt;\r\n#include &lt;cstdlib&gt;\r\n#include &lt;ctime&gt;\r\n#include &lt;string&gt;\r\n\r\nusingnamespace std;\r\n\r\nclass ifstree\r\n{\r\npublic:\r\n    float minfactor;\r\n    float maxfactor;\r\n    float bend;\r\n    float angle;\r\n    float initlen;\r\n    int fdim;\r\n    ifstree();\r\n    void turnleft(float ang)\r\n    {\r\n        printf(\"lt %4.2f\\n\", ang);\r\n    };\r\n    void turnright(float ang)\r\n    {\r\n        printf(\"rt %4.2f\\n\", ang);\r\n    };\r\n    void movefw(float value)\r\n    {\r\n        printf(\"fw %4.2f\\n\", value);\r\n    };\r\n    void movebw(float value)\r\n    {\r\n        printf(\"bw %4.2f\\n\", value);\r\n    };\r\n    float randfactor();\r\n    void draw();\r\n    void draw(float linelen,int depth);\r\n};\r\n\r\nifstree::ifstree()\r\n{\r\n    minfactor =(float)1\/3;\r\n    maxfactor =(float)2\/3;\r\n    bend =8.0;\r\n    angle =40.0;\r\n    fdim =8;\r\n    srand( time(NULL));\r\n    initlen =100.0;\r\n}\r\n\r\nvoid ifstree::draw()\r\n{\r\n    draw(initlen, fdim);\r\n}\r\n\r\nfloat ifstree::randfactor()\r\n{\r\n    float rnd =(float) rand()\/RAND_MAX;\r\n    return(float) rnd;\r\n}\r\n\r\nvoid ifstree::draw(float linelen,int depth)\r\n{\r\n    if(depth&gt;0)\r\n    {\r\n       float minlength = linelen * minfactor;\r\n       float maxlength = linelen * maxfactor;\r\n       float difflength = maxlength - minlength;\r\n       movefw(linelen);\r\n       turnleft(angle+bend);\r\n       draw(minlength+(randfactor()*difflength), depth-1);\r\n       turnright(angle);\r\n       draw(minlength+(randfactor()*difflength), depth-1);\r\n       turnright(angle);\r\n       draw(minlength+(randfactor()*difflength), depth-1);\r\n       turnleft(angle-bend);\r\n       movebw(linelen);\r\n    }\r\n}\r\n\r\nint main(int argc,char*argv[])\r\n{\r\n    ifstree T;\r\n    if(argc&gt;1)\r\n    {\r\n        string svalue(argv[1]);\r\n        float fv =(float)atof(svalue.c_str());\r\n        T.initlen = fv;\r\n    }\r\n    T.draw();\r\n    return0;\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;cstdio&gt; #include &lt;cstdlib&gt; #include &lt;ctime&gt; #include &lt;string&gt; usingnamespace std; class ifstree { public: float minfactor; float maxfactor; float bend; float angle; float initlen; int fdim; ifstree(); void turnleft(float ang) { printf(&#8220;lt %4.2f\\n&#8221;, ang); }; void turnright(float ang) { printf(&#8220;rt %4.2f\\n&#8221;, ang); }; void movefw(float value) { printf(&#8220;fw %4.2f\\n&#8221;, value); }; void movebw(float value) { &#8230; <a href=\"https:\/\/dragonlordwarlock.com\/blog\/?p=293\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &#8220;Fractal Tree C++ Logo Output&#8221;<\/span> &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[29,32],"tags":[],"class_list":["post-293","post","type-post","status-publish","format-standard","hentry","category-c","category-programming"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=293"}],"version-history":[{"count":5,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/293\/revisions"}],"predecessor-version":[{"id":518,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/293\/revisions\/518"}],"wp:attachment":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}