⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 displaycursor.m

📁 国际象棋程序,解压到当前目录,在matlab窗口输入chess即可应用
💻 M
字号:
function displayCursor(varargin)
% displayCursor Displays the cursor.
% The cursors is displayed, whilst the mouse is moving.
%
% Whenever the cursor gets to a new chess field, the cursor data is updated 
% and the cursor patch is redrawn.
%
%% Input and Output:
% * varargin ... currently not used
% * global cursor ... cursor structure containing from, to, current, etc.
%
% Example
% Assume a chess figure is activated (cursorListener). The |cursorListener|
% starts the mouse motion callback, which starts |displayCursor|.
%
% See also: cursorListener, setCursor, reset_cursor
%
% TODO: get rid of gca
%
%% Signature
% Author: W.Garn
% E-Mail: wgarn@yahoo.com
% Date: 2006/03/23 12:00:00 
% 
% Copyright 2006 W.Garn


global cursor; % attention is in matrix notation!
position = get(gca,'currentPoint');
xy = [position(1) position(3)];
%hObject = get(gcf,'CurrentObject');
hObject = cursor.to_h;

xy = xy+.5;
xy = round(xy);
if sum(xy == matrix2xy(cursor.current)) < 2
    if sum(0 < xy & xy < 9)==2 % within board
        cursor.current = xy2matrix(xy);
        if mod(xy(1)+xy(2),2), color=[.94 .94 .94]; else color=[.87 .49 0]; end
        set(hObject,'XData',xy(1)-1+[0 1 1 0],'YData',xy(2)-1+[0 0 1 1]);
        set(hObject,'FaceColor',color);
        set(hObject,'EdgeColor','y');
        set(hObject,'FaceAlpha',.1); % There must be a nicer way!

    end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -