• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating special shapes/patterns without using graphic Lib

 
Ranch Hand
Posts: 598
3
jQuery Google App Engine Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello there , I see various interesting programs (such as diamond pattern using "*") on the Internet. Several of them uses Maths functions to form a particular shape. Check out this one..


the above program prints a heart shape with "Happy Valentine's Day" message. They used the math functions to perform this task. If I want to print a particular shape without using a graphic library , say a cube how would I do that ? I need your guidance to understand such situation. What is "idx" in the above code ? I mainly get confused with For Loops with mathematical calculation. I find it very hard to understand. Sorry , If I sound like complete moron.. unlike you guys , I don't have an engineering degree. >
 
Bartender
Posts: 1205
22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bobby Sharma wrote:hello there , I see various interesting programs (such as diamond pattern using "*") on the Internet. Several of them uses Maths functions to form a particular shape. Check out this one..
...
the above program prints a heart shape with "Happy Valentine's Day" message. They used the math functions to perform this task. If I want to print a particular shape without using a graphic library , say a cube how would I do that ? I need your guidance to understand such situation. What is "idx" in the above code ? I mainly get confused with For Loops with mathematical calculation. I find it very hard to understand. Sorry , If I sound like complete moron.. unlike you guys , I don't have an engineering degree. >



First, let me say that the second outer for loop (the "for(x=1..." one), whcih prints out the lower triangle of the heart, is not put together the way I would have done. Nonetheless...

The "idx" variable indicates what character within "message" is to be printed. e.g. When idx=1, the 'H' in " Happy Valentine's Day " will be printed.


As for how to draw other shapes, such a cube, it all depends on how exactly you want to output to look. If you really want to make something general-purpose enough to be able to draw the 2D projection of arbitrary 3D shapes, you could develop your own ray-tracing program. However, I suspect that such a project is more than you want to get involved in.

Let me add some specifics to your request so that we're all on the same page about what problem we're trying to solve:

How could you print a character graphics representation of an isometric projection of a cube of a given size? For instance for size=4, you would get the following:

(Edit: New version of output.)


I just picked '.', 'c' and 'M' more-or-less at random as "light", "medium" and "dark" fill characters.

Bobby, now that you know what you want, what do you think the next step is toward implementing it?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic