DCarpenter Posted May 20, 2011 Share Posted May 20, 2011 I created the script below that creates a closed polygon and a rectangle, both with a gradient fill. After execution and converting the PIO to a group, both objects show (in the attribute palette) that they have a gradient fill, but on the screen the gradient only appears in the rectangle. If I select the poly and open the gradient dialog box and click preview the gradient appears. Why doesn't the gradient appear on both objects after the execution of the script. Any ideas? PROCEDURE Gradient1; VAR SegmentIndex:INTEGER; h,i: HANDLE; BEGIN {---------------------------------------------Create gradient} h:= CreateGradient('Black-White'); SegmentIndex:=1; SetGradientData(h,SegmentIndex,0,0.5,0,0,0); SegmentIndex:=2; SetGradientData (h,SegmentIndex,.75,1,255,255,255); {-------------------------------Sets fill pattern to gradient} FillPat(-Name2Index('Black-White')); {-------------------------------------------------Create poly} ClosePoly; Poly(0,0, 0,100, -100,100, -100,0); SetFillOriginPoint(LNewObj,0,50); SetFillIAxisEndPoint(LNewObj,-100,50); {--------------------------------------------Create rectangle} Rect(0,0,100,100); Redraw; END; RUN (Gradient1); Quote Link to comment
MullinRJ Posted May 25, 2011 Share Posted May 25, 2011 Dave, ???I think you've found a bug. The gradient fill should display inside the Poly with the FillPat() setting. The OIP shows there is a gradient, but does not show it. It also fails for Ovals and Arcs. Only Rects seem to be showing the fill correctly. I'm going to submit a bug and reference this thread. ???I am not familiar with the commands SetFillOriginPoint() and SetFillIAxisEndPoint(). It seems like they should work for what you want, but don't, so I tried commands that I know will work. I've modified your code below. ???The offsets for the Gradient Origin are set with the FIll X and Fill Y Offsets and are relative to the object's center (which I originally found by trial and error). The Fill I-Axis Length is the width of the object in your case, since your fill is horizontal. If you set your fill at an angle, then you will need to specify Fill Y Offset (objVar 111) and Fill J-Axis Length (objVar 113) which in this case are both 0 by default. And note, the rotation angle of the Gradient (objVar 74) is specified in Radians, not Degrees. PROCEDURE Gradient2; CONST GradName = 'Black-White'; VAR SegmentIndex : INTEGER; hGrad : HANDLE; BEGIN {---------------------------------------------Create gradient} hGrad := GetObject(GradName); if (hGrad = nil) then hGrad := CreateGradient(GradName); SegmentIndex := 1; SetGradientData(hGrad, SegmentIndex, 0, 0.5, 0, 0, 0); SegmentIndex := 2; SetGradientData (hGrad, SegmentIndex, 0.75, 1, 255, 255, 255); {-------------------------------Sets fill pattern to gradient} FillPat(-Name2Index(GradName)); {--------------------------------------------Create rectangle} Rect(0, 0, 100, 100); { receives fill from FillPat() } {------------------------------------------------Create poly} ClosePoly; Poly(-100, 100, -100, 0, 0, 0, 0, 100); {-------These shouldn't be necessary, but they make the Poly fill show} SetObjectVariableReal (LNewObj, 110, -50); { Fill X Offset - relative to object center } SetObjectVariableReal (LNewObj, 112, 100); { Fill I-Axis Length } SetObjectVariableReal (LNewObj, 74, 0); { Fill Angle (radians) } SetObjectVariableLongInt (LNewObj, 78, 1); { Gradient Geometry Type - 1 = Linear } END; RUN (Gradient2); Raymond Quote Link to comment
DCarpenter Posted May 25, 2011 Author Share Posted May 25, 2011 I don't like finding bugs, but I do appreciate the work around solution, I'll make it work for my script. I really appreciate you taking the time to look into my little dilemma. Thanks for all your help. Dave Quote Link to comment
MullinRJ Posted May 26, 2011 Share Posted May 26, 2011 Dave, You are very welcome. I filed a bug report referencing this thread, so maybe it won't be a bug for long. The Rectangle and Rounded Rectangle seem to be the only shapes that receive the gradient fill from the FillPat() command. Arcs/Circles, Polys, Polylines and Ovals do not. For these shapes, use the manual method from above. Raymond Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.