HTML5 vs Flash Drawing (JavaScript vs ActionScript 3) { William Malone }

Drawing with JavaScript in HTML5 vs ActionScript 3 in Flash

by William Malone

HTML5 introduces an element called a “canvas” on which we can use JavaScript to draw. This offers a quick and easy approach to drawing dynamic content. This article will compare this relatively new (and not yet cross-browser compatible) option for drawing to Adobe Flash’s ActionScript 3. JavaScript and ActionScript have common roots as they are both dialects of ECMAScript.

For this article we are going to draw something with a little complexity to better compare the two languages. I have chosen a warning icon I made in Photoshop.

An Initial Difference

As we dive right into the code try not to be too concerned about the math. The point of this article is not to explain the trigonometry behind a triangle, just to compare how we draw the triangle. That said, the first thing we do is declare a few variables.

The code is similar in both languages, but two differences appear immediately and will be consistent throughout this article:

Basic Shape: A Triangular Path

The icon we are drawing has three major components:

Since both JavaScript and ActionScript support paths, we will use paths to define our shapes. Let us start with the background. It is a triangle consisting of three points.

Triangular path with points

Although beginning a path is slightly different, both JS and AS3 use the methods moveTo and lineTo.

To add a little complexity, let’s round the corners of the triangle (and we are not going to take the stroke shortcut I used in in my previous article: HTML 5 Canvas Example).

To round the corners we will use Bézier curves, which are supported by both languages. The type of Bézier curve will be quadratic (opposed to cubic). Quadradtic Bézier curves have two anchor points; the curve of the line between them is defined by one control point (Cubic Bézier curves have two control points).

Adding a pair of control points at each corner will give a rounded effect.

Rounded and non-rouned corner triangular path

JavaScript uses the method quadraticCurveTo on the HTML5 canvas to create the control point. ActionScript 3 uses the method curveTo.

Create the Inner Stroke Path

Next we create a smaller triangle within our first triangle. Later we will stroke it and utilize standard properties to curve the border of our stroke for us.

Triangular Inner Path to Stroke

Bang!

With any icon, we have a message. The warning standard is an exclamation point (aka a “bang” character) which we add in the center of our icon. We could use a text representation but we will not do that for a various reasons (the user might not have that font, the size cost for embedding an entire typeface just for one character is not worth it, etc.)

exclamation point path

Again the major difference between the two approaches are the methods quadraticCurveTo versus curveTo.

Exclamation ‘Point’

To finish our bang character, we add a circle:

JavaScript and ActionScript have more efficient ways to create circles including the methods arc and drawCircle respectively.

Draw Inside the Lines

The paths are complete:

In JavaScript and ActionScript and you won’t actually see the path until assign a fill or stroke to them. The following code defines what the fills and strokes will look like:

Draw

JavaScript applies the path fills on the HTML5 Canvas as each one is completed. ActionScript 3 can apply all path fills and strokes all at one time using the method drawGraphicsData.

We see the results below:

A Subtle Shadow

We are almost there, but there is something missing. Let’s add a subtle shadow.

Related posts

Trump’s 2020 attack strategy: Smear Biden over mental fitness
By Eric Bradner, Ryan Nobles and Dan Merica, CNN

President Donald Trump and his allies have zeroed-in on an attack against Joe Biden, going after the presumptive Democratic governmental nominee’s mental physical fitness in a coordinated effort using smears and innuendo to paint him as ill-quipped to be President of the United States.

Trump for months has questioned the mental skill of the opponent he calls “Drowsy Joe.” Trump last week described Biden as “a sleepy person in a basement of a home,” and he has actually repeatedly recommended that Biden did not personally write declarations issued by his project criticizing Trump’s handling of the coronavirus pandemic.

His project and the Republican National Committee have progressively focused its attacks on Biden’s tendency for on-camera verbal stumbles in recent weeks, as it looks for to define Biden after he emerged triumphant from the Democratic primary.

One example came previously this month, when Trump’s campaign launched an ad comparing Biden and Vermont Sen. Bernie Sanders, which closed with the line: “At least Bernie remembers his positions.”

https://twitter.com/parscale/status/1247928262036258816

The attacks are an early demonstration of how Trump will utilize the full Republican politician Celebration apparatus to run a scorched-earth campaign based upon personal insults and unwarranted insinuations– a heightened variation of his playbook from 2016, when Trump and his allies, without proof, called into question Hillary Clinton’s health. They have actually become a daily occurrence from Trump’s campaign, assistants and Republican allies throughout every medium possible– on social media, in campaign e-mail blasts and videos and on Trump-aligned media companies like Fox News.

Biden’s advisers and Democratic allies mention that Trump is guilty of many of the same verbal tics he is attacking Biden over, and often lies and embraces conspiracy theories.

As one Biden ally put it: “Has Trump taken his own guidance and downed a gallon of bleach yet?”

