Re: [racket-users] Re: ask a pict its colour?

2020-04-18 Thread Robby Findler
I basically agree with Alex, as the internal structures of pict don't
really keep information in that way, but a "best effort" might be to
draw it into a bitmap and then use the bitmap to find the average
color or the most common color (perhaps with some error bounds on what
colors count as "the same") or something like that.

Robby

On Sat, Apr 18, 2020 at 6:49 PM Alex Harsanyi  wrote:
>
>
> I don't think such a procedure can be written. at least not for the general 
> case.
>
> First, the color of `(filled-rectangle 30 30)` is not black, but whatever 
> color was installed in the drawing context when the filled rectangle was 
> rendered.  You can change it to red using:
>
> (colorize (filled-rectangle 20 20) "red")
>
> Even if you could inspect the colorize pict, it would still not be sufficient 
> for a general `get-color` function.  Users can write their own pict 
> constructors using dc:
>
>
> (define colors (list "red" "green" "blue" "yellow"))
>
> (define (my-red-colorize other-pict)
>   (dc (lambda (dc dx dy)
>
> (define color (list-ref colors (random (length colors
>
> (define old-pen (send dc get-pen))
> (send dc set-pen (new pen% [width 1] [color color]))
>
> (draw-pict other-pict dc dx dy)
>
> (send dc set-pen old-pen))
>   (pict-width other-pict)
>   (pict-height other-pict)))
>
> And a call like `(my-red-colorize (filled-rectangle 20 20))` will only result 
> in a red rectangle about 25% of the time.
>
> Even if you want to ignore cases like the above, what should `get-color` 
> return for the picture below?
>
> (hc-append (colorize (filled-rectangle 20 20) "red") (colorize 
> (filled-rectangle 20 20) "blue"))
>
>
> Alex.
>
>
> On Saturday, April 18, 2020 at 8:00:12 PM UTC+8, Raoul Schorer wrote:
>>
>> Hi,
>>
>> Using the 'pict' library, I could not find predicates regarding color in the 
>> doc.
>> Is there something like
>>
>> (get-color (filled-rectangle 30 30)) --> "black"
>>
>> somewhere?
>> If not, how can I make a reliable color predicate?
>>
>> Thanks,
>> Raoul
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/d3fa9021-63af-4129-bfb6-a82e219cfcf0%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAL3TdONPB16S1srT1%3Dz0ZPM52%3DZh624hrq5zOc7C4oerXqgaCA%40mail.gmail.com.


[racket-users] Re: ask a pict its colour?

2020-04-18 Thread Alex Harsanyi

I don't think such a procedure can be written. at least not for the general 
case.

First, the color of `(filled-rectangle 30 30)` is not black, but whatever 
color was installed in the drawing context when the filled rectangle was 
rendered.  You can change it to red using:

(colorize (filled-rectangle 20 20) "red")

Even if you could inspect the colorize pict, it would still not be 
sufficient for a general `get-color` function.  Users can write their own 
pict constructors using dc:


(define colors (list "red" "green" "blue" "yellow"))

(define (my-red-colorize other-pict)
  (dc (lambda (dc dx dy)

(define color (list-ref colors (random (length colors

(define old-pen (send dc get-pen))
(send dc set-pen (new pen% [width 1] [color color]))

(draw-pict other-pict dc dx dy)

(send dc set-pen old-pen))
  (pict-width other-pict)
  (pict-height other-pict)))

And a call like `(my-red-colorize (filled-rectangle 20 20))` will only 
result in a red rectangle about 25% of the time.

Even if you want to ignore cases like the above, what should `get-color` 
return for the picture below?

(hc-append (colorize (filled-rectangle 20 20) "red") (colorize 
(filled-rectangle 
20 20) "blue"))


Alex.


On Saturday, April 18, 2020 at 8:00:12 PM UTC+8, Raoul Schorer wrote:
>
> Hi,
>
> Using the 'pict' library, I could not find predicates regarding color in 
> the doc.
> Is there something like
>
> (get-color (filled-rectangle 30 30)) --> "black"
>
> somewhere?
> If not, how can I make a reliable color predicate?
>
> Thanks,
> Raoul
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/d3fa9021-63af-4129-bfb6-a82e219cfcf0%40googlegroups.com.


Re: [racket-users] DrRacket and command line arguments

2020-04-18 Thread David Storrs
Okay, so "edit the file" is the answer.  That works for me.  Thanks!

On Sat, Apr 18, 2020 at 2:30 PM Michael MacLeod 
wrote:

> You can parameterize `current-command-line-arguments` like so:
>
> ```
> #lang racket
>
> (require racket/cmdline)
>
> (define foo (make-parameter 7))
>
> (parameterize ([current-command-line-arguments #("--thing" "9")])
>   (command-line
>#:program "foo"
>#:once-each
>[("--thing") thing "The thing" (foo thing)])
>   (displayln (foo)))
> ```
>
> See the docs
> 
> for more information.
>
>
> On Sat, Apr 18, 2020 at 11:03 AM David Storrs 
> wrote:
>
>>
>> Is there a way to specify command line arguments when running inside
>> DrRacket?
>>
>> For example:
>>
>> #lang racket
>> (define foo (make-parameter 7))
>> (command-line
>>  #:program "foo"
>>  #:once-each
>>  [("--thing") thing "The thing" (foo thing)]
>>  )
>> (displayln (foo))
>>
>>
>> If running in DrRacket, how can I make this spit out 9 instead of 7?
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAE8gKocbjLNy%3D9S-g4HSc6WmOJf2TAsd7LOzbEYGQsm%3DYLGLAg%40mail.gmail.com
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKodKGSnJj4eXZX6rXpLA7yomBywMtakCGn_G6M5AM-JfKA%40mail.gmail.com.


Re: [racket-users] DrRacket and command line arguments

2020-04-18 Thread Michael MacLeod
You can parameterize `current-command-line-arguments` like so:

```
#lang racket

(require racket/cmdline)

(define foo (make-parameter 7))

(parameterize ([current-command-line-arguments #("--thing" "9")])
  (command-line
   #:program "foo"
   #:once-each
   [("--thing") thing "The thing" (foo thing)])
  (displayln (foo)))
```

See the docs

for more information.


On Sat, Apr 18, 2020 at 11:03 AM David Storrs 
wrote:

>
> Is there a way to specify command line arguments when running inside
> DrRacket?
>
> For example:
>
> #lang racket
> (define foo (make-parameter 7))
> (command-line
>  #:program "foo"
>  #:once-each
>  [("--thing") thing "The thing" (foo thing)]
>  )
> (displayln (foo))
>
>
> If running in DrRacket, how can I make this spit out 9 instead of 7?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKocbjLNy%3D9S-g4HSc6WmOJf2TAsd7LOzbEYGQsm%3DYLGLAg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CACehHmBKwf--7mBpuTtCEG9a_n2%3DBPP5g1sHtwwhjQUDJF8Bbw%40mail.gmail.com.


[racket-users] DrRacket and command line arguments

2020-04-18 Thread David Storrs
Is there a way to specify command line arguments when running inside
DrRacket?

For example:

#lang racket
(define foo (make-parameter 7))
(command-line
 #:program "foo"
 #:once-each
 [("--thing") thing "The thing" (foo thing)]
 )
(displayln (foo))


If running in DrRacket, how can I make this spit out 9 instead of 7?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKocbjLNy%3D9S-g4HSc6WmOJf2TAsd7LOzbEYGQsm%3DYLGLAg%40mail.gmail.com.


[racket-users] ask a pict its colour?

2020-04-18 Thread Raoul Schorer
Hi,

Using the 'pict' library, I could not find predicates regarding color in 
the doc.
Is there something like

(get-color (filled-rectangle 30 30)) --> "black"

somewhere?
If not, how can I make a reliable color predicate?

Thanks,
Raoul

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/d018765d-7cd7-4dd5-8cf1-3fc3fccc397d%40googlegroups.com.


[racket-users] Error building racket BC snapshot from source

2020-04-18 Thread bedeke
Hello,

I was trying to build racket snapshot using the using the files on the utah 
server[1].
Afterwards I basically do make && make DESTDIR="${pkgdir}" install

This is part of a PKGBUILD script I have been using reliably on arch for 
the last few years.
However somewhere around the beginning of this month it didn't work, 
Complaining about references
to Chez-Scheme [3]
Using the files on the northwestern server[2], this script does work.
Have the make commands changed?


[1]: 
http://www.cs.utah.edu/plt/snapshots/current/installers/racket-current-src-builtpkgs.tgz
[2]: 
https://plt.eecs.northwestern.edu/snapshots/current/installers/racket-test-current-src-pre-built.tgz
[3]: last part of build output
make[4]: Entering directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
make install-wx_xt
make[5]: Entering directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
make install-common
make[6]: Entering directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
:
make[6]: Leaving directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
cd ..; rm -f "/home/bert/builds/racket-snap/pkg/racket/usr/lib/gracketcgc"
cd ..; rm -f "/home/bert/builds/racket-snap/pkg/racket/usr/lib/gracket"
cd ..; echo 'MROPTIONS=' >> 
"/home/bert/builds/racket-snap/pkg/racket/usr/lib/buildinfo"
cd ..; echo "MRLIBS=" >> 
"/home/bert/builds/racket-snap/pkg/racket/usr/lib/buildinfo"
cd ..; echo "MRLDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro -pthread 
-L../racket" >> "/home/bert/builds/racket-snap/pkg/racket/usr/lib/buildinfo"
cd ..; mkdir -p "/home/bert/builds/racket-snap/pkg/racket/usr/lib";
make[5]: Leaving directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
make install-wx_xt-3m
make[5]: Entering directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
make install-lib-3m-wx_xt
make[6]: Entering directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
:
make[6]: Leaving directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
cd ..; libtool --mode=install cp gracket/gracket3m 
"/home/bert/builds/racket-snap/pkg/racket/usr/lib/gracket"
libtool: install: cp gracket/.libs/gracket3m 
/home/bert/builds/racket-snap/pkg/racket/usr/lib/gracket
cd ..; strip "/home/bert/builds/racket-snap/pkg/racket/usr/lib/gracket"
../racket/racket3m  -cu 
"/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/../gracket/../racket/collects-path.rkt"
 
"/home/bert/builds/racket-snap/pkg/racket/usr/lib/gracket" ../collects 
../etc
make[5]: Leaving directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
make install-wx_xt-3m-final
make[5]: Entering directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
:
make[5]: Leaving directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
make[4]: Leaving directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/gracket'
make[3]: Leaving directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build'
make install-common-middle
make[3]: Entering directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build'
make copytree-run
make[4]: Entering directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build'
racket/racketcgc  -u \
  
"/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/../../collects/setup/unixstyle-install.rkt"
 
\
  make-install-copytree 
"/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build/../.." \
  "/home/bert/builds/racket-snap/pkg/racket/usr/bin" 
"/home/bert/builds/racket-snap/pkg/racket/usr/collects" 
"/home/bert/builds/racket-snap/pkg/racket/usr/doc" 
"/home/bert/builds/racket-snap/pkg/racket/usr/lib" 
"/home/bert/builds/racket-snap/pkg/racket/usr/include" 
"/home/bert/builds/racket-snap/pkg/racket/usr/lib" 
"/home/bert/builds/racket-snap/pkg/racket/usr/share" 
"/home/bert/builds/racket-snap/pkg/racket/usr/etc" 
"/home/bert/builds/racket-snap/pkg/racket/usr/share/applications" 
"/home/bert/builds/racket-snap/pkg/racket/usr/man" "yes"
read-compiled-linklet: virtual-machine mismatch  expected: "racket"  found: 
"chez-scheme"  in: 
/home/bert/builds/racket-snap/src/racket-7.7.0.2/collects/setup/compiled/unixstyle-install_rkt.zo
  context...:
   read-linklet-or-directory
   read-dispatch
   read-syntax
   default-load-handler
   standard-module-name-resolver
   module-path-index-resolve
   [repeats 1 more time]
   module-declared?
make[4]: *** [Makefile:163: copytree-run] Error 1
make[4]: Leaving directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build'
make[3]: *** [Makefile:142: install-common-middle] Error 2
make[3]: Leaving directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build'
make[2]: *** [Makefile:196: install-3m-common] Error 2
make[2]: Leaving directory 
'/home/bert/builds/racket-snap/src/racket-7.7.0.2/src/build'
make[1]