📄 fsshapeconstructor.java
字号:
}
/**
* Generates a transparent shape containing the current path and styles.
*
* The shape is constructed with copies of the style arrays and the shape representing the
* path drawn. This allows the number of styles to be changed without affecting previously
* created shapes.
*
* @param identifier an unique identifier for the shape.
*/
public FSDefineShape3 defineTransparentShape(int identifier)
{
return new FSDefineShape3(identifier, bounds(), (ArrayList)fillStyles.clone(), (ArrayList)lineStyles.clone(), new FSShape((ArrayList)objects.clone()));
}
/**
* Creates a new path, discarding any path elements drawn.
*/
public void newPath()
{
pathInProgress = false;
setInitial(0, 0);
setCurrent(0, 0);
setControl(0, 0);
setBounds(0, 0, 0, 0);
objects.clear();
lineWidth = 0;
}
/**
* Closes the current path by drawing a line from the current point to the starting point of the
* path.
*/
public void closePath()
{
int dx = initialX - currentX;
int dy = initialY - currentY;
if (dx != 0 || dy != 0)
objects.add(new FSLine(dx, dy));
setCurrent(initialX, initialY);
pathInProgress = false;
}
/**
* move to the point (x,y).
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x the x-coordinate of the point to move to.
* @param y the y-coordinate of the point to move to.
*/
public void move(int x, int y)
{
x = COORDINATES_ARE_PIXELS ? x * 20 : x;
y = COORDINATES_ARE_PIXELS ? y * 20 : y;
objects.add(new FSShapeStyle(x, y));
setControl((currentX+x)/2, (currentY+y)/2);
setCurrent(x, y);
setInitial(x, y);
}
void moveForFont(int x, int y)
{
x = COORDINATES_ARE_PIXELS ? x * 20 : x;
y = COORDINATES_ARE_PIXELS ? y * 20 : y;
objects.add(new FSShapeStyle(1, Transform.VALUE_NOT_SET, 1, x, y));
setControl((currentX+x)/2, (currentY+y)/2);
setCurrent(x, y);
setInitial(x, y);
}
/**
* move relative to the current point.
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x the distance along the x-axis.
* @param y the distance along the y-axis.
*/
public void rmove(int x, int y)
{
x = COORDINATES_ARE_PIXELS ? x * 20 : x;
y = COORDINATES_ARE_PIXELS ? y * 20 : y;
objects.add(new FSShapeStyle(x+currentX, y+currentY));
setControl(currentX+x/2, currentY+y/2);
setCurrent(currentX+x, currentY+y);
}
/**
* draw a line from the current point to the point (x,y).
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x the x-coordinate of the end of the line.
* @param y the y-coordinate of the end of the line.
*/
public void line(int x, int y)
{
x = (COORDINATES_ARE_PIXELS ? x * 20 : x) - currentX;
y = (COORDINATES_ARE_PIXELS ? y * 20 : y) - currentY;
objects.add(new FSLine(x, y));
if (pathInProgress == false)
{
setInitial(currentX, currentY);
pathInProgress = true;
}
setControl(currentX+x/2, currentY+y/2);
setCurrent(currentX+x, currentY+y);
}
/**
* draw a line relative to the current point.
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x the distance along the x-axis to the end of the line.
* @param y the distance along the y-axis to the end of the line.
*/
public void rline(int x, int y)
{
x = COORDINATES_ARE_PIXELS ? x * 20 : x;
y = COORDINATES_ARE_PIXELS ? y * 20 : y;
objects.add(new FSLine(x, y));
if (pathInProgress == false)
{
setInitial(currentX, currentY);
pathInProgress = true;
}
setControl(currentX+x/2, currentY+y/2);
setCurrent(currentX+x, currentY+y);
}
/**
* draw a quadratic bezier curve from the current point to the point (x,y) with the control
* point (x1, y1).
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x1 the x-coordinate of the control point.
* @param y1 the y-coordinate of the control point.
* @param x the x-coordinate of the end of the curve.
* @param y the y-coordinate of the end of the curve.
*/
public void curve(int x1, int y1, int x, int y)
{
x1 = (COORDINATES_ARE_PIXELS ? x1 * 20 : x1) - currentX;
y1 = (COORDINATES_ARE_PIXELS ? y1 * 20 : y1) - currentY;
x = (COORDINATES_ARE_PIXELS ? x * 20 : x) - currentX - x1;
y = (COORDINATES_ARE_PIXELS ? y * 20 : y) - currentY - y1;
objects.add(new FSCurve(x1, y1, x, y));
if (pathInProgress == false)
{
setInitial(currentX, currentY);
pathInProgress = true;
}
setControl(currentX+x1, currentY+y1);
setCurrent(currentX+x1+x, currentY+y1+y);
}
/**
* draw a quadratic bezier curve relative to the current point to the point.
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x1 the distance along the x-axis from the current point to the control point.
* @param y1 the distance along the y-axis from the current point to the control point.
* @param x the distance along the x-axis from the current point to the end of the curve.
* @param y the distance along the y-axis from the current point to the end of the curve.
*/
public void rcurve(int x1, int y1, int x, int y)
{
x1 = COORDINATES_ARE_PIXELS ? x1 * 20 : x1;
y1 = COORDINATES_ARE_PIXELS ? y1 * 20 : y1;
x = COORDINATES_ARE_PIXELS ? x * 20 : x;
y = COORDINATES_ARE_PIXELS ? y * 20 : y;
objects.add(new FSCurve(x1, y1, x, y));
if (pathInProgress == false)
{
setInitial(currentX, currentY);
pathInProgress = true;
}
setControl(currentX+x1, currentY+y1);
setCurrent(currentX+x1+x, currentY+y1+y);
}
/**
* draw a cubic bezier curve from the current point to the point (x,y) with the off-curve control
* points (x1, y1) and (x2, y2).
*
* IMPORTANT: Converting cubic bezier curves to the quadratic bezier curves supported by Flash is
* mathematically difficult. The cubic curve is approximated by a series of straight line segments.
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x1 the x-coordinate of the first control point.
* @param y1 the y-coordinate of the first control point.
* @param x2 the x-coordinate of the second control point.
* @param y2 the y-coordinate of the second control point.
* @param x the x-coordinate of the end of the curve.
* @param y the y-coordinate of the end of the curve.
*/
public void curve(int x1, int y1, int x2, int y2, int x, int y)
{
Px[0] = currentX;
Py[0] = currentY;
Px[1] = COORDINATES_ARE_PIXELS ? x1 * 20 : x1;
Py[1] = COORDINATES_ARE_PIXELS ? y1 * 20 : y1;
Px[2] = COORDINATES_ARE_PIXELS ? x2 * 20 : x2;
Py[2] = COORDINATES_ARE_PIXELS ? y2 * 20 : y2;
Px[3] = COORDINATES_ARE_PIXELS ? x * 20 : x;
Py[3] = COORDINATES_ARE_PIXELS ? y * 20 : y;
flatten();
}
/**
* draw a cubic bezier curve relative to the current point.
*
* IMPORTANT: Converting cubic bezier curves to the quadratic bezier curves supported by Flash is
* mathematically difficult. The cubic curve is approximated by a series of straight line segments.
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x1 the distance along the x-axis from the current point to the first control point.
* @param y1 the distance along the y-axis from the current point to the first control point.
* @param x2 the distance along the x-axis from the current point to the second control point.
* @param y2 the distance along the y-axis from the current point to the second control point.
* @param x the distance along the x-axis from the current point to the end of the curve.
* @param y the distance along the y-axis from the current point to the end of the curve.
*/
public void rcurve(int x1, int y1, int x2, int y2, int x, int y)
{
Px[0] = currentX;
Py[0] = currentY;
Px[1] = currentX + (COORDINATES_ARE_PIXELS ? x1 * 20 : x1);
Py[1] = currentY + (COORDINATES_ARE_PIXELS ? y1 * 20 : y1);
Px[2] = currentX + (COORDINATES_ARE_PIXELS ? x2 * 20 : x2);
Py[2] = currentY + (COORDINATES_ARE_PIXELS ? y2 * 20 : y2);
Px[3] = currentX + (COORDINATES_ARE_PIXELS ? x * 20 : x);
Py[3] = currentY + (COORDINATES_ARE_PIXELS ? y * 20 : y);
flatten();
}
/**
* draw a quadratic bezier curve from the current point to the point (x,y) using the control point
* for the previously drawn curve.
*
* If no curve has been drawn previously then a control point midway along the previous line or
* move is used.
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x the x-coordinate of the end of the curve.
* @param y the y-coordinate of the end of the curve.
*/
public void reflect(int x, int y)
{
int x1 = currentX - controlX;
int y1 = currentY - controlY;
x = (COORDINATES_ARE_PIXELS ? x * 20 : x) - currentX;
y = (COORDINATES_ARE_PIXELS ? y * 20 : y) - currentY;
objects.add(new FSCurve(x1, y1, x, y));
if (pathInProgress == false)
{
setInitial(currentX, currentY);
pathInProgress = true;
}
setControl(x1+currentX, y1+currentY);
setCurrent(x+currentX, y+currentY);
}
/**
* draw a quadratic bezier curve relative to the current point to the point using the control point
* for the previously drawn curve.
*
* If no curve has been drawn previously then a control point midway along the previous line or
* move is used.
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x the distance along the x-axis from the current point to the end of the curve.
* @param y the distance along the y-axis from the current point to the end of the curve.
*/
public void rreflect(int x, int y)
{
int x1 = currentX - controlX;
int y1 = currentY - controlY;
x = COORDINATES_ARE_PIXELS ? x * 20 : x;
y = COORDINATES_ARE_PIXELS ? y * 20 : y;
objects.add(new FSCurve(x1, y1, x, y));
if (pathInProgress == false)
{
setInitial(currentX, currentY);
pathInProgress = true;
}
setControl(x1+currentX, y1+currentY);
setCurrent(x+currentX, y+currentY);
}
/**
* draw a cubic bezier curve from the current point to the point (x,y). The first control point
* is the one defined for the previously drawn curve. The second control point is the
* coordinates (x2, y2).
*
* If no curve has been drawn previously then a control point midway along the previous line or
* move is used.
*
* If the COORDINATES_ARE_PIXELS attribute is true then the coordinates are specified in pixels,
* otherwise the coordinates are specified in twips.
*
* @param x2 the x-coordinate of the control point.
* @param y2 the y-coordinate of the control point.
* @param x the x-coordinate of the end of the curve.
* @param y the y-coordinate of the end of the curve.
*/
public void reflect(int x2, int y2, int x, int y)
{
int x1 = currentX - controlX;
int y1 = currentY - controlY;
x2 = (COORDINATES_ARE_PIXELS ? x2 * 20 : x2) - currentX;
y2 = (COORDINATES_ARE_PIXELS ? y2 * 20 : y2) - currentY;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -