Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

# Draw Cos and Sin On A TPlotGrid In Delphi XE6 Firemonkey On Android And IOS

Embarcadero has a sample that comes with Delphi XE6 Firemonkey which demonstrates plotting lines on a grid using the TPlotGrid component. The TPlotGrid component is basically a grid component where you can draw things like lines or charts and have them match up with the grid background of the component. This component works on Android, IOS, Windows, and OSX. In the sample simple Sin and Cos lines are plotted into a TPolygon and then drawn on the plot grid in the OnPaint event. It has two functions CalculateCos and CalculateSin where the TPolygon is filled up and then DrawPolygon is used to draw it out. There is a function called SetParams where the resolution, radian, origin, and interval of the points is calculated based on the size of the component. Resolution is the precision of the graph. Radian is the angle. Origin is the middle point of the TPlotGrid. And interval is the space between two points. Here is the SetParams function from the sample:
```procedure TMainForm.SetParams; begin Resolution := 200;Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  // Set resolution to 200 points Radian := -2.0 * Pi;Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  // Start angle at -2Pi xPixels := PlotGrid.Width / 4;Â Â Â Â Â Â Â  // Contain graph width within a quarter of the grid width (actually half because of neg values) yPixels := PlotGrid.Height / 4;Â Â Â Â Â Â  // Contain graph height within a quarter of the grid height (actually half because of neg values) Origin := PointF(PlotGrid.Width / 2,Â  // Calculate the center point of the plot grid PlotGrid.Height / 2); Interval := 4.0 * Pi / Resolution;Â Â Â  // Set interval between two points in which function values are calculated end;```