Re: [racket-users] Color Arithmetic
Il giorno 04/giu/2015, alle ore 23.59, Jens Axel Søgaard ha scritto:2015-06-04 11:38 GMT+02:00 Michael Tiedtke michael.tied...@o2online.de:Before I go ahead and just do it I wanted to ask:1) Does such a thing exist somewhere for Scheme or Racket (I couldn't find anything) The only example I found was:https://www.wolframalpha.com/examples/ColorArithmetic.htmlFWIW here is a few color related functions/utilities:Docs:http://soegaard.github.io/docs/metapict/metapict.html#%28part._ref-colors%29Code: https://github.com/soegaard/metapict/blob/master/metapict/color.rktAlso: https://github.com/mbutterick/css-tools/blob/master/colors.rkt/Jens AxelThank you! After having a second thought about colors I'm pretty sure that1) RGB components or tuples as they have been called already are color distances and can be treated like vectors, which we're all doing anyway. I suppose they are defined as distances to the white point but the origin of the RGB24 space is black. Perhaps it is not a completely defined vector space but subtract, add, scalar product / division are there and useful. The color subtraction is the color distance: it might even be the mathematical representation of color contrast (within the color space). The cross product might not be useful but ...2) when calculating with colors as such vectors we're already doing "compositing" - the alfa channel is part of the compositing pipeline and not a dimension of the color space. That's why it has to be treated seperately.3) RGB24 is a low level byte-based hardware color space implementation. I have now defined a new "schemisher" exact color space on-top of it which allows to do exact compositing and leaves behind the byte boundary and it's integer limitations. Perhaps I will have a look at the color class (color%) to bring in these computational colors but perhaps others know how to extend that hardware color class color% better than me.4) it's better to put hard limits on what can go into the hardware. That's why my integer-bytedoes not allow out of bounds values. Fault tolerant versions like make-color* from metapict are still useful though. Why not put it into color%? -- 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. For more options, visit https://groups.google.com/d/optout. delta-color.rkt Description: Binary data -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] (fifth RacketCon) Second Call for Speakers
On 2015-06-04 18:39:39 -0500, Vincent St-Amour wrote: (fifth RacketCon) will be held on September 27th in St. Louis. Like last year, we are pleased to be co-located with Strange Loop [3]. BTW, Strange Loop's registration[1] opens next week on June 11 for anyone who is considering going to both SL and RacketCon. Students in particular will want to register quickly after opening because they sold out quickly last year. Plus Matthias is giving a talk[2] at SL this year. [1]: http://www.thestrangeloop.com/register.html [2]: http://www.thestrangeloop.com/2015/big-bang-the-world-the-universe-and-the-network-in-the-programming-language.html Cheers, Asumu -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] racket virtual machine
Thanks, Jens Axel, Raoul, and Robby. Different question... For support for writing polished Web browser (and PhoneGap) apps in Racket, any comments on which of the following two options is better (viable, easier to implement and maintain, better performance, etc.)? 1. Implement Racket VM in JS, along with implementing support libraries in JS, and interpret `.zo` files at runtime. 2. Forget about `eval`, require apps to be compilable on development host (but not necessarily runnable there), implement compiler from `.zo` to JS (managing TCO, etc.), implement small Racket runtime library in JS, implement browser facilities and/or GUI libraries in JS. Later think about `eval`.[*] [*] I've only done a very brief peek at sample `zo-parse` and `decompile` output, so I don't know how tricky it can get, but the little I saw looked like a static translation to JS wouldn't be too difficult. I don't know how necessary `eval` is if you have bytecode, nor how much of the primitives would have to be implemented manually rather than translated from `.zo`. Neil V. -- 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. For more options, visit https://groups.google.com/d/optout.
[racket-users] (fifth RacketCon) Second Call for Speakers
The schedule for (fifth RacketCon) [1] is starting to take shape, but we still have room for more speakers. If you've built something cool with Racket, we want to hear about it! We're looking for speakers to give 15 minute talks about their Racket-based applications, libraries, etc. If that sounds like fun, let me know! Even if you'd prefer not to speak, we'd love to have you join us. Registration is open! [2] (fifth RacketCon) will be held on September 27th in St. Louis. Like last year, we are pleased to be co-located with Strange Loop [3]. RacketCon is a yearly event where members of the Racket community get together, featuring talks and demos about the things you do with Racket. See you in St. Louis! Vincent [1] http://con.racket-lang.org/ [2] https://www.eventbrite.com/e/racketcon-2015-tickets-16825218682 [3] https://thestrangeloop.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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Color Arithmetic
2015-06-04 11:38 GMT+02:00 Michael Tiedtke michael.tied...@o2online.de: Before I go ahead and just do it I wanted to ask: 1) Does such a thing exist somewhere for Scheme or Racket (I couldn't find anything) The only example I found was: https://www.wolframalpha.com/examples/ColorArithmetic.html FWIW here is a few color related functions/utilities: Docs: http://soegaard.github.io/docs/metapict/metapict.html#%28part._ref-colors%29 Code: https://github.com/soegaard/metapict/blob/master/metapict/color.rkt Also: https://github.com/mbutterick/css-tools/blob/master/colors.rkt /Jens Axel -- 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. For more options, visit https://groups.google.com/d/optout.
RE: [racket-users] defform quastion
Hi Mathhew, Thanks very much. I am sorry I did not see code:line by myself. Jos -Original Message- From: Matthew Flatt [mailto:mfl...@cs.utah.edu] Sent: jueves, 04 de junio de 2015 17:01 To: Jos Koot Cc: 'Racket-Users List' Subject: Re: [racket-users] defform quastion You can use `code:line` to group terms without parentheses: (code:line addition + term) At Thu, 4 Jun 2015 16:53:33 +0200, Jos Koot wrote: Hi, I have tried to use defform of scribble to describe the following: syntax ($ infix-expr) → any infix-expr ::= addition addition ::= term addition ::= addition + term addition ::= addition - term term ::= etc. Using #:grammar I can easily get: addition = term | (addition + term) | (addition - term) but I don't want the parentheses and I don't know how to get rid of them. Is it possible to generate something like: infix-expr = addition addition = term | addition + term | addition - term If it is possible, help me please. Thanks, Jos -- 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. For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] defform quastion
You can use `code:line` to group terms without parentheses: (code:line addition + term) At Thu, 4 Jun 2015 16:53:33 +0200, Jos Koot wrote: Hi, I have tried to use defform of scribble to describe the following: syntax ($ infix-expr) → any infix-expr ::= addition addition ::= term addition ::= addition + term addition ::= addition - term term ::= etc. Using #:grammar I can easily get: addition = term | (addition + term) | (addition - term) but I don't want the parentheses and I don't know how to get rid of them. Is it possible to generate something like: infix-expr = addition addition = term | addition + term | addition - term If it is possible, help me please. Thanks, Jos -- 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. For more options, visit https://groups.google.com/d/optout. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Color Arithmetic
Il giorno 04/giu/2015, alle ore 11.38, Michael Tiedtke ha scritto: All I wanted to do was to compute two or three color steps between two colors to fade from one to the other. Usually I would this with available compositing methods but in the current case it's easier to do maths and just redraw with the new color. The usual method to calculate the color steps is the linear one (http://stackoverflow.com/questions/27532/generating-gradients-programmatically). Wouldn't it be nice to define new methods for the usual arithmetic operation generics '(+ - * / = abs) to do color arithmetic? Example: (define color-1 (make-color r1 g1 b1)) (define color-2 (make-color r2 g2 b2)) (define color-delta (/ (- color-2 color-1) number-of-steps)) (let loop ((color color-1)) (cons color [if (= color color-2) '() (loop (+ color color-delta))] )) NB It's not the best example out there: delta should be computed like any other delta as the absolute numerical distance where the return value of the subtraction might be a negative color-distance% object but colors usually are only positive. Perhaps it's better to do without bigger than and less than when it comes to colors. Before I go ahead and just do it I wanted to ask: 1) Does such a thing exist somewhere for Scheme or Racket (I couldn't find anything) The only example I found was: https://www.wolframalpha.com/examples/ColorArithmetic.html 2) Does anyone know how this proposed color arithmetic would interact with color management / color spaces? 2a) Is it true that non-linear color arithmetic produces better results for gradients? 3) Any suggestions regarding the implementation of the generics? 4) Both Cairo and Quartz do have more sophisticated compositing methods - but they do not expose this low level functionality? -- 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. For more options, visit https://groups.google.com/d/optout. Here is a first implementation: it's a bit awkward but does the job. 1) Some things that do not work: I can't provide + - etc. because this results in really strange error messages where send doesn't see a color% object but a number / rgb component at (define (rgb-delta rgb-1 rgb-2) (vector (- (send rgb-1 red) ... 2) I can't compare colors in Racket - two (0 0 0) rgb color objects are neither equal? nor object=?. Perhaps I should add an color equal predicate ... #lang racket ;; Module In (require racket/draw ; color% plot/utils ; vector calculus) ;;; ;;; Delta Color: Color Distance Arithmetic ;;; ;;; Rationale: Colors are abstract concepts in the first place which ;;; we can't calculate with. Color distances are easy to define even ;;; for abstract unknown color spaces. The current definition is: ;;; ;;; If delta is the difference between color 2 and color 1, then ;;; you get color 2 by adding the delta to color 1. ;;; ;;; If you divide delta by n and add delta n times to color 1 you ;;; will get n color steps representing a smooth gradient from color ;;; 1 to color 2. ;;; ;;; Everything else is currently undefined. This Color Distance ;;; Arithmetic is currently only implemented for the usual virtual ;;; interval integer RGB color space (RGB32). Color Deltas are vectors ;;; of exact numbers. For this you can calculate with endless (memory ;;; limited) precision between the color points in the color space. ;;; ;;; Domain Entry and Exit: ;;; ;;;color - color - color-delta ;;;color + color-delta - color ;;;color - color-delta - color ;; RGB Delta: Color Distance in our virtual RGB color space ;; The red, green and blue methods return byte data but we ;; use them as exact integers to allow further computation. (define (rgb-delta rgb-1 rgb-2) (vector (- (send rgb-1 red) (send rgb-2 red)) (- (send rgb-1 green) (send rgb-2 green)) (- (send rgb-1 blue) (send rgb-2 blue)) )) (define (delta? a) (and (vector? a) (= (vector-length a) 3))) (define (red delta) (vector-ref delta 0)) (define (green delta) (vector-ref delta 1)) (define (blue delta) (vector-ref delta 2)) ;; RGB Delta Plus: Domain Exit (define (rgb-delta-plus rgb delta) (make-color (+ (send rgb red) (red delta)) (+ (send rgb green) (green delta)) (+ (send rgb blue) (blue delta ;; RGB Delta Minus: Domain Exit (define (rgb-delta-minus rgb delta) (make-color (- (send rgb red) (red delta)) (- (send rgb green) (green delta)) (- (send rgb blue) (blue delta (define (color? a) (is-a? a color%)) (define (subtract a b) (cond ([and (color? a) (color? b)] (rgb-delta a b)) ([and (color? a) (delta? b)] (rgb-delta-minus a b)) ([and (delta? a) (delta? b)] (v- a b)) (else
[racket-users] defform quastion
Hi, I have tried to use defform of scribble to describe the following: syntax ($ infix-expr) → any infix-expr ::= addition addition ::= term addition ::= addition + term addition ::= addition - term term ::= etc. Using #:grammar I can easily get: addition = term | (addition + term) | (addition - term) but I don't want the parentheses and I don't know how to get rid of them. Is it possible to generate something like: infix-expr = addition addition = term | addition + term | addition - term If it is possible, help me please. Thanks, Jos -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] terminal emulator
On Thu, Jun 04, 2015 at 07:20:27AM -0600, Matthew Flatt wrote: At Wed, 3 Jun 2015 16:46:09 -0600, William G Hatch wrote: Its main problem currently is that it spends a lot of time drawing. I am using a canvas% and I override its dc%'s on-paint to get the contents and then draw them on screen. I call the refresh method to queue a re-paint whenever I get new input. If I, say, start up vim and start writing in it, my input lags behind as it spends all its time repainting. Are there some good practices for drawing stuff quickly? I was also wondering, before I start searching and grepping all over, if someone who knows can point me to where I can see how drracket formats the contents of its text panes (IE adds color, etc). Whatever it's doing seems to be good, so perhaps I can leverage something there. FWIW, your terminal seems much more responsive to me if I remove the `on-paint` call in `on-char` (since the terminal callback queues a refresh if any is needed, I think). Aha! Thanks, I didn't realize that was there. I was sprinkled a few of them around when I was first figuring out where things needed to be redrawn, before I learned about 'refresh'. I missed that one when I was removing them. DrRacket uses the editor classes that are described here: http://docs.racket-lang.org/gui/editor-overview.html That editor refreshes only part of the window when it can. For example, it's often easy to repaint only the current line where editing is happening. Redrawing only part of the screen means not calling `refresh` and instead drawing into that part of the canvas directly (but always drawing the whole canvas in a `refresh`-triggered `on-paint`). Use `suspend-flush` and `resume-flush` to avoid flicker while drawing outside of `on-paint`. My other biggest issue right now is getting the child processes to register window size changes, and I'm not sure whether it's a problem with how I'm setting things up with the child or with how I'm sending the resize signals through the parent. It's all through FFI calls into the black box of ioctl, so it has nothing to do with racket, but if any of you have tips for that, I would also appreciate it. But related to that, I have some C constants hard coded right now in racket for the FFI. Is there a way for me to get them out of the C header file so it won't just break if/when the header changes? No idea on the ioctl issue, but you may have to run a C program to extract constants from header files. Probably you don't have to worry about numbers changing for a given platform, though, since the numbers get embedded in executables and OS changes usually avoid breaking existing binaries in that way. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] terminal emulator
On Wed, Jun 3, 2015 at 6:46 PM, William G Hatch willgha...@gmail.com wrote: Hello racketeers, I'm pretty new to racket, so to get some experience with it I've been writing a terminal emulator. It's coming along nicely (it is one control code away from being able to nicely run vim), and is at https://github.com/willghatch/rackterm for your browsing pleasure. I have run into some difficulties that I would like some advice for: Its main problem currently is that it spends a lot of time drawing. I am using a canvas% and I override its dc%'s on-paint to get the contents and then draw them on screen. I call the refresh method to queue a re-paint whenever I get new input. If I, say, start up vim and start writing in it, my input lags behind as it spends all its time repainting. Are there some good practices for drawing stuff quickly? You may enjoy the mode-lambda package which is mainly designed for games, but terminals are also sprite-based (just a rectangular display of a fixed character set). The documentation isn't building right now, but you can just read it: https://github.com/jeapostrophe/mode-lambda/blob/master/mode-lambda/scribblings/mode-lambda.scrbl I was also wondering, before I start searching and grepping all over, if someone who knows can point me to where I can see how drracket formats the contents of its text panes (IE adds color, etc). Whatever it's doing seems to be good, so perhaps I can leverage something there. My other biggest issue right now is getting the child processes to register window size changes, and I'm not sure whether it's a problem with how I'm setting things up with the child or with how I'm sending the resize signals through the parent. It's all through FFI calls into the black box of ioctl, so it has nothing to do with racket, but if any of you have tips for that, I would also appreciate it. But related to that, I have some C constants hard coded right now in racket for the FFI. Is there a way for me to get them out of the C header file so it won't just break if/when the header changes? The cleanest terminal emulator I know of is http://www.leonerd.org.uk/code/libvterm/ You may want to bind to it or read its code to get an idea. Thanks in advance, William Hatch -- 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. For more options, visit https://groups.google.com/d/optout. -- Jay McCarthy http://jeapostrophe.github.io Wherefore, be not weary in well-doing, for ye are laying the foundation of a great work. And out of small things proceedeth that which is great. - DC 64:33 -- 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. For more options, visit https://groups.google.com/d/optout.
[racket-users] Color Arithmetic
All I wanted to do was to compute two or three color steps between two colors to fade from one to the other. Usually I would this with available compositing methods but in the current case it's easier to do maths and just redraw with the new color. The usual method to calculate the color steps is the linear one (http://stackoverflow.com/questions/27532/generating-gradients-programmatically). Wouldn't it be nice to define new methods for the usual arithmetic operation generics '(+ - * / = abs) to do color arithmetic? Example: (define color-1 (make-color r1 g1 b1)) (define color-2 (make-color r2 g2 b2)) (define color-delta (/ (- color-2 color-1) number-of-steps)) (let loop ((color color-1)) (cons color [if (= color color-2) '() (loop (+ color color-delta))] )) NB It's not the best example out there: delta should be computed like any other delta as the absolute numerical distance where the return value of the subtraction might be a negative color-distance% object but colors usually are only positive. Perhaps it's better to do without bigger than and less than when it comes to colors. Before I go ahead and just do it I wanted to ask: 1) Does such a thing exist somewhere for Scheme or Racket (I couldn't find anything) The only example I found was: https://www.wolframalpha.com/examples/ColorArithmetic.html 2) Does anyone know how this proposed color arithmetic would interact with color management / color spaces? 2a) Is it true that non-linear color arithmetic produces better results for gradients? 3) Any suggestions regarding the implementation of the generics? 4) Both Cairo and Quartz do have more sophisticated compositing methods - but they do not expose this low level functionality? -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] terminal emulator
At Wed, 3 Jun 2015 16:46:09 -0600, William G Hatch wrote: Its main problem currently is that it spends a lot of time drawing. I am using a canvas% and I override its dc%'s on-paint to get the contents and then draw them on screen. I call the refresh method to queue a re-paint whenever I get new input. If I, say, start up vim and start writing in it, my input lags behind as it spends all its time repainting. Are there some good practices for drawing stuff quickly? I was also wondering, before I start searching and grepping all over, if someone who knows can point me to where I can see how drracket formats the contents of its text panes (IE adds color, etc). Whatever it's doing seems to be good, so perhaps I can leverage something there. FWIW, your terminal seems much more responsive to me if I remove the `on-paint` call in `on-char` (since the terminal callback queues a refresh if any is needed, I think). DrRacket uses the editor classes that are described here: http://docs.racket-lang.org/gui/editor-overview.html That editor refreshes only part of the window when it can. For example, it's often easy to repaint only the current line where editing is happening. Redrawing only part of the screen means not calling `refresh` and instead drawing into that part of the canvas directly (but always drawing the whole canvas in a `refresh`-triggered `on-paint`). Use `suspend-flush` and `resume-flush` to avoid flicker while drawing outside of `on-paint`. My other biggest issue right now is getting the child processes to register window size changes, and I'm not sure whether it's a problem with how I'm setting things up with the child or with how I'm sending the resize signals through the parent. It's all through FFI calls into the black box of ioctl, so it has nothing to do with racket, but if any of you have tips for that, I would also appreciate it. But related to that, I have some C constants hard coded right now in racket for the FFI. Is there a way for me to get them out of the C header file so it won't just break if/when the header changes? No idea on the ioctl issue, but you may have to run a C program to extract constants from header files. Probably you don't have to worry about numbers changing for a given platform, though, since the numbers get embedded in executables and OS changes usually avoid breaking existing binaries in that way. -- 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. For more options, visit https://groups.google.com/d/optout.