×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    10

    DirectGraphics and fillarc

    Can I do a fillarc with DirectGraphics? If so, how? I want to 'cut out' a circle in some graphics to leave a transparent 'hole'

    Also, where is the best documentation for DirectGraphics?

    Thanks in advance

    Moray

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    38

    RE: DirectGraphics and fillarc

    Hi.
    The method fillArc is in the javax.microedition.lcdui.Graphics, thus it's part of the MIDP standard profile. When you invoke it you have to use a Graphics Object and not a DirectGraphics Object (DirectGraphics does not implement any fillArc method).
    Of course you can use an ARGB color to fill your arc (i.e. can use transparent values) adopting the setARGBColor(int argbColor) defined in the DirectGraphics Interface instead of the setColor in javax.microedition.lcdui.Graphics.
    Unfortunetely there's no way to use the fillArc method so that it can display a "donut" shape.
    The first thing that comes to my mind to achieve this result is to use the setPixel method in com.nokia.mid.ui DirectGraphics after you've drawn your circle, "cutting up" a central circle setting those pixels to fully transparent (where supported).

    You can find documentation (and code) on how you can achieve this result in the "Nokia_UIAPI_Guide.pdf" (there's just an example on how to create a color checkerboard image with a transparent hole in the center.

    Hope this can help
    regards

    davide
    <AtomicTag.com/>

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    38

    RE: DirectGraphics and fillarc

    Hi. Don't worry! =)
    A few remarks:
    1. - if youre using an emulator sometimes transparency its completely ignored (Concept Beta Series 60 for instance) even if your code is correct (and works on the real device).
    2. - When you use an ARGB color with fillPolygon, fillTriangle and so on you gotta use a proper 32 bit color in 0xAARRGGBB format in order to get the color you want (i.e. a fully opaque blue color is not 0xF00F but 0xFF0000FF). See the post "com.nokia.mid.ui.DirectGrap hics.fillPoly trouble" posted yesterday on this forum.
    3. - Whatever you do, if you paint a transparent shape over a filled shape it doesn't cut it away (because an overlapping shape does not change the underline pixels!). I.E. if you draw correctly a fully transparent shape over an image and test it on the actual device you won't see anything overlapping your image (neither filled a shape nor a "hole&quot.
    3 - I'm afraid you have to deal with pixels manipulation methods to achieve your goal ("the donut&quot.
    Hope this helps

    cheers
    davide
    <Atomictag.com/>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×