博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C++ 用RGB 三种颜色绘图
阅读量:4356 次
发布时间:2019-06-07

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

#include 
#include
#include
#define DIM 1024#define DM1 (DIM-1)#define _sq(x) ((x)*(x)) // square#define _cb(x) abs((x)*(x)*(x)) // absolute value of cube#define _cr(x) (unsigned char)(pow((x),1.0/3.0)) // cube root unsigned char GR(int,int);unsigned char BL(int,int); unsigned char RD(int i,int j){ float s=3./(j+99); float y=(j+sin((i*i+_sq(j-700)*5)/100./DIM)*35)*s; return (int((i+DIM)*s+y)%2+int((DIM*2-i)*s+y)%2)*127;}unsigned char GR(int i,int j){ float s=3./(j+99); float y=(j+sin((i*i+_sq(j-700)*5)/100./DIM)*35)*s; return (int(5*((i+DIM)*s+y))%2+int(5*((DIM*2-i)*s+y))%2)*127;}unsigned char BL(int i,int j){ float s=3./(j+99); float y=(j+sin((i*i+_sq(j-700)*5)/100./DIM)*35)*s; return (int(29*((i+DIM)*s+y))%2+int(29*((DIM*2-i)*s+y))%2)*127;}void pixel_write(int,int);FILE *fp;int main(){ fp = fopen("MathPic.png","wb"); fprintf(fp, "P6\n%d %d\n255\n", DIM, DIM); for(int j=0;j

 

# 上边代码保存为 draw.cpp  编译与运行g++ draw.cpp -o draw  (编译)./draw  (运行)然后当前目录就会出现 MathPic.png

 

 

http://www.matrix67.com/blog/archives/6039

转载于:https://www.cnblogs.com/lixiuran/p/6213611.html

你可能感兴趣的文章
Centos7 安装mysql5.7.16
查看>>
java串口通信与打卡器交互
查看>>
<CoreJava> 5.2 Object:所有类的超类
查看>>
输入年月日计算是星期几
查看>>
redis部分配置与报错解决
查看>>
Python Challenge(0-8)
查看>>
oracle中的trunc()函数
查看>>
对大一一年的总结和对大二的规划
查看>>
结构化程序设计04 - 零基础入门学习Delphi13
查看>>
密码学基础
查看>>
Java基础Map接口+Collections工具类
查看>>
OSGI基础知识整理
查看>>
Revit 开发将自己的窗口设置为Revit窗口
查看>>
倾斜摄影数据OSGB转换成3DML(转载)
查看>>
给年轻程序员的几句话
查看>>
ionic如何uglify和minify你的js,css,image,png....
查看>>
[LeetCode]Minimum Depth of Binary Tree
查看>>
jboss初体验
查看>>
Python列表、元组练习
查看>>
angular页面刷新
查看>>