编写一个“绘画系统”

在最后一次的作业中,老师让我们编写一个“绘画系统”,提供一系列绘画材料(例如画笔/颜料/滤镜)给用户操作,以创作出动态/交互的绘画作品。这个绘画系统是对“绘画”的概念的扩展,但仍然体现出与传统绘画系统的相似性。可以理解为:创作一个app,看起来比较像“画画”的工具,但又绝不是复现已知的绘画行为,而要体现出通常绘画出不来的效果(动态、交互性)

一 什么是“绘画”

  材料:颜料,画布,画笔等物质要素;

  作画者:创作的思想/技法有关的内容;

  交互方式:作画者如何操作材料;

  作品:即呈现效果。通常的绘画作品。

最开始我设想的是一个很基本的绘画系统,即点击某个按钮在面板上可以进行基础的绘画(画点,线,特殊图形),再细致的区分颜色大小粗细等等。但是又看了一遍作业要求之后,发现并不是要我们完全复刻一个类似于电脑自带的画图软件。在这里的给出我的理解。

  材料:可以是基础的颜色,颜料,画笔,更可以是一个已经制作好的物体(比如unity里面的预制件,点击某个按钮可以用脚本生成)或者说已经制作好的作品。

  作画者:各种对作品能产生改变的功能(比如添加一个新物体,或者对已经弄好的作品本身进行改变,例如旋转,平移,缩放,或者是色彩的改变)。

 交互方式:因为是编程制作,更多的是用鼠标拖拽,点击。

作品:最后的绘画作品。

确定好这些概念之后,我的作业大致方向已经确定了,分为基础版的绘画和加强版(好像也不对)的“绘画”。

 

基础版:制作一个基本的绘画系统,更多的是体现材料和交互方式。

因为matlab自己有各种绘制函数,所以我决定用matlab制作。

最初的基础版设计界面:

这个就是点击下拉框选择不同的形状和颜色(类似于画笔和颜料)在面板上进行绘画操作(交互),可以清除图形(类似橡皮擦的功能),同时可以保存作品。

具体的形状有:点,线,矩形和椭圆。点的形状有:+,o,*和三角形。具体的颜色有:红,绿,蓝,黑。通过这些比较基本的绘制,我们可以得到一个很基本的绘画作品。

下面是具体的代码(参考别人代码,会给出链接):

function varargout = net1(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @net1_OpeningFcn, ...
                   'gui_OutputFcn',  @net1_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before net1 is made visible.
function net1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to net1 (see VARARGIN)

% Choose default command line output for net1
handles.output = hObject;
movegui(gcf,'center');
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes net1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = net1_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton1.




% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.


% --- Executes during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

global flg mark rgb graph;
flg=0;   %f初始鼠标没有按下
graph='点线';
mark='.';
rgb=[1,0,0];
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global flg  mark rgb x0 y0 x y rect graph;
flg=1;
set(handles.pushbutton2,'enable','on');
set(handles.pushbutton3,'enable','on');
currPt = get(gca, 'CurrentPoint');
x = currPt(1,1);
y = currPt(1,2);
switch(graph)
    case '点线'
        line(x,y, 'marker', mark,'color',rgb);
    otherwise
        line(x,y,'LineStyle',mark,'color',rgb);
end
x0=x;y0=y;
set(handles.edit1,'string',num2str(x));
set(handles.edit2,'string',num2str(y));
set(handles.text3,'string','Mouse down!');

% --- Executes on mouse motion over figure - except title and menu.
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global flg mark rgb x0 y0 x y rect graph h;
if flg
    switch(graph)
        case '点线'
            currPt=get(gca, 'CurrentPoint');
            x=currPt(1,1);
            y=currPt(1,2);
            line(x,y, 'marker', mark,'color',rgb);
        case '线形'
            x0=x;y0=y;
            currPt=get(gca, 'CurrentPoint');
            x=currPt(1,1);
            y=currPt
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值