The attacks weaponize Biden’s propensity to stumble over words, utilize the wrong word or interrupt himself in the middle of long answers by stating, “anyhow,” and altering course. To fans of a former vice president who in December 2018 called himself a “gaffe maker,” those long-time spoken tics have always belonged to Biden’s public persona. They are made more forgivable to his advocates by Biden’s openness about conquering a stutter.

Aside from periodic jousts amongst assistants on Twitter, Biden’s project has mostly neglected the Trump project’s attacks.

Biden-world’s view is that the political and media landscape has actually shifted because 2016, when every Trump attack on a rival was treated as novel and took command of the project narrative on social media and cable news.

His consultants pointed to Trump’s stopped working efforts to guide the political discussion in the 2017 Virginia governor’s race, when he and his GOP allies cautioned of the MS-13 gang, in addition to the 2018 midterms, when Trump’s message concentrated on caravans of refugees approaching the US-Mexico border.

” The misapprehension that whatever Trump wishes to speak about is inherently efficient and that he gets to act as the media’s at-large task editor has actually been closed,” a Biden consultant said.

As Biden has adapted to marketing in the age of coronavirus– knocked off the campaign path and rather transmitting occasions and interviews from a transformed rec room in his basement in Delaware– Trump’s project is seizing on every on-camera miscue, with conservative Trump allies such as Fox News host Sean Hannity then magnifying them.

” His sharpness, or absence thereof is on screen every day, every time he talks,” Trump project spokesperson Tim Murtaugh informed CNN in response to concerns about the technique. “His failure to keep a train of thought going is obvious.”

Biden frequently looks down at his notes, which Trump’s allies have actually mischaracterized as Biden dropping off to sleep. Trump’s boy Eric Trump tweeted a seven-second video from Biden’s online broadcast with Hillary Clinton on Tuesday, along with the hashtag “#SleepyJoe.”.

https://twitter.com/EricTrump/status/1255213748811374596.

Robby Mook, Hillary Clinton’s 2016 campaign supervisor, said Trump “always projects his biggest weakens on his challenger in an attempt to deflect criticism from himself.”.

” What is very clear is the White Home thinks his presidency will be evaluated on how properly he is managing coronavirus, so it makes ideal sense that he is now attempting to accuse his challenger of incompetence, which is ridiculous.”.

The attacks resemble how Trump’s campaign pursued Clinton in 2016, Mook noted. Trump and his campaign frequently cast the former secretary of state as sick or unhealthy, a technique that was further elevated after Clinton stumbled after a September 11 occasion in New York due to concealed pneumonia.

” I simply see a pattern regularly from 2016 all the way through now, which is, he attempts to predict his most significant issues onto his opponents so he gives the media a false equivalence to attempt to muddy the water,” Mook stated. “Part of the factor he was so obsessed with calling Hillary Clinton dishonest is because he is probably the most deceitful individual to win the White Home.”.

Biden advisers argue that Trump’s efforts to caricature Biden won’t overcome the same qualities that insulated him in the Democratic primary: After 5 decades in the public eye and eight years as President Barack Obama’s No. 2, voters feel like they know him.

Biden frequently expresses distaste for attacks on his rivals’ character. His aides say that by questioning Biden’s mental capability, the President is guiding the project toward concerns of character and fitness.

” This is asinine to tee up– since it’s 10,000 times even worse for him,” a Biden adviser stated.

As an example of how easily Trump could be parodied, Biden’s assistants indicated a video from The Daily Show in which Fox News hosts and analysts’ comments about Biden’s mental skill were interspersed with videos of Trump’s own verbal flubs.

Biden spokesman Andrew Bates tweeted The Daily Program’s video, which has been seen 3.6 million times on Twitter, on March 25, in action to Trump spokesperson Matt Wolking tweeting: “When is the last time Joe Biden was lucid?”.

https://twitter.com/AndrewBatesNC/status/1242886701002960896.

” Triggering voters to assess prospects’ mental states is a devastating proposal for Donald Trump, so we’re never going to prevent him from going there,” Bates said.
– CNNPolitics.

