Part B -- Representing Numbers with Rectangles Using PyCharm, use lab11b.py: For this part of the lab, you will modify t
Posted: Mon May 09, 2022 6:02 am
Part B -- Representing Numbers with Rectangles
Using PyCharm, use lab11b.py:
For this part of the lab, you will modify the complete version
of lab10 that you copied in lab11b.py to draw a
rectangle to represent each input number. Then, you repeatedly
accept user's mouse-clicks and if the point of the click is in a
rectangle, you color it 'darkblue'. Here is a demo.
How to do it
Let's use some constant literals.
Each input value, v, will be represented by a
rectangle whose bottom y is base_line_y, its height
is v * height_multiplier, and its width
is rectangle_width. Two adjacent rectangles are
separated by gap_between_rectangles pixels. You
should define the following functions to help you with the
implementation.
A few notes...
As you have noticed, to create an instance of
the Text object, you need an anchor
point and the text to be drawn. If you were to draw a
rectangle around the text that is drawn in the window,
the anchor point is at the center of this
rectangle. In this example, we have placed a red circle at the
anchor point of the text to show this concept.
I need help with this python pseudo-code above,
please!
Using PyCharm, use lab11b.py:
For this part of the lab, you will modify the complete version
of lab10 that you copied in lab11b.py to draw a
rectangle to represent each input number. Then, you repeatedly
accept user's mouse-clicks and if the point of the click is in a
rectangle, you color it 'darkblue'. Here is a demo.
How to do it
Let's use some constant literals.
Each input value, v, will be represented by a
rectangle whose bottom y is base_line_y, its height
is v * height_multiplier, and its width
is rectangle_width. Two adjacent rectangles are
separated by gap_between_rectangles pixels. You
should define the following functions to help you with the
implementation.
A few notes...
As you have noticed, to create an instance of
the Text object, you need an anchor
point and the text to be drawn. If you were to draw a
rectangle around the text that is drawn in the window,
the anchor point is at the center of this
rectangle. In this example, we have placed a red circle at the
anchor point of the text to show this concept.
I need help with this python pseudo-code above,
please!