public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Arie van Wingerden <xapwing@gmail.com>, kawa@sourceware.org
Subject: Re: Need some help with Java - Kawa interop
Date: Fri, 02 Nov 2018 05:08:00 -0000	[thread overview]
Message-ID: <dbdb88ea-e0b5-078d-a822-0acb47066929@bothner.com> (raw)
In-Reply-To: <CADkALSGg=9RURk9-kG6qGPMUUx4fnJeQEdP0BQFX+4AJOX__yw@mail.gmail.com>

On 11/1/18 6:44 AM, Arie van Wingerden wrote:
> Trying to generate a random color for a shape in JavaFX.
> This (lines 7-9 are the binding of r, g and b):
> 
>> (define (randomColor)
>    (let (
>      (rnd ((java.lang.Math:random))
>      (r (java.util.Random:nextInt 255))
>      (g (java.util.Random:nextInt 255))
>      (b (java.util.Random:nextInt 255)))
>    (Color:rgb r g b)))

nextInt is not  static method, so you need an instance.

(define (randomColor)
   (let* ((rnd (java.util.Random))
          (r (rnd:nextInt 255))
          (g (rnd:nextInt 255))
          (b (rnd:nextInt 255)))
     (java.awt.Color r g b)))


-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

      reply	other threads:[~2018-11-02  5:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01 13:45 Arie van Wingerden
2018-11-02  5:08 ` Per Bothner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dbdb88ea-e0b5-078d-a822-0acb47066929@bothner.com \
    --to=per@bothner.com \
    --cc=kawa@sourceware.org \
    --cc=xapwing@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).