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

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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