How Much Math Do You Need To Know For Javascript PIM Team Case Study – Creating Text Effects With PHP And GD

You are searching about How Much Math Do You Need To Know For Javascript, today we will share with you article about How Much Math Do You Need To Know For Javascript was compiled and edited by our team from many sources on the internet. Hope this article on the topic How Much Math Do You Need To Know For Javascript is useful to you.

PIM Team Case Study – Creating Text Effects With PHP And GD

See how you can create graphic effects in text with PHP and GD: shadows, arcs, fonts and colors.

problem

A-tec Signs and Graphics Inc. launched a website with the idea of ​​selling stickers online. To achieve better customer interest, the website had to integrate the online label maker. The company also offers vehicle decals that brought some specific requirements to the builder, such as the decal text revolving around 4 types of arcs.

goals

  • Provide users with a preview area
  • It allows visitors to choose the font and color
  • Allows you to add shadow and select the shadow color
  • Allows you to convert text into arcs
  • Real-time calculation

solution

Due to the need to increase customer interest, we had to think not about perfect mathematical formulas when displaying the graphics in the preview area, but about the people who will look at them.

As we will reveal below, there were few problems surrounding human appreciations of something “perfectly smooth” and perfect figures.

Methodology

We were going to use the PHP GD library extensively for the text effects. It provided easy changing of fonts and colors, adding shadows and rotating texts.

We also had to create color palettes that would appear when the user clicked and disappear when the color was selected (you can try creating stickers yourself here). Using hidden layers and javascript should do the job.

The main problem with this site was creating 4 types of arcs, so when the user selects one, the text is created around an imaginary arc (like in vector graphics programs). We were going to study Bezie’s formulas and create these arcs with their help.

Implementation

The PIM Bulgaria team was tasked with creating the fully functional online sticker creator with the following features:

– Background decal

Some users were supposed to have their stickers placed on colored backgrounds. We had to allow the preview area to be painted with a selected background. First we created the image in the temporary folder:

</p> <p> // the name of the destination image $dest=&#8217;decals/&#8217;.time().&#8217;.jpg&#8217;; //the background image filled rectangle ( $im, 0, 0, 590, 60, $colors[$_POST[&#8216;bcolors&#8217;]]);</p> <p>

The $colors array contains the available color that the administrator stores in the database.

So when the visitor selects a background, it is passed as a parameter to the image filled rectangle function.

– Selection of sources

Users should be able to select fonts for their future stickers. Knowing that we cannot assume that all sources will be available on all visitors’ computers, we had to upload them to the web server directory.

We allowed the admin to manage the fonts, adding their names and uploading files in the admin area.

Fonts in the selection box came from the database. The selected font was passed to the imagettftext calling function which is based on the previously created image.

– Color selections

Color selections were supposed to be palettes that appear when the user clicks and disappear when the color is selected. The palette should look like a table with colors and these colors are also defined in the

the admin area, so they had to come dynamically. We had to seed a static javascript function with dynamic content.

We created a PHP loop that was getting the colors from the database and then creating a string for the HTML table. This table is then passed to a javascript function that creates the palettes with the help of hidden layers:

