Shop OBEX P1 Docs P2 Docs Learn Events
COnversion to hex — Parallax Forums

COnversion to hex

edited 2007-06-25 19:42 in Propeller 1
I'm trying to use the arc function in the graphics pack:

PUB arc(x, y, xr, yr, angle, anglestep, steps, arcmode)

'' Draw an arc
''
'' x,y - center of arc
'' xr,yr - radii of arc
'' angle - initial angle in bits[noparse][[/noparse]12..0] (0..$1FFF = 0°..359.956°)
'' anglestep - angle step in bits[noparse][[/noparse]12..0]
'' steps - number of steps (0 just leaves (x,y) at initial arc position)
'' arcmode - 0: plot point(s)
'' 1: line to point(s)
'' 2: line between points
'' 3: line from point(s) to center


and it wants an angle value in HEX. I have the value stored in a byte variable (0-255) so how do I convert that to a hex value with a range of 0-$1FFF, so the function can read it?

Comments

  • CardboardGuruCardboardGuru Posts: 443
    edited 2007-06-25 08:59
    Do you mean it's stored in the byte value so that 0-255 is a complete revolution? If so you need to shift bits to the left 5 times.

    byte_value<<5
  • deSilvadeSilva Posts: 2,967
    edited 2007-06-25 19:42
    This is probably a misunderstanding: the parameter expects a FULL CIRCLE as $1fff = around 8.000

    If you talk - using some peculiar Sumerian convention - in terms of 360 degrees for the FULL CIRCLE, just convert your value X by X* constant($1fff/36o)
    Ps: You can improve precision A LITTLE BIT by doing X * $1fff/360

    Post Edited (deSilva) : 6/25/2007 7:48:03 PM GMT
Sign In or Register to comment.