actionscript 3 - Drawing dynamic figure, then filling it with color (AS3) -
I just wanted to create a piechart using Flash AS3. I have made a code that pulls the fragmented circles, so I can use them to point to different parts.
My problem: I have code to make many pies as I want, but I need a code to fill in different areas (Segment 1 Blue, Segment 2 red, etc.) )
My code is as follows:
/ ** * Draw a segment of a circle * @ Ultimate Goal & lt; Sprite & gt; The object we are going to * * the ultimate X & Lt; Number & gt; Want to draw in X-coordinates of Segment Generation * @ Param Y and LT; Number & gt; Y-coordinates of Segment Generation @ Ultimate R & LT; Number & gt; Radius of Segment * @ Ultimate OneStart & lt; Number & gt; Initial angles (degrees) of the segment (0 = east) * @ param eind & lt; Number & gt; Segment ending angle (degrees) (0 = east) * @love stage & lt; Number = 1> Number of degrees between each point on the perimeter of the segment * / Function Draw Segment (Target: Sprite, X: Number, Y: Number, R: Number, A Start: Number, End: Number, Step: Number = 1): Zero To work more radically in radians, var degrees: radians: numbers = mathematics. PI / 180; aStart * = Degreered Radian; AE * = Degreeredrien; Step * = Degreeredrien; // segment goal. Graphics.moveTo (x, y) draw; For (var goeta: number = a start; theta
It's very easy you get started () and Add the endfill () call using the colors provided by your draw segment . Add a parameter for this. function drawSegment (target: sprite, x: number, y: number, r: number, a start: number, eid: number, color: uint = 0x0, phase: number = 1) : Zero {// radian var more capable to work in degree: peerradian: number = monastery. PI / 180; aStart * = Degreered Radian; AED * = Degreeredrion; Step * = Degreeredrien; // segment goal. Draw Graphics.beginFill (Color, 1); // The second parameter is alpha target.graphics.moveTo (x, y); (Var goeta: number = a start; theta Instead of using a function to draw size , drag it somewhere. Expands the public square pie chart sprite on {...} and this.graphics .
Comments
Post a Comment