PDA

View Full Version : GraphicsPath NO_OP



Felixz
December 11th, 2008, 05:17 PM
http://livedocs.adobe.com/labs/textlayout/flash/display/GraphicsPathCommand.html#NO_OP (http://livedocs.adobe.com/labs/textlayout/flash/display/GraphicsPathCommand.html#NO_OP)

Is there a use of that?
A little story:

DRAWING_VECTOR[1] = new GraphicsPath(Vector.<int>([5, 5, 2, 5]), initPathData);
//DRAWING_VECTOR[1] = new GraphicsPath(Vector.<int>([2, 3, 2, 3, 2]), initPathData);
I have created a rounded square on one side and I want to get rid of curveTos in some situations and make it maximally optimized.
So I thought to have
Vector.<int>([5, 0, 5, 5])//3 lineTos instead of earlier 4.But it doesn't work and creates slightly different line than here (a note: each line gives the same effect)
Vector.<int>([5, 5, 0, 5]);
Vector.<int>([5, 5, 5]);
Vector.<int>([0,5, 5,0,0,0, 5,0,0,0,0]);Here is whole code:
private static const DRAWING_VECTOR:Vector.<IGraphicsData> = new Vector.<IGraphicsData>(3, true);
DRAWING_VECTOR[0] = new GraphicsGradientFill(GradientType.LINEAR, [0xFFFFFF, 0xFFFFFF], [.1, .75], [0x0F, 0xF0], matrixButton, SpreadMethod.REFLECT, InterpolationMethod.RGB);
//DRAWING_VECTOR[1] = new GraphicsPath(Vector.<int>([5, 0, 5, 5]), initPathData);
DRAWING_VECTOR[1] = new GraphicsPath(Vector.<int>([2, 3, 2, 3, 2]), initPathData);
DRAWING_VECTOR[2] = new GraphicsEndFill();
private static function get initPathData():Vector.<Number> {
var data:Vector.<Number> = new Vector.<Number>(14, true);
data[0] = data[2] = data[13] = 0;
data[1] = data[11] = BaseWindow.BAR_HEIGHT * 4 / 9;
data[3] = data[5] = data[7] = data[9] = BaseWindow.BAR_HEIGHT * 2 / 3;
data[4] = -BaseWindow.BAR_HEIGHT * 2 / 9;
data[8] = data[10] = data[12] = -BaseWindow.BAR_HEIGHT * 1.5;
data[6] = data[8] - data[4];
return data;
}

senocular
December 11th, 2008, 05:43 PM
Don't you want
[2, 5, 2, 5, 2]
?

Felixz
December 12th, 2008, 06:45 AM
I don't want to cut the corners but straighten them, using the same data set in 3 instructions: The best method to do that seemed to be [5, 0, 5, 5], but 0 does not shift the data like wideLineTo.
My questions are: Why usage of 0 is unintuitive and useless?
Is there a way to make that smaller: [5, 2, 5, 5] (skip, lineTo, lineTo, skip, lineTo, skip, lineTo (4 lineTos) convert to skip, lineTo, skip, skip, lineTo, skip, lineTo (3 lineTos))

senocular
December 12th, 2008, 11:19 AM
I'd go so far as to say it's a bug.
I'll make sure it gets recognized.

Actually, it looks like its just ignoring the command but not the data. I'll have to check to see if this is the expected behavior or not

Felixz
December 12th, 2008, 12:44 PM
Is there a use of current behavior?

senocular
December 12th, 2008, 01:08 PM
Is there a use of current behavior?

I think the original idea what that an "empty" vector would produce no drawing. Since vectors are dense and must have values, an "empty" vector would consist entirely of 0's since 0 is the default int value.

senocular
December 12th, 2008, 02:47 PM
Ok, so the current behavior is as intended, and there really is no supposed use case per se; it mostly relates to what I said before. This especially for when adding commands to the beginning of a pre-sized vector, the extra, default 0's will cause no actions to occur.

Your particular use case is good one, however. It was suggested that it could be a feature request. If you feel up to it, log it ;)
bugs.adobe.com
(under Flash Player)

Felixz
December 12th, 2008, 05:35 PM
The wierd thing is with those vectors:
[5, 5, 5] and [5, 5, 0, 5] produce the same image, but [5, 0, 5, 5] 'shifts' drawing... :confused:

senocular
December 12th, 2008, 06:04 PM
Thats because 0 is not wide and 5 is.

Felixz
December 13th, 2008, 05:59 AM
I still don't get it...
The goal is to make a consistent experience and maximally optimized, that's why I want to make a square from 3 instructions (look at 4 last tiles).
But weirdness happens when '0' is on first position after first '5' or '2': when it is anywhere else in any amount - it is okay. This seems to be a bug (or a feature).