📄 ctt1.td1
字号:
// Created by Action Script Viewer 4
// Custom Tool Template #1
// Copyright (c) 2003 Manitu Group, portions copyright Macromedia Inc.
// http://www.buraks.com/asv
// Thanks to (in no particular order) Keith Peters, Peter J. Hall, Eric Mueller, Sharon Selden
// version 1.00 (15 August 2003)
var data;
var width;
var height;
var ptStart=new Object;
var ptEnd=new Object;
// options
var ONLYSTROKE="Apply Stroke";
var FILLANDSTROKE="Apply Fill and Stroke";
var style=FILLANDSTROKE;
var SCALE="Scale";
var ROTATE="Rotate";
var mode=ROTATE;
function configureTool()
{
var theTool = fl.tools.activeTool;
theTool.setToolName("<#toolname>");
theTool.setIcon("<#toolicon>");
theTool.setMenuString("<#toolmenustr>");
theTool.setToolTip("<#tooltooltip>");
theTool.setPI("shape");
theTool.showPIControl("stroke",true);
theTool.enablePIControl("stroke",true);
theTool.showPIControl("fill",true);
theTool.enablePIControl("fill",true);
theTool.setOptionsFile("<#toolxml>");
}
function notifySettingsChanged()
{
var theTool = fl.tools.activeTool;
style=theTool.style;
mode=theTool.mode;
}
function setCursor()
{
fl.tools.setCursor(0);
}
function notifyDocChanged(theType)
{
//just to be cautious
if (theType!="selectionChanged")
{
ptEnd=ptStart;
fl.drawingLayer.endDraw();
}
}
function activate()
{
<#outlinefortoolshape>
}
function deactivate()
{
data=undefined;
}
function mouseDown(mouseLoc)
{
ptStart = fl.tools.snapPoint(mouseLoc);
ptEnd = ptStart;
fl.drawingLayer.beginDraw();
}
function mouseUp()
{
fl.drawingLayer.endDraw();
if (ptStart==ptEnd) return;
getDataPath().makeShape(style==ONLYSTROKE);
}
function mouseMove(mouseLoc)
{
if (fl.tools.mouseIsDown)
{
ptEnd=fl.tools.snapPoint(mouseLoc);
if (ptStart==ptEnd) return;
var dl = fl.drawingLayer;
dl.beginFrame();
dl.drawPath(getDataPath());
dl.endFrame();
}
}
function getDataPath()
{
var curWidth = ptEnd.x-ptStart.x;
var curHeight = ptEnd.y-ptStart.y;
var mat = new Object;
mat.tx = ptStart.x;
mat.ty = ptStart.y;
if (mode==ROTATE)
{
var sc = Math.sqrt(((curWidth*curWidth)+(curHeight*curHeight))/((width*width)+(height*height)));
var t=Math.atan2(curHeight,curWidth)-Math.atan2(height,width);
mat.a = Math.cos(t)*sc;
mat.b = Math.sin(t)*sc;
mat.c = -mat.b;
mat.d = mat.a;
}
else
{
mat.a = curWidth/width;
mat.b = 0;
mat.c = 0;
mat.d = curHeight/height;
//shift lock not implemented because of redraw issues
}
mat=fl.Math.concatMatrix(mat,fl.getDocumentDOM().viewMatrix);
var pt1x,pt1y,pt2x,pt2y,pt3x,pt3y;
var dp = fl.drawingLayer.newPath();
var k = 0;
var n = data.length;
while (k<n)
{
var d = data[k++];
var c = d[0];
var d1 = d[1];
if (c=='M')
{
pt1x = d1[0]*mat.a + d1[1]*mat.c + mat.tx;
pt1y = d1[0]*mat.b + d1[1]*mat.d + mat.ty;
dp.newContour();
}
else
if (c=='L')
{
dp.addPoint(pt1x,pt1y);
pt1x = d1[0]*mat.a + d1[1]*mat.c + mat.tx;
pt1y = d1[0]*mat.b + d1[1]*mat.d + mat.ty;
dp.addPoint(pt1x,pt1y);
}
else
if (c=='C')
{
pt2x = d1[0]*mat.a + d1[1]*mat.c + mat.tx;
pt2y = d1[0]*mat.b + d1[1]*mat.d + mat.ty;
pt3x = d1[2]*mat.a + d1[3]*mat.c + mat.tx;
pt3y = d1[2]*mat.b + d1[3]*mat.d + mat.ty;
dp.addCurve(pt1x,pt1y,pt2x,pt2y,pt3x,pt3y);
pt1x = pt3x;
pt1y = pt3y;
}
}
return dp;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -