Generate a specified number of solid colour square

Assignment Help Programming Languages
Reference no: EM131061972

Task 1 - Square Tile Generator

Define a function createSquareTile(numTiles, prefix) which generates a specified number of solid colour square tile pictures with the size and colour of each picture specified by the user. It accepts two input parameters:

  • numTiles - int, the number of square tiles to be created.
  • prefix - str, the prefix of the file names for the square tiles to be generated.

The function MUST follow the program flow on page 4. For each square tile being generated, the function should create a JPEG file using the specified prefix. For example, createSquareTile(3, "tile") will create three files named tile1.jpg, tile2.jpg and tile3.jpg. Depending on the size and colour specified by the user for each tile, the generated pictures may look like:

569_figure.jpg

 

Note: In a solid colour picture, every pixel has the exactly same colour.

Task 2 - Tint a Picture in a Circular Region Using a Colour Gradient

Define a function gradTintPicInCircle(bgPic, solidPic1, solidPic2, intensity, centreX, centreY, radius) that applies a tint, based on a colour gradient, to a specified circular region over a background picture. This function will return the tinted background picture as a Picture object, and accepts the following 8 input parameters:

  • bgPic - Picture, the background picture to be tinted.
  • solidPic1 - Picture, the 1st solid colour picture that provides the starting colour of the colour gradient. In this assignment, you should always use a solid colour picture generated by Task 1.
  • solidPic2 - Picture, the 2nd solid colour picture that provides the ending colour of the colour gradient. In this assignment, you should always use a solid colour picture generated by Task 1.
  • intensity - int, the strength of the tint in percentage. For example, a value of 30 means 30%.
  • centreX - int, the centre position of the circular region on the X axis of the background picture.
  • centreY - int, the centre position of the circular region on the Y axis of the background picture.
  • radius - int, the radius of the circular region.

To tint a background picture using one colour (rtint, gtint, btint), the colour of each pixel in the tinted background picture is calculated by:

rbgtint = rbg + (rtint - rbg) x intensity/100.0

gbgtint = gbg + (gtint - rbg) x intensity/100.0

bbgtint = bbg + (btint - bbg) x intensity/100.0

To tint a background picture using a colour gradient, the tint colour to be applied to a pixel in the background picture depends on the coordinate of that pixel in the background picture and should be calculated accordingly.

You may think of this process as firstly creating a colour gradient picture of the same size to the background picture and then using the colour of each pixel in the created colour gradient picture to tint the corresponding pixel in the background picture.

This function requires the colour gradient to be defined from right to left with respect to the background picture, which means the starting and ending colours of a colour gradient should be applied to the rightmost and leftmost columns of the background picture, respectively. Furthermore, the tint should ONLY be applied to the pixels within the specified circular region.

Below are three sample pictures created by invoking function gradTintPicInCircle using different inputs. The pictures on the left and in the middle used the provided RMIT building picture as the background picture. The picture on the right used an empty canvas as the background picture to better visualize the tint effect. Note: The specified circular region may exceed the border of the background picture as illustrated by the middle picture.

770_figure1.jpg

Skeleton Code

You MUST use the provided skeleton code and follow its instructions to complete this assignment. In the skeleton code, there is a predefined main function and two incomplete function definitions. You should complete these two incomplete function dentitions so that when function main is executed, it generates three square tile pictures using createSquareTile and three tinted pictures using gradTintPicInCircle.

Demonstration (Week 11 or 12)

The whole assignment group must demonstrate the assignment in your allocated tute/lab class prior to the final submission. If two group members come from different classes, please choose one of the two classes to make the demonstration. Subject to the on-time final submission and the plagiarism detection, you will receive preliminary marks for your demonstration, and each member must be able to clearly explain the entire program.

You may choose to demonstrate your code in Week 11 or Week 12 and you must make your final code submission by 11:59pm May 27 (Friday) 2016.

Program Flow for Task 1

You should follow the following program flow to define function createSquareTile:

Based on the specified numTiles, loop numTiles times. In each iteration,

1. Check if it is the very first iteration (i.e. the first tile to be created):

a. For the first iteration, ask the user for an integer using a dialog popup with the following message:

Please enter the size of Tile 1:

If the entered size is non-positive, display an error message via a dialog popup and then repeat Step 1-a.

b. For subsequent iterations, ask the user the following question using a dialog popup:

Same size as the previous tile? (Y/N):

i. If the answer is "Y", use the size of the previous tile and go to Step 2.

