網(wǎng)站首頁 編程語言 正文
PART.0?使用效果
?PART.1 程序說明
這個(gè)代碼主要復(fù)刻的Clayton Shonkwiler使用Wolfram繪制的作品(二十個(gè)旋轉(zhuǎn)的正九變形),據(jù)說其靈感來源于Thomas Davis的一些作品,Clayton Shonkwiler的更多作品可以在這個(gè)地址查看
?PART.2 完整代碼
function nonagon20 % @author:slandarer % axes屬性設(shè)置 ax=gca; hold on;axis equal; ax.Position=[0 0 1 1]; ax.XLim=[-6,6];ax.YLim=[-6,6]; ax.XColor='none';ax.YColor='none'; ax.Color=[0,44,106]./255; % 初始集合構(gòu)建 t=linspace(0,2*pi,9); NGon=[cos(t'),sin(t')].*2; NGonSet=repmat(NGon',[20,1]); rotate18=arrayfun(@(k)[cos(pi/10),-sin(pi/10);sin(pi/10),cos(pi/10)]^k,0:19,'UniformOutput',false); rotate18=blkdiag(rotate18{:}); NGonSet=rotate18*NGonSet; % 漸變顏色矩陣創(chuàng)建 C1=[237,210,155]./255; C2=[219,90,117]./255; ct=linspace(0,1,11); CList=[interp1([0,1],[C1(1),C2(1)],ct,'linear')',... interp1([0,1],[C1(2),C2(2)],ct,'linear')',... interp1([0,1],[C1(3),C2(3)],ct,'linear')']; CList=[CList;flipud(CList(2:10,:))];CList=[CList(5:end,:);CList(1:4,:)]; % 初始圖像繪制 NGonHdl{20}=[]; for i=1:20 NGonHdl{i}=fill(NGonSet(i*2-1,:)+cos((i-1)*pi/10)*2,... NGonSet(i*2,:)+sin((i-1)*pi/10)*2,CList(i,:),... 'FaceAlpha',.12,'LineWidth',1.3,'EdgeColor',CList(i,:)); end % 旋轉(zhuǎn)矩陣 rotateMat=arrayfun(@(k)[cos(k),-sin(k);sin(k),cos(k)],ones([1,20]).*(2*pi/120),'UniformOutput',false); rotateMat=blkdiag(rotateMat{:}); % 旋轉(zhuǎn) for n=1:1000 NGonSet=rotateMat*NGonSet; for i=1:20 NGonHdl{i}.XData=NGonSet(i*2-1,:)+cos((i-1)*pi/10)*2; NGonHdl{i}.YData=NGonSet(i*2,:)+sin((i-1)*pi/10)*2; end pause(.05) drawnow end end
原文鏈接:https://mp.weixin.qq.com/s/L3yN4v4ICU5oOlO-D1a-Tw
相關(guān)推薦
- 2022-04-28 C++實(shí)現(xiàn)班級成績管理系統(tǒng)_C 語言
- 2022-12-07 利用C語言模擬實(shí)現(xiàn)qsort,strcpy,strcat,strcmp函數(shù)_C 語言
- 2022-02-23 Proxy error Could not proxy request錯(cuò)誤解決
- 2024-03-09 【Redis】什么是緩存擊穿,如何預(yù)防緩存擊穿?
- 2022-03-29 PostgreSQL13基于流復(fù)制搭建后備服務(wù)器的方法_PostgreSQL
- 2023-01-13 pytorch如何定義新的自動(dòng)求導(dǎo)函數(shù)_python
- 2022-06-30 PyTorch實(shí)現(xiàn)卷積神經(jīng)網(wǎng)絡(luò)的搭建詳解_python
- 2022-11-18 Shell實(shí)現(xiàn)批量操作文件的方法詳解_linux shell
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支