Delphi实例之绘制正弦函数图像

 unit Unit1;

 interface

 uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls; type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
var
x,l:Integer;
y,a:double;
begin
Image1.Picture.Bitmap:=TBitMap.Create;
Image1.Picture.Bitmap.Width:=Image1.Width;
Image1.Picture.Bitmap.Height:=Image1.Height;
l:=Image1.Picture.Bitmap.Width;
{下面的语句用于绘制直角坐标系}
Image1.Canvas.MoveTo(,(Image1.Height div ));
Image1.Canvas.Pen.Color:=clBlue;
Image1.Canvas.LineTo(Image1.Width,(Image1.Height div ));{绘制函数图像X轴}
Image1.Canvas.MoveTo((Image1.Width div ),Image1.Height);
Image1.Canvas.LineTo((Image1.Width div ),);{绘制函数图像Y轴}
for x:= to l do
begin
a:=(x/l)**Pi;{角度化弧度}
y:=sin(*a);{为了加强美观效果,这里讲振幅设为2}
y:=y*(Image1.Picture.Bitmap.Height/);
y:=y+(Image1.Picture.Bitmap.Height/);
Image1.Picture.Bitmap.Canvas.Brush.Style:=bsSolid;
Image1.Picture.Bitmap.Canvas.Pixels[Trunc(x),Trunc(y)]:=clRed;{当然也可以用LineTo过程来实现,但是要注意设置Pen.Width到合适的值}
end;
label1.Visible:=true;
Label2.Visible:=true;
label3.Visible:=true;
Label4.Visible:=true;
label5.Visible:=true;
Label6.Visible:=true;
end; end.

注意,这里我用了四个标签,分别用于显示X,Y,0,f(x)=sinx,并事先将它们的Visible属性设为False,当图像绘制完成后在将Visible改为True。

Delphi实例之绘制正弦函数图像的更多相关文章

  1. Matlab绘图基础——利用axes(坐标系图形对象)绘制重叠图像 及 一图多轴(一幅图绘制多个坐标轴)

    描述 axes在当前窗口中创建一个包含默认属性坐标系 axes('PropertyName',propertyvalue,...)创建坐标系时,同时指定它的一些属性,没有指定的使用DefaultAxe ...

  2. 【openGL】画正弦函数图像

    #include "stdafx.h" #include <GL/glut.h> #include <stdlib.h> #include <math ...

  3. (转载)delphi实例TDBGrid用右键菜单复制行粘贴行

    delphi实例TDBGrid用右键菜单复制行粘贴行 这个从本质上来说就是DBGrid后台数据库的插入 右键复制当前行的相关数据到临时变量点粘贴时,覆盖数据或插入数据! db为数据库: 字段名id,n ...

  4. -_-#【Canvas】导出在<canvas>元素上绘制的图像

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  5. Delphi实例之一个简易的浏览器的实现

    Delphi实例之一个简易的浏览器的实现 Delphi7的WebBrowser组件提供了很多不错的网页设计的功能,下面做一个简单的浏览器.组件很简单按照下面摆放就行了. 这是运行后的效果 源代码 主页 ...

  6. Delphi实例之橡皮筋画图的实现

    Delphi实例之橡皮筋画图的实现 在<Delphi7基础教程>这本书的练习中提到过一个橡皮筋画图的例子,书上的源码是错误的!不知道是打印的错误还是本身源码就有问题,我将它改了过来. 在F ...

  7. OpenCV 鼠标手动绘制掩码图像

    OpenCV 鼠标手动绘制掩码图像 完整的代码: #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui ...

  8. matplotlib绘制矢量图像(svg),pdf and ps文件

    机器学习的过程中处理数据,会遇到数据可视化的问题. 大部分都是利用python的matplotlib库进行数据的可视化处理. plt.show() 默认都是输出.png文件,图片只要稍微放大一点,就糊 ...

  9. MATLAB实例:绘制条形图

    MATLAB实例:绘制条形图 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 用MATLAB绘制条形图,自定义条形图的颜色.图例位置.横坐标名称.显示条 ...

随机推荐

  1. 20165322 实验二《Java面向对象程序设计》实验报告

    实验二<Java面向对象程序设计>实验报告 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 了解设计模式 实 ...

  2. 【转】android Looper 理解

    在主线程中运行的部分,都可以直接使用Handler,因为在主线程启动的过程中(ActivityThread的main函数里)会调用Looper.prepareMainLooper(),Looper类中 ...

  3. GroundPlaneEstimator.cpp解读

    GroundPlaneEstimator域下的compute函数,就相当于整个cpp的主函数,也体现了整个调用过程,先执行compute_v_disparity_data,再compute_v_dis ...

  4. canvas基本图形

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. P2852 [USACO06DEC]牛奶模式Milk Patterns

    link 这是一道后缀匹配的模板题 我们只需要将height算出来 然后二分一下答案就可以了 #include<cstdio> #include<algorithm> #inc ...

  6. Android学习笔记_62_手机安全卫士知识点归纳(2)ListView重要属性 PopupWindow应用

    1.缓存颜色: 为什么ListView在拖动的时间是黑色,而静止时间是自己的颜色是因为 ListView的缓存.只需一个配置即可.在这个ListView里面加上它即可. android:cacheCo ...

  7. Storm 中drpc调用

    package storm.starter; import backtype.storm.Config; import backtype.storm.LocalCluster; import back ...

  8. 揭开redux,react-redux的神秘面纱

    16年开始使用react-redux,迄今也已两年多.这时候再来阅读和读懂redux/react-redux源码,虽已没有当初的新鲜感,但依然觉得略有收获.把要点简单写下来,一方面供感兴趣的读者参考, ...

  9. Keepalived 配置高可用

    VRRP协议及Keepalived原理使用   VRRP 协议即 Virtual Router Redundancy Protocol,虚拟路由器冗余协议, 为了解决局域网内默认网关单点失效的问题.  ...

  10. fjutacm 2492 宠物收养所 : Splay 模板 O(nlogn)

    /** problem: http://www.fjutacm.com/Problem.jsp?pid=2492 Splay blog: https://tiger0132.blog.luogu.or ...