exam questions

Exam 70-480 All Questions

View all questions & answers for the 70-480 exam

Exam 70-480 topic 3 question 35 discussion

Actual exam question from Microsoft's 70-480
Question #: 35
Topic #: 3
[All 70-480 Questions]

HOTSPOT -
You develop an interactive scalable vector graphics (SVG) application. You write the following HTML markup that makes a rectangle rotate:

You need to control the speed of the rotating rectangle.
How should you complete the relevant code? (To answer, select the appropriate option from each drop-down list in the answer area.)
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
Note:
* What is SVG?
SVG stands for Scalable Vector Graphics
SVG is used to define vector-based graphics for the Web
SVG defines the graphics in XML format
SVG graphics do NOT lose any quality if they are zoomed or resized
Every element and every attribute in SVG files can be animated

SVG is a W3C recommendation -
* Example:
<script>
/* CONSTANTS */
var initialTheta = 0; // The initial rotation angle, in degrees. var thetaDelta = 0.3; // The amount to rotate the square every "delay" milliseconds, in degrees. var delay = 10; // The delay between animation stills, in milliseconds. Affects animation smoothness. var angularLimit = 90; // The maximum number of degrees to rotate the square.

/*
Note that it will take the square (angularLimit/thetaDelta)*delay milliseconds to rotate an angularLimit number of degrees. For example, (90/0.3)*10 = 3000 ms (or 3 seconds) to rotate the square 90 degrees.
*/

/* GLOBALS */
var theSquare; // Will contain a reference to the square element, as well as other things. var timer; // Contains the setInterval() object, used to stop the animation.

function init()
/*
Assumes that this function is called after the page loads.
*/
{
theSquare = document.getElementById("mySquare"); // Set this custom property after the page loads. theSquare.currentTheta = initialTheta; // The initial rotation angle to use when the animation starts, stored in timer = setInterval(doAnim, delay); // Call the doAnim() function every "delay" milliseconds until "timer" is cleared.
}

function doAnim()
/*
This function is called by setInterval() every "delay" milliseconds.
*/
{
if (theSquare.currentTheta > angularLimit)
{
clearInterval(timer); // The square has rotated enough, instruct the browser to stop calling the doAnim() function. return; // No point in continuing; stop now.
}

theSquare.setAttribute("transform", "rotate(" + theSquare.currentTheta + ")"); // Rotate the square by a small amount. theSquare.currentTheta += thetaDelta; // Increase the angle that the square will be rotated to, by a small amount.
}
</script>
</head>

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Joshua
Highly Voted 5 years, 8 months ago
you would use document.getElementById("mySquare");
upvoted 8 times
...
Bennyseems
Highly Voted 5 years, 4 months ago
Kyrylx is nearly there, but it should be: document.getElementById("mySquare"); as others have said. https://www.w3schools.com/code/tryit.asp?filename=GCDVRWT2KSRO
upvoted 5 times
...
ichbin
Most Recent 5 years, 4 months ago
What is correct here in the end?
upvoted 1 times
...
KyryIx
5 years, 5 months ago
var squareShape; var myTimer; function startAnimation(){ squareShape = mySquare; //squareShape = document.getElementById("mySquare"); squareShape.currentTheta = 0; //myTimer = speed.value; //myTimer = myTimer.interval( speed.value ); //myTimer = setTimer( animateImage, speed.value ); //myTimer = new timer( animateImage, speed.value ); myTimer = setInterval( animateImage, speed.value ); animateImage(); } function animateImage(){ squareShape.setAttribute( "transform", "rotate(" + squareShape.currentTheta + ")" ); squareShape.currentTheta += 0.1; }
upvoted 3 times
...
Joshua
5 years, 7 months ago
Think the other two are wrong too. It should be rotate
upvoted 4 times
...
Etnic
5 years, 8 months ago
agreee document.getElementById("mySquare");
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...