Pages

Thursday, 28 May 2020

Chapter 14 // Exercise 1 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and the graphics files found here:
https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files

Chapter 14 // Exercise 1

Define two classes Smiley and Frowny, which are both derived from class Circle and have two eyes and a mouth. Next, derive classes from Smiley and Frowny which add an appropriate hat to each.

Github: https://github.com/l-paz91/principles-practice/tree/master/Chapter%2014/Exercise1


This took me a bit longer than I thought it would, mainly because I forgot how fl_pie() works:
The top left corner of the rectangle is where fl_pie() draws from; not from the center of the circle which would honestly make more sense. So instead of figuring out where you want the center of the circle to be; calculate the top-left of the bounding box.

For the "appropriate hat", I wanted to use images. However, there was no way to resize the image to fit whatever radius the circle was. I looked around FLTK and found a badly named function called copy() that creates a new version of the image and resizes it if given a width and height.


No comments:

Post a Comment