博客
关于我
送你一颗心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/

你可能感兴趣的文章
Openlayers Interaction基础及重点内容讲解
查看>>
Openlayers layer 基础及重点内容讲解
查看>>
Openlayers map三要素(view,target,layers),及其他参数属性方法介绍
查看>>
Openlayers Map事件基础及重点内容讲解
查看>>
Openlayers Select的用法、属性、方法、事件介绍
查看>>
Openlayers Source基础及重点内容讲解
查看>>
Openlayers view三要素(zoom,center,projection)及其他参数属性方法介绍
查看>>
OpenLayers 入门使用
查看>>
Openlayers 入门教程(一):应该如何学习 Openlayers
查看>>
openlayers 入门教程(七):Interactions 篇
查看>>
openlayers 入门教程(三):view 篇
查看>>
openlayers 入门教程(九):overlay 篇
查看>>
openlayers 入门教程(二):map 篇
查看>>
openlayers 入门教程(五):sources 篇
查看>>
openlayers 入门教程(八):Geoms 篇
查看>>
openlayers 入门教程(六):controls 篇
查看>>
openlayers 入门教程(十一):Formats 篇
查看>>
openlayers 入门教程(十三):动画
查看>>
openlayers 入门教程(十二):定位与轨迹
查看>>
openlayers 入门教程(十五):与 canvas、echart,turf 等交互
查看>>