ii. If the answer is "N", ask the user to enter the size of the tile to be created:

Please enter the size of Tile #: (Replace # with the tile number)

If the entered size is non-positive, display an error message via a dialog popup and then repeat Step 1-b-ii.

iii. If the answer is neither "Y" or "N", display an appropriate message via a dialog popup and then repeat Step 1-b.

2. Ask the user to pick a colour using a colour picker popup.

3. Create a new Picture object based on the specified size and colour.

4. Save the created Picture object as a JPEG file based on the specified prefix, for example, when the prefix is "image", the 3rd square tile being created will be named "image3.jpg".

There will be no program flow provided for Task 2. Should you need any help, please discuss with your assignment partner (if applicable) or seek assistance from your tutor in the practical class.

Reference no: EM131061972

Questions Cloud

Variable under consideration has a density curve : Provide an appropriate response. Assume that the variable under consideration has a density curve. The area under the density curve that lies to the right of 16 is 0.536. What percentage of all possible observations of the variable are at most 16?
Find the indicated binomial probability : Find the indicated binomial probability. Round to five decimal places when necessary. In a certain college, 20% of the physics majors belong to ethnic minorities. If 10 students are selected at random from the physics majors, what is the probabili..
Determine the force p required to move the cabinet to right : the largest allowable value of h if the cabinet is not to tip over.
Review the information on america''s health rankings website : Review the information on America's Health Rankings website for Arizona. Keeping all of the elements of health literacy in mind (language barriers, numeracy, reading comprehension, tone, and verbiage), write a press release/news article for the ge..
Generate a specified number of solid colour square : COSC1519 Introduction to Programming - Define a function createSquareTile(numTiles, prefix) which generates a specified number of solid colour square tile pictures with the size and colour of each picture specified by the user.
Find the area under the standard normal curve : 1) Find the area under the standard normal curve that lies between z = -2.4 and z= 1
Group of students and the expected value : A study of 600 college students taking Statistics 101 revealed that 54 students received the grade of A. Typically 10% of the class gets an A. The difference between this group of students and the expected value is not significant at the 0.05 leve..
Express in terms w and r the magnitude of the largest couple : The cylinder shown is of weight W and radius r. Express in terms W and r the magnitude of the largest couple M that can be applied to the cylinder if it is not to rotate,
Compute the mean annual percent increase in net sales : From 1982 to 2003 the net sales for the J.M Smucker company increased from $157 million to $687 million compute the mean annual percent increase in net sales.

Reviews

Write a Review

Programming Languages Questions & Answers

  Program-compute monthly interest-print next balance for sav

Set annual interest rate to 4% then compute monthly interest and print next balance for both savers. Then set annual interest rate 5%. Compute next month interest and print next balance for both savers.

  Explain calling functions and pass functions by value

I need to create 2 functions which passe their values when they are called in main.

  Provide proper indentation and programming style

Provide proper documentation as required in the PAs, Provide proper indentation & programming style similar to the examples from the textbook, videos & PAs

  How many time is loop body of while statement executed

How many time is the loop body of the while statement executed? a) once, b) never, c) 49 times, d) 50 times, e) until a number 50 or larger is entered

  Create program to enter number of packages bought

Create a program which asks user to enter number of packages bought . The program must then display amount of discount (if any) and total amount of purchase after the discount.

  Application to make a guessing game

The number I guess should be compared with the random generated number. If I guess correctly, the second field could display a message like "you win", else it should display "more" or "less" depending on my guess. If I fail to guess those 5 times,..

  What is the difference between re-locatable program

What is the difference between re-locatable program and re-locatable data?, Explain the working of increment and decrement instruction ?

  Design and run a program that takes a numerical score

Design and run a program that takes a numerical score and outputs a letter grade. Precise numeral scores and letter grades are listed show.

  Create a file values.txt contains the data

Make sure your program is clear with no syntactical errors, correctly uses i/o syntax, correctly uses branching and looping syntax, that it contains functions with correct parameters and return values, that it correctly uses arrays, and that you p..

  Write program to permit user to enter last names

Write down the program which permits the user to enter last names of five candidates in local election and number of votes received by each candidate.

  Creates an object from the person class

Which of the following creates an object from the Person class?

  Define and create an exception

Quotient throws an exception to the higher-level function main to decide whether or not the program should be terminated. Main catches the divByZero and prints out an appropriate comment on the screen. Also include in main a try block to catch the..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd