Home   Archive   Permalink



Draw dialect question about arc

If you thought the documentation for the Visual Interface Dialect was bad, you should try the Draw Dialect.
    
Anyway, I am trying to understand the 'arc' command. It has a bunch of numbers after it. What could they mean. A sample script is below. It appears that after the keyword 'arc,' we have, in order, 1) a pair to indicate the center of the arc, in pixels, relative to the face upon which the arc is drawn, 2) a pair where the X value is the length, in pixels, of the first ('left' so to speak) leg of the arc and the 'Y' value is the length of the 'right' or 'ending' edge of the arc, 3) a number which is the direction of the 'left' or starting leg, in degrees, with zero meaning horizontally to the right like the coordinate system in algebra, and 4) a number indicating the number of degrees between the two edges of the arc.    
    
I have made the following demo to test this hypothesis, and the demo doesn't match up with my understanding. If my understanding is correct, then arc number three which has a starting edge of 50 pixels pointed straight down at 90 degrees should look like arc number four, and four should look like three. What am I missing?
    
Thank you. Demo follows.
    
R E B O L [
     title: 'Test harness'
]
    
;; [---------------------------------------------------------------------------]
;; [ Test the 'draw' functions.                                                ]
;; [---------------------------------------------------------------------------]
    
view center-face layout [
     across
     box 800x200 black effect [
         draw [
         arc 100x100 50x100 0 100 closed
         arc 300x100 100x50 0 100 closed
         arc 500x100 50x100 90 100 closed
         arc 700x100 100x50 90 100 closed
         ]
     ]
     return
     box 200x20 '1: 50x100 0 100' font [color: black shadow: none]
     box 200x20 '2: 100x50 0 100' font [color: black shadow: none]
     box 200x20 '3: 50x100 90 100' font [color: black shadow: none]
     box 200x20 '4: 100x50 90 100' font [color: black shadow: none]
     return
     button 'Quit' [quit]
]


posted by:   Steven White       20-May-2016/15:15:21-7:00



Don't know if it helps, but here it is anyway.
    
R E B O L [title: "Arc test"]
    
drw: [
    'arc 100x100
    as-pair 100 * s1/data 100 * s2/data
    360 * s3/data
    360 * s4/data
    'closed
]
act: [b/effect: reduce ['draw reduce drw] show b]
view center-face layout [
    b: box 200x200 black
    style sld slider 200x20 act
    label "r/x (0-100)"
    s1: sld 0.5
    label "r/y (0-100)"
    s2: sld 0.5
    label "begin (0-360)"
    s3: sld
    label "length (0-360)"
    s4: sld 0.5
    do act
]


posted by:   Gorf       23-May-2016/22:35:54-7:00



Thank you. I modified your example as shown below to make it easier for me to probe the arc numbers, and I believe I have an explanation.
    
The first pair after the "arc" keyword is the center of the arc in relation to the face upon which it is drawn.
    
The second pair after the "arc" keyword indicates the X-direction and Y-direction "boundaries" so to speak for the arc. The X value is the number of pixels in the X direction, on both sides of the center, beyond which the are can not go. The Y value functions similarly for the Y dimension.
    
The next single number indicates the angle of the "starting" vector of the arc, with zero being straight out to the right and increasing values representing increasing angles in the clockwise direction.
    
The final number is the "length" of the arc, which basically means the angle between the starting vector and the ending vector.    
    
I don't know if that is right, but it does seem to explain things.
    
R E B O L [title: "Arc test"]
    
;; Put the various arc-defining numbers here so we can probe them
;; and display them.
    
ARC-CENTER: 100X100
MAX-X: 0
MAX-Y: 0
START-ANGLE: 0
ARC-LENGTH: 0
        
drw: [
     'arc ARC-CENTER
     as-pair MAX-X MAX-Y
     START-ANGLE
     ARC-LENGTH
     'closed
]
    
act: [
     MAX-X: to-integer 100 * s1/data
     MAX-Y: to-integer 100 * s2/data
     START-ANGLE: to-integer 360 * s3/data
     ARC-LENGTH: to-integer 360 * s4/data
     b/effect: reduce [
         'draw reduce drw
     ]
     show b
     THE-NUMBERS/text: rejoin [
         MAX-X
         "X"
         MAX-Y
         " "
         START-ANGLE
         " "
         ARC-LENGTH
     ]
     show THE-NUMBERS
]
    
view center-face layout [
     b: box 200x200 black
     THE-NUMBERS: text 200 font [color: black shadow: none size: 14 style: 'bold]
     style sld slider 200x20 act
     label "r/x (0-100)" font [color: black shadow: none]
     s1: sld 0.5
     label "r/y (0-100)" font [color: black shadow: none]
     s2: sld 0.5
     label "begin (0-360)" font [color: black shadow: none]
     s3: sld
     label "length (0-360)" font [color: black shadow: none]
     s4: sld 0.5
     do act
]
    


posted by:   Steven White       31-May-2016/15:39:19-7:00



I believe your explanation is correct.
There is no problem you can't solve with a few sliders.
    
Irrelevant side issue: Below is a perhaps better way of updating the draw block.
    
R E B O L [title: "Arc test"]
        
drw: [
     'arc 100x100
     as-pair 100 * s1/data 100 * s2/data
     360 * s3/data
     360 * s4/data
     'closed
]
act: [change b/effect/draw reduce drw show b]
view center-face layout [
     b: box 200x200 black effect [draw []]
     style sld slider 200x20 act
     label "r/x (0-100)"
     s1: sld 0.5
     label "r/y (0-100)"
     s2: sld 0.5
     label "begin (0-360)"
     s3: sld
     label "length (0-360)"
     s4: sld 0.5
     do act
]


posted by:   Gorf       31-May-2016/20:58:08-7:00



act: [change b/effect/draw reduce drw show b]
    
Skip 'change', just use assignment.

posted by:   Ebbot       1-Jun-2016/0:02:15-7:00