×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    18

    J2me Gradient colors

    Hi all,

    I want to ask how we can fill j2me primitive shapes (arc, rect, triangle, round rect) with gradient color?

    is this possible?

    if so how?

    Regards,

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: J2me Gradient colors

    Quote Originally Posted by omarhassan123 View Post
    Hi all,

    I want to ask how we can fill j2me primitive shapes (arc, rect, triangle, round rect) with gradient color?

    is this possible?

    if so how?

    Regards,
    yes, it is possible ref to FN Wiki example - http://wiki.forum.nokia.com/index.ph...ent_in_Java_ME

    and also - http://www.j2meforums.com/forum/inde...prev_next=next
    Thanks,
    Ekta

  3. #3
    Registered User
    Join Date
    Jun 2010
    Posts
    18

    Re: J2me Gradient colors

    Quote Originally Posted by ektasrv View Post
    i tried the example on FN but the color change on it is not smooth like the gradient made by GradientPaint in jse,

    and also it only draw lines, how i can draw an arc using those lines?

    Thanks,
    Omar

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: J2me Gradient colors

    Quote Originally Posted by omarhassan123 View Post
    i tried the example on FN but the color change on it is not smooth like the gradient made by GradientPaint in jse,

    and also it only draw lines, how i can draw an arc using those lines?

    Thanks,
    Omar
    Arc is already a problem are of j2me it differs in look on various devices & emulators, so better you go gradient filled objects jpg or svg images.
    Thanks,
    Ekta

  5. #5
    Registered User
    Join Date
    Jun 2010
    Posts
    18

    Re: J2me Gradient colors

    Quote Originally Posted by ektasrv View Post
    Arc is already a problem are of j2me it differs in look on various devices & emulators, so better you go gradient filled objects jpg or svg images.
    can't we draw these arcs as a successive line which can finally make the arc shape?

  6. #6
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: J2me Gradient colors

    Quote Originally Posted by omarhassan123 View Post
    can't we draw these arcs as a successive line which can finally make the arc shape?
    You can try this, successive line in different colors...for some people it worked well on emulator but had shown some empty pixels on some device.
    Thanks,
    Ekta

  7. #7
    Registered User
    Join Date
    Jun 2010
    Posts
    18

    Re: J2me Gradient colors

    Quote Originally Posted by ektasrv View Post
    You can try this, successive line in different colors...for some people it worked well on emulator but had shown some empty pixels on some device.
    do you know an algorithm for drawing those lines?

  8. #8
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: J2me Gradient colors

    refer to Fn Wiki - http://wiki.forum.nokia.com/index.ph...vas_in_Java_ME

    Useing drawArc, changing color by 1 of RGB value by +1 everytime and changing height,width of Arc below you can try get it.


    public void drawArc(int x,
    int y,
    int width,
    int height,
    int startAngle,
    int arcAngle)
    Draws the outline of a circular or elliptical arc covering the specified rectangle, using the current color and stroke style.
    The resulting arc begins at startAngle and extends for arcAngle degrees, using the current color. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation.

    The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the width and height arguments.

    The resulting arc covers an area width + 1 pixels wide by height + 1 pixels tall. If either width or height is less than zero, nothing is drawn.

    The angles are specified relative to the non-square extents of the bounding rectangle such that 45 degrees always falls on the line from the center of the ellipse to the upper right corner of the bounding rectangle. As a result, if the bounding rectangle is noticeably longer in one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the bounds.

    Parameters:
    x - the x coordinate of the upper-left corner of the arc to be drawn
    y - the y coordinate of the upper-left corner of the arc to be drawn
    width - the width of the arc to be drawn
    height - the height of the arc to be drawn
    startAngle - the beginning angle
    arcAngle - the angular extent of the arc, relative to the start angle
    See Also:
    fillArc(int, int, int, int, int, int)
    Thanks,
    Ekta

  9. #9
    Registered User
    Join Date
    Jun 2010
    Posts
    18

    Re: J2me Gradient colors

    Quote Originally Posted by ektasrv View Post
    refer to Fn Wiki - http://wiki.forum.nokia.com/index.ph...vas_in_Java_ME

    Useing drawArc, changing color by 1 of RGB value by +1 everytime and changing height,width of Arc below you can try get it.


    public void drawArc(int x,
    int y,
    int width,
    int height,
    int startAngle,
    int arcAngle)
    Draws the outline of a circular or elliptical arc covering the specified rectangle, using the current color and stroke style.
    The resulting arc begins at startAngle and extends for arcAngle degrees, using the current color. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation.

    The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the width and height arguments.

    The resulting arc covers an area width + 1 pixels wide by height + 1 pixels tall. If either width or height is less than zero, nothing is drawn.

    The angles are specified relative to the non-square extents of the bounding rectangle such that 45 degrees always falls on the line from the center of the ellipse to the upper right corner of the bounding rectangle. As a result, if the bounding rectangle is noticeably longer in one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the bounds.

    Parameters:
    x - the x coordinate of the upper-left corner of the arc to be drawn
    y - the y coordinate of the upper-left corner of the arc to be drawn
    width - the width of the arc to be drawn
    height - the height of the arc to be drawn
    startAngle - the beginning angle
    arcAngle - the angular extent of the arc, relative to the start angle
    See Also:
    fillArc(int, int, int, int, int, int)
    Thanks a lot Ektasrv for your help

    Omar,

Similar Threads

  1. plz help me in this doubt regarding colors in j2me
    By kumarv75 in forum Mobile Java General
    Replies: 3
    Last Post: 2010-06-05, 07:45
  2. Gradient
    By j.teixeira in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2007-03-15, 00:28
  3. Gradient Colors
    By roopa_ckr in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-10-12, 13:37
  4. how many colors in J2ME and phone
    By ffunus in forum Mobile Java General
    Replies: 1
    Last Post: 2004-04-11, 23:55
  5. Doing a gradient fill
    By nkn_aikon in forum Symbian User Interface
    Replies: 1
    Last Post: 2001-11-28, 21:23

Posting Permissions

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