2022-12-20 01:45 AM - last edited on 2023-01-16 09:56 AM by Daniel Kassai
I've reached a dead-end and can't work this out. It's a first for me using the POLY2_B{2} command and I'm trying to set the fill origin for a fill to the center of the fill. I've got the j4(8) code in the frame fill it responds to changes in the origin variables.
However, before drawing the fill several cursor movements are made to get to that point. Now when the fill is drawn the origin is all over the place. I've included a test object code below (no parameters required) which shows this. There's a loop that draws the fill, rotates 90° and draws the fill again. Drawing it 4 times. The origin is in the center and everything is good.
But then a simple ADD2 1,1 is added before the loop. Now the fill's origins are off by 200mm for each iteration of the loop in one or both the x & y directions. If I throw in an angle for the fill origin it gets even more confusing. I had assumed the fill origin x / y coordinates would be based off the cursor position, but that's not the case. Does anyone know what's going on here? Or do I need to draw the fills without any movement commands? Thanks,
x1 = 0
x2 = 4
y1 = 2
y2 = 4
fill_x = (x2-x1)/2+x1
fill_y = (y2-y1)/2+y1
HOTSPOT2 0,0 !!==== CENTER PRE MOVE
!ADD2 1,1 !!==== TURN THIS ON / OFF
HOTSPOT2 0,0 !!==== CENTER AFTER MOVE
FILL 127
FOR i = 1 TO 4
fillosx = 0 !!=== USED TO TEST EDITING THE ORIGIN
fillosy = 0
rot_angle = 0
! IF i = 2 THEN !!=== USED TO TEST EDITING THE ORIGIN FOR EACH LOOP
! fillosy = -0.200
! rot_angle = 0
! ENDIF
! IF i = 3 THEN
! fillosx = -0.200
! fillosy = -0.200
! rot_angle = 0
! ENDIF
! IF i = 4 THEN
! fillosx = -0.200
! rot_angle = 0
! ENDIF
HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2
HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{2} 5, 1+2+4+8, 1, 19, fill_x +fillosx, fill_y +fillosy, rot_angle,
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 90
NEXT i
Solved! Go to Solution.
2022-12-20 02:52 AM - edited 2022-12-20 04:22 AM
Hi,
don't confuse what you think you see with what you should look at.
if you explode the object (Ctrl+=) then you see the origin is off by 1mx1m.(i added in a slight rotation and a larger scaled fill to pick this up)
because the temp origin is being calculated then
ox = 3 !!==== move any amount
oy = 1 !!==== move any amount
x1 = 0
x2 = 4
y1 = 2
y2 = 4
fill_x = (x2-x1)/2+x1
fill_y = (y2-y1)/2+y1
line2 0,0,1,0.25
HOTSPOT2 0,0 !!==== CENTER PRE MOVE
ADD2 ox,oy !!==== move any amount
HOTSPOT2 0,0 !!==== CENTER AFTER MOVE
FILL fillAttribute_1
FOR i = 1 TO 4
fillosx = -ox +ox !!==== move back to the origin then move forward in the new direction
fillosy = -oy +oy !!==== move back to the origin then move forward in the new direction
rot_angle = 11
IF i = 2 THEN !!=== USED TO TEST EDITING THE ORIGIN FOR EACH LOOP
fillosx = -ox+oy !!==== move back to the origin then move forward in the new rotated direction
fillosy = -oy -ox !!==== move back to the origin then move forward in the new rotated direction
ENDIF
IF i = 3 THEN
fillosx = -ox -ox !!==== move back to the origin then move forward in the new rotated direction
fillosy = -oy -oy !!==== move back to the origin then move forward in the new rotated direction
ENDIF
IF i = 4 THEN
fillosx = -ox-oy !!==== move back to the origin then move forward in the new rotated direction
fillosy = -oy+ox !!==== move back to the origin then move forward in the new rotated direction
ENDIF
HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2
HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{2} 5, 1+2+4+8, 1, 19, fill_x +fillosx, fill_y +fillosy, rot_angle,
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 90
NEXT i
I hope this explains the strange behavior .
you could use sin and cos for non 90degree angles
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
fillosx = -ox +ox*cos(rotangle)+oy*sin(rotangle)
fillosy = -oy +oy*cos(rotangle)-ox*sin(rotangle)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
i.e.
i_angle = 30
rotangle = 0
FOR i = 1 TO 4
rot_angle = 11
fillosx = -ox +ox*cos(rotangle)+oy*sin(rotangle)
fillosy = -oy +oy*cos(rotangle)-ox*sin(rotangle)
HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2
HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{2} 5, 1+2+4+8, 1, 19, fill_x +fillosx, fill_y +fillosy, rot_angle,
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 i_angle
rotangle = rotangle +i_angle
NEXT i
or you can jump to POLY2_B{3} where the problem doesn't exist....
FOR i = 1 TO 4
rot_angle = 11
HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2
HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{3} 5, 1+2+4+8, 1, 19, fill_x , fill_y ,!!!!! rot_angle,replaced by next 4 values
1*cos(rot_angle),1*sin(rot_angle),0-1*sin(rot_angle),1*cos(rot_angle),
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 i_angle
NEXT i
2022-12-20 02:52 AM - edited 2022-12-20 04:22 AM
Hi,
don't confuse what you think you see with what you should look at.
if you explode the object (Ctrl+=) then you see the origin is off by 1mx1m.(i added in a slight rotation and a larger scaled fill to pick this up)
because the temp origin is being calculated then
ox = 3 !!==== move any amount
oy = 1 !!==== move any amount
x1 = 0
x2 = 4
y1 = 2
y2 = 4
fill_x = (x2-x1)/2+x1
fill_y = (y2-y1)/2+y1
line2 0,0,1,0.25
HOTSPOT2 0,0 !!==== CENTER PRE MOVE
ADD2 ox,oy !!==== move any amount
HOTSPOT2 0,0 !!==== CENTER AFTER MOVE
FILL fillAttribute_1
FOR i = 1 TO 4
fillosx = -ox +ox !!==== move back to the origin then move forward in the new direction
fillosy = -oy +oy !!==== move back to the origin then move forward in the new direction
rot_angle = 11
IF i = 2 THEN !!=== USED TO TEST EDITING THE ORIGIN FOR EACH LOOP
fillosx = -ox+oy !!==== move back to the origin then move forward in the new rotated direction
fillosy = -oy -ox !!==== move back to the origin then move forward in the new rotated direction
ENDIF
IF i = 3 THEN
fillosx = -ox -ox !!==== move back to the origin then move forward in the new rotated direction
fillosy = -oy -oy !!==== move back to the origin then move forward in the new rotated direction
ENDIF
IF i = 4 THEN
fillosx = -ox-oy !!==== move back to the origin then move forward in the new rotated direction
fillosy = -oy+ox !!==== move back to the origin then move forward in the new rotated direction
ENDIF
HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2
HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{2} 5, 1+2+4+8, 1, 19, fill_x +fillosx, fill_y +fillosy, rot_angle,
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 90
NEXT i
I hope this explains the strange behavior .
you could use sin and cos for non 90degree angles
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
fillosx = -ox +ox*cos(rotangle)+oy*sin(rotangle)
fillosy = -oy +oy*cos(rotangle)-ox*sin(rotangle)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
i.e.
i_angle = 30
rotangle = 0
FOR i = 1 TO 4
rot_angle = 11
fillosx = -ox +ox*cos(rotangle)+oy*sin(rotangle)
fillosy = -oy +oy*cos(rotangle)-ox*sin(rotangle)
HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2
HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{2} 5, 1+2+4+8, 1, 19, fill_x +fillosx, fill_y +fillosy, rot_angle,
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 i_angle
rotangle = rotangle +i_angle
NEXT i
or you can jump to POLY2_B{3} where the problem doesn't exist....
FOR i = 1 TO 4
rot_angle = 11
HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2
HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{3} 5, 1+2+4+8, 1, 19, fill_x , fill_y ,!!!!! rot_angle,replaced by next 4 values
1*cos(rot_angle),1*sin(rot_angle),0-1*sin(rot_angle),1*cos(rot_angle),
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 i_angle
NEXT i
2022-12-20 03:33 AM
That made me think of Obi-Wan - "Your eyes deceive you. Don't trust them". Exploding the object to find the actual origin is a nice trick I hadn't thought of.
Attached is an image of the exploded fills from the object I'm working on. It's one fill command that sits within two loops. Now that I know where the actual origins are, I'm considering if I should spend the time to work out how to control these fills. Or just change the script to draw some lines over the top and make it look like the fill I need.
Thanks again for the help.
2022-12-20 04:38 AM - edited 2022-12-20 04:59 AM
sorry, had school run, last day of term, didn't have time to finish the post.
just go for POLY2_B{3} which uses "Distorted fill" settings rather than "rotation relative to fill origin" setting for POLY2_B{2}.