By the time you have completed this work, you should be able to:
In this assignment, you will implement key components of a library that manipulates images. Further details about the concepts used in the library are available here.
Download the template code below.
There is only one file you need to modify in the template code: fi.scala
.
In fi.scala
, you will need to implement a number of methods (defined with def
) and functions (which are bound to val
definitions).
These have been marked in the code with the following comment:
// !!FILL ME IN
Unlike with previous assignments, the template file does not contain signatures for the components you need to implement.
Merely writing the signatures is considered part of this assignment.
We recommend implementing these signatures first, with implementations of ???
.
This way, your code will be compiling relatively quickly.
As a hint with implementing the signatures, the provided test suite in tests.scala
calls these components, so you can see what a correct call looks like.
Some of the components require you to implement curried methods.
If you are unclear on what curried methods are and how to define them, you should revisit 012_currying.scala
in Assignment 1's Scala tutorial.
Once you have the signatures implemented, you should move on to giving these components implementations. Types are tremendously helpful for this purpose, as in most cases it is possible to derive correct implementations even without a complete understanding of the problem. We have a written up a short guide on how to best use types for this purpose, which is available here.
Your code can be compiled like so:
scalac -cp swing.jar *.scala
A small test suite has also been provided; this can be run like so (once your code is compiled):
scala -cp swing.jar:. Tester
The code you are writing ultimately is used to produce images. These images can be created in batch with the following command:
scala -cp swing.jar:. SaveAll
Once the images can be created, they can be compared to provided reference images like so:
./compare.sh
The above command will produce no output if all the images match up.
A breakdown of the grade follows (out of 100 points):
lift0
lift1
lift2
lift3
lerpImgClr
overlayImgClr
selectImgClr
msk2clr
gray2clr
translatePt
scalePt
rotatePt
swirlPt
polarXf
translate
scale
rotate
swirl
fullM
emptyM
notM
intersectM
unionM
xorM
diffM
You must use turnin
to turn in all of your code.
The command below will work for this purpose:
turnin assign4@cs162 fi.scala
As a reminder: with fi.scala
, you may not use any mutable state.
This is to encourage you to think in a functional way, rather than to write Java/Python with a new syntax.