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

  How would i write a shell script to locate executable files

How would I write a shell script to locate executable files? This script takes a list of file names from the command line and determines which would be executed had these names been given as commands.

  Create class for hardware store to represent invoice

Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables a part number.

  Determine single vs double compartment model

The following plasma concentrations (in ug/ml) of a new drug were recorded in a patient. Is this data best fit by a single or double compartment model?

  Problem related to reading file and doing averege

First the program must read a text file (The user must be able to write the name of the text file) , the text file contains the following: the expenses the company is going to spend. Text file example: Keywords:, #best_project_ever, Expenses:, Equi..

  Create an application in which a user can enter a phone book

Create an application in which a user can enter a phone book entry, including the following elements

  Statement to read variables of type double

Suppose two variables p1 and p2 of type POINT, with two fields, x and y, both of type double, have been declared. Write a statement that reads values for p1 and p2 in that order.

  Program to execute on cse unix environment

Your program should be written in C++, execute correctly on CSE unix environment, and compile using g++ compiler using makefile.

  Demonstrate that you can read and understand code

What will the code output when run - What are individualScores, bonusScore, baseScore, and teamScore? What do you think the difference is between the keywords let and var?

  Develop a program to determine the final scores

In this project, you will develop a program to determine the final scores, letter grades, and rankings of all students in a course. All records of the course will be stored in an input file, and a record of each student will include the first name..

  Write an application that prints out the receipt

Write an application that prints out the receipt details for these shopping baskets...

  Create a java application to convert english to pig latin

Create a java application to convert English words to pig Latin using the above rules.

  Clear description of the program

Program Description- A detailed, clear description of the program you are building. Analysis- Demonstrates your thought process and steps used to analyze the problem. Be sure to include the required input and output and how you will obtain the req..

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