Trump’s 2020 attack strategy: Smear Biden over mental fitness By Eric Bradner, Ryan Nobles and Dan Merica, CNN President Donald Trump and his allies have zeroed-in on an attack against Joe Biden, going after the presumptive Democratic governmental nominee’s mental physical fitness in a coordinated effort using smears and innuendo to paint him as ill-quipped to be President of the United States. Trump for months has questioned the mental skill of the opponent he calls “Drowsy Joe.” Trump last week described Biden as “a sleepy person in a basement of a home,” and he has actually repeatedly recommended that Biden did not personally write declarations issued by his project criticizing Trump’s handling of the coronavirus pandemic. His project and the Republican National Committee have progressively focused its attacks on Biden’s tendency for on-camera verbal stumbles in recent weeks, as it looks for to define Biden after he emerged triumphant from the Democratic primary. One example came previously this month, when Trump’s campaign launched an ad comparing Biden and Vermont Sen. Bernie Sanders, which closed with the line: “At least Bernie remembers his positions.” https://twitter.com/parscale/status/1247928262036258816 The attacks are an early demonstration of how Trump will utilize the full Republican politician Celebration apparatus to run a scorched-earth campaign based upon personal insults and unwarranted insinuations– a heightened variation of his playbook from 2016, when Trump and his allies, without proof, called into question Hillary Clinton’s health. They have actually become a daily occurrence from Trump’s campaign, assistants and Republican allies throughout every medium possible– on social media, in campaign e-mail blasts and videos and on Trump-aligned media companies like Fox News. Biden’s advisers and Democratic allies mention that Trump is guilty of many of the same verbal tics he is attacking Biden over, and often lies and embraces conspiracy theories. As one Biden ally put it: “Has Trump taken his own guidance and downed a gallon of bleach yet?” The attacks weaponize Biden’s propensity to stumble over words, utilize the wrong word or interrupt himself in the middle of long answers by stating, “anyhow,” and altering course. To fans of a former vice president who in December 2018 called himself a “gaffe maker,” those long-time spoken tics have always belonged to Biden’s public persona. They are made more forgivable to his advocates by Biden’s openness about conquering a stutter. Aside from periodic jousts amongst assistants on Twitter, Biden’s project has mostly neglected the Trump project’s attacks. Biden-world’s view is that the political and media landscape has actually shifted because 2016, when every Trump attack on a rival was treated as novel and took command of the project narrative on social media and cable news. His consultants pointed to Trump’s stopped working efforts to guide the political discussion in the 2017 Virginia governor’s race, when he and his GOP allies cautioned of the MS-13 gang, in addition to the 2018 midterms, when Trump’s message concentrated on caravans of refugees approaching the US-Mexico border. ” The misapprehension that whatever Trump wishes to speak about is inherently efficient and that he gets to act as the media’s at-large task editor has actually been closed,” a Biden consultant said. As Biden has adapted to marketing in the age of coronavirus– knocked off the campaign path and rather transmitting occasions and interviews from a transformed rec room in his basement in Delaware– Trump’s project is seizing on every on-camera miscue, with conservative Trump allies such as Fox News host Sean Hannity then magnifying them. ” His sharpness, or absence thereof is on screen every day, every time he talks,” Trump project spokesperson Tim Murtaugh informed CNN in response to concerns about the technique. “His failure to keep a train of thought going is obvious.” Biden frequently looks down at his notes, which Trump’s allies have actually mischaracterized as Biden dropping off to sleep. Trump’s boy Eric Trump tweeted a seven-second video from Biden’s online broadcast with Hillary Clinton on Tuesday, along with the hashtag “#SleepyJoe.”. https://twitter.com/EricTrump/status/1255213748811374596. Robby Mook, Hillary Clinton’s 2016 campaign supervisor, said Trump “always projects his biggest weakens on his challenger in an attempt to deflect criticism from himself.”. ” What is very clear is the White Home thinks his presidency will be evaluated on how properly he is managing coronavirus, so it makes ideal sense that he is now attempting to accuse his challenger of incompetence, which is ridiculous.”. The attacks resemble how Trump’s campaign pursued Clinton in 2016, Mook noted. Trump and his campaign frequently cast the former secretary of state as sick or unhealthy, a technique that was further elevated after Clinton stumbled after a September 11 occasion in New York due to concealed pneumonia. ” I simply see a pattern regularly from 2016 all the way through now, which is, he attempts to predict his most significant issues onto his opponents so he gives the media a false equivalence to attempt to muddy the water,” Mook stated. “Part of the factor he was so obsessed with calling Hillary Clinton dishonest is because he is probably the most deceitful individual to win the White Home.”. Biden advisers argue that Trump’s efforts to caricature Biden won’t overcome the same qualities that insulated him in the Democratic primary: After 5 decades in the public eye and eight years as President Barack Obama’s No. 2, voters feel like they know him. Biden frequently expresses distaste for attacks on his rivals’ character. His aides say that by questioning Biden’s mental capability, the President is guiding the project toward concerns of character and fitness. ” This is asinine to tee up– since it’s 10,000 times even worse for him,” a Biden adviser stated. As an example of how easily Trump could be parodied, Biden’s assistants indicated a video from The Daily Show in which Fox News hosts and analysts’ comments about Biden’s mental skill were interspersed with videos of Trump’s own verbal flubs. Biden spokesman Andrew Bates tweeted The Daily Program’s video, which has been seen 3.6 million times on Twitter, on March 25, in action to Trump spokesperson Matt Wolking tweeting: “When is the last time Joe Biden was lucid?”. https://twitter.com/AndrewBatesNC/status/1242886701002960896. ” Triggering voters to assess prospects’ mental states is a devastating proposal for Donald Trump, so we’re never going to prevent him from going there,” Bates said. – CNNPolitics.

Authentication failed. No user with this email address found. This content was originally published here.

Posted

Leave a Reply