</p> <p> function showTable(table) mouseX = window.event.x + document.body.scrollLeft+25; if(table==&#8217;background&#8217;) var content=&#8221;&#8221;; var y=460; if(table==&#8217;sources&#8217;) var content=&#8221;&#8221;; var y=690; if(table==&#8217;shadows&#8217;) var content=&#8221;&#8221;; var y=810; document.getElementById(&#8216;table&#8217;).style.pixelLeft=mouseX; document.getElementById(&#8216;table&#8217;).style.pixelTop=y; document.getElementById(&#8216;table&#8217;).style.visibility=&#8217;visible&#8217;; document.getElementById(&#8216;table&#8217;).innerHTML=content; </p> <p>

Of course, once the user selected the desired color we had to hide the palette:

</p> <p> function setColor(elid,color,fromid,shc) document.getElementById(elid).value=color; document.getElementById(&#8216;table&#8217;).style.visibility=&#8217;hidden&#8217;; </p> <p>

So we’ve created nice palettes that appear and disappear with a single click and don’t take up much screen space.

– Let go of Shawdows

The stickers offered have the ability to add a shadow, so we had to add that option to the online creator. However, PHP didn’t provide a nice function for this. We created a procedure that draws the texts twice: once the original 100% saturated text and once the shadow with a percentage of the color and the appropriate offset. Of course, the shadow was drawn on the image before the main text.

</p> <p> @imagettftext($img, 20, $gr[$i]$x+$dx, $ys[$i]+$dy, $scolors[$shadowcolor]&#8221;sources/&#8221;.$_POST[&#8216;fonts&#8217;],$word[$i]); </p> <p>

– Arches

The main problem came when we had to “rotate” the texts by arcs. First we created the perfect Bezie function to draw the curves and adjust the font above it. But what a surprise: the curves looked perfect on their own, but when we adjusted the letters on top of them they looked rough.

After looking into this problem, we realized that the approximate resolution of the screen and the disability to anti-alias the images would not allow us to create nice arcs. We were faced with an intractable problem.

We decided to create a few arcs with a graphics software (CorelDraw) and see what could be wrong.

We noticed that Corel’s curves looked great after adjusting them manually. However, you can’t leave the program to create perfect curves automatically. It took a human eye to judge when a curve looked right and when it didn’t.

We have a totally different direction. There was no universal function to help us. The solution we found was to “manually” adjust each letter. We created a procedure with cases that were fitting each letter in the right place and with the right rotation based on the length of the text. It worked!

We created 2 arrays for each arc type: an array with the positions and an array with the rotations.

The rest was simple:

</p> <p> if($arctype) $start=(35-$l)/2; if($start%2) $start+=1; $gr=array_slice($gr,$start,$l); $ys=array_slice($ys,$start,$l); if(!$arctype) { $ys=array(); $gr=array(); //creating the arrays for ($i=0;$i</p> <p>

You can go to the atec site and try the decals we got (http://atecsigns.com/decal/step_1.php).

results

Now the A-tec Sings web creator creates perfect stickers with graphics, calculates the price and allows you to add the stickers to your shopping cart and remove them (the shopping cart software is also created by PIM Team Bulgaria ).

The builder allows the visitor to create the desired stickers with any color, drop shadow, background and shape, view them and calculate the cost for different sizes and quantities.

The website and builder were promoted with a massive radio advertising company. At that time it was the only decal builder that allowed text to be created around arches.

Conclusions

  • Use GD to create text effects
  • Don’t forget that you can create your own functions for what GD doesn’t offer
  • Don’t always look for perfect mathematical formulas. Graphical effects are intended for the human eye
  • Upload the fonts to the server
  • Use javascript and hidden layers to achieve great flexibility

Video about How Much Math Do You Need To Know For Javascript

You can see more content about How Much Math Do You Need To Know For Javascript on our youtube channel: Click Here

Question about How Much Math Do You Need To Know For Javascript

If you have any questions about How Much Math Do You Need To Know For Javascript, please let us know, all your questions or suggestions will help us improve in the following articles!

The article How Much Math Do You Need To Know For Javascript was compiled by me and my team from many sources. If you find the article How Much Math Do You Need To Know For Javascript helpful to you, please support the team Like or Share!

Rate Articles How Much Math Do You Need To Know For Javascript

Rate: 4-5 stars
Ratings: 8262
Views: 14742257

Search keywords How Much Math Do You Need To Know For Javascript

How Much Math Do You Need To Know For Javascript
way How Much Math Do You Need To Know For Javascript
tutorial How Much Math Do You Need To Know For Javascript
How Much Math Do You Need To Know For Javascript free
#PIM #Team #Case #Study #Creating #Text #Effects #PHP

Source: https://ezinearticles.com/?PIM-Team-Case-Study—Creating-Text-Effects-With-PHP-And-GD&id=21964

Related Posts

How Many Questions Does The Math 3 Final Exam Have How to Cure Test Anxiety – 3 Habits You Must Break to Cure Exam Panic!

You are searching about How Many Questions Does The Math 3 Final Exam Have, today we will share with you article about How Many Questions Does The…

How Many School Allow Students Use Calculators In Math Class http://webcache.googleusercontent.com/search?q=cache:https%3A%2F%2Fezinearticles.com%2F%3FReport-Card-Comments%26id%3D3524667

You are searching about How Many School Allow Students Use Calculators In Math Class, today we will share with you article about How Many School Allow Students…

How To Ask Students To Draw A Picture For Math Three Ways to Improve Learning Readiness Through Play

You are searching about How To Ask Students To Draw A Picture For Math, today we will share with you article about How To Ask Students To…

How Much You Charge For Taking An Online Math Class Making Money Online – The New Way to Get Rich Quick

You are searching about How Much You Charge For Taking An Online Math Class, today we will share with you article about How Much You Charge For…

How Many Hours Do You Get In A Crative Math Turning a Band Into Songwriters – 10 Songs In One Hour

You are searching about How Many Hours Do You Get In A Crative Math, today we will share with you article about How Many Hours Do You…

How To Get A Better Math Score On The Act 7 Trouble-Free Tips About How To Study For The ACT

You are searching about How To Get A Better Math Score On The Act, today we will share with you article about How To Get A Better…