Subtraction blending mode

Report a typo

There are several simple blending modes based on basic arithmetic operations, like the Addition, Subtraction, Difference, and Divide blending modes.

Here, you will implement the Subtraction blending mode to write the code for the subtractionBlend() function. It reads two lines from stdin, each with 3 integers: Red, Green, and Blue (separated by a space). Each line represents the color components for a Color instance.

To produce each target color component, the two respective input values are subtracted one from the other (the second value from the first one). For example, the target color component red is calculated as red = c1.red - c2.red. If the sum is less than 0, then the color component is set to the value of 0.

Your function should print the 3 color components of the target pixel as integers (separated by a space).

Sample Input 1:

255 20 30
100 40 10

Sample Output 1:

155 0 20
Write a program in Kotlin
fun subtractionBlend() {
// Write your code here

//
}
___

Create a free account to access the full topic