Skip to content

realabases/heart.c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

How it works:

  • 1: The size you give for the program represents the number of certain pixels and spaces, Here's an example of a heart of size 3:

image

The top pixels of the heart equals (size - 2), If the number is negative then it simply won't draw any. image

  • 2: To determine how many pixels the program needs to draw between the left and the right side of the heart it uses the formula (2X + 3 + (X-1)) where X is the size, Here's an example with two hearts of sizes 1 and 2: image

  • 3: To draw the rest of the heart we need to determine the height of the rest of it, It depends on whether the size is an odd or an even number, If its odd then the formula of the height is ((3X + 1) / 2) where X is the size.

    However if it's even then the forumla is (1.5X) where X is the size. image

  • 4: We need the number of spaces at the start of each row, The formula to achive this is (X-(X-1-I)) where X is the size and I is the number of the current row (first row is zero), Here's an example with two hearts of sizes 1 and 2:

    image

  • 5: Finally we need to determine the number of pixels to draw on each row, The formula to achive that is (2*X + 3 + (X-1) - 2 - 2*I) where X is the size and I is the current row (first row is zero), Here's an example with two hearts of sizes 1 and 2:

    image

All the formulas were found with trial and error

About

retarded way to create a heart ascii shape

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages