博客
关于我
送你一颗心Easyx
阅读量:326 次
发布时间:2019-03-04

本文共 1504 字,大约阅读时间需要 5 分钟。

    C代码示例:绘制极坐标系图形    
        #include 
#include
#include
#include
#include
#define a 60 #define PI 3.1415926 double th = PI / 180; void StartPic(void) { // 初始化图形 initgraph(800, 600); cleardevice(); } void ClosePic(void) { // 等待键盘输入以关闭图形窗口 getch(); } void DrawXin(int x0, int y0, int k) { // 绘制极坐标系的星形 double i, x, y, tx, ty; for (i = -180.0; i < 180.0; i += 0.01) { x = a * (2 * cos(i * th) - cos(2 * i * th)); y = a * (2 * sin(i * th) - sin(2 * i * th)); tx = x; ty = y; x = tx * cos(k * th) - ty * sin(k * th) + x0; y = y0 - (ty * cos(k * th) + tx * sin(k * th)); putpixel(x, y, RED); setfillstyle(1, RED); floodfill(500, 500, RED); } } void main(void) { // 初始化图形并启动画面 StartPic(); // 绘制星形 DrawXin(320, 240, 90); // 设置填充颜色并填充 setfillcolor(RGB(255, 0, 0)); floodfill(350, 250, RGB(255, 255, 0)); // 关闭画面并结束程序 ClosePic(); }

以上代码示例展示了一个使用C语言绘制极坐标星形图形的简单程序。代码主要通过调用图形库函数进行图形绘制,适用于在终端环境下进行显示。程序的核心功能包括图形初始化、图形绘制和图形关闭等基本操作。

这个代码片段可以用于教育和开发目的,帮助用户理解如何利用C语言和图形库进行简单的图形绘制操作。

转载地址:http://srsh.baihongyu.com/

你可能感兴趣的文章
org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: not s
查看>>
sqlserver学习笔记(三)—— 为数据库添加新的用户
查看>>
org.apache.http.conn.HttpHostConnectException: Connection to refused
查看>>
org.apache.ibatis.binding.BindingException: Invalid bound statement错误一例
查看>>
org.apache.ibatis.exceptions.PersistenceException:
查看>>
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
查看>>
org.apache.ibatis.type.TypeException: Could not resolve type alias 'xxxx'异常
查看>>
org.apache.poi.hssf.util.Region
查看>>
org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
查看>>
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
查看>>
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugManifest'
查看>>
org.hibernate.HibernateException: Unable to get the default Bean Validation factory
查看>>
org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
查看>>
org.springframework.amqp.AmqpConnectException:java.net.ConnectException:Connection timed out:connect
查看>>
org.springframework.beans.factory.BeanDefinitionStoreException
查看>>
org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
查看>>
org.springframework.boot:spring boot maven plugin丢失---SpringCloud Alibaba_若依微服务框架改造_--工作笔记012
查看>>
SQL-CLR 类型映射 (LINQ to SQL)
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>