[racket-dev] Can't change plot in DrRacket without getting link errors

2014-01-03 Thread Neil Toronto

I do this:

 * In DrRacket, open pkgs/plot-pkgs/plot-lib/plot/private/common/draw.rkt

 * Make a small change, save

 * At the command line, racket/bin/raco setup --no-docs -l plot

 * Run a test file in another tab in DrRacket that has (require plot)


I wait a long time (I think it's recompiling) and get this error:

link: bad variable linkage;
 reference to a variable that has the wrong procedure or structure-type 
shape

  reference phase level: 0
  variable module: 
/home/neil/plt/pkgs/plot-pkgs/plot-lib/plot/private/common/draw.rkt

  variable phase: 0
  reference in module: 
/home/neil/plt/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot2d.rkt 
in: draw-bitmap



So I remove the compiled directory and try again. Same problem.

Here's the kicker: I always get link errors *until I close draw.rkt in 
DrRacket*. After that, I can remove the compiled directory, rebuild, 
and run the program without errors.


Does anybody know what's going on?

Neil ⊥
_
 Racket Developers list:
 http://lists.racket-lang.org/dev


Re: [racket-dev] Can't change plot in DrRacket without getting link errors

2014-01-03 Thread Jens Axel Søgaard
Try this:
  - open the menu Language in DrRacket
  - choose the menu item Choose language...
  - click the button Show details
  - remove the tick in Populate 'compiled' directories (for faster loading)

/Jens Axel



2014/1/4 Neil Toronto neil.toro...@gmail.com:
 I do this:

  * In DrRacket, open pkgs/plot-pkgs/plot-lib/plot/private/common/draw.rkt

  * Make a small change, save

  * At the command line, racket/bin/raco setup --no-docs -l plot

  * Run a test file in another tab in DrRacket that has (require plot)


 I wait a long time (I think it's recompiling) and get this error:

 link: bad variable linkage;
  reference to a variable that has the wrong procedure or structure-type
 shape
   reference phase level: 0
   variable module:
 /home/neil/plt/pkgs/plot-pkgs/plot-lib/plot/private/common/draw.rkt
   variable phase: 0
   reference in module:
 /home/neil/plt/pkgs/plot-pkgs/plot-gui-lib/plot/private/gui/plot2d.rkt in:
 draw-bitmap


 So I remove the compiled directory and try again. Same problem.

 Here's the kicker: I always get link errors *until I close draw.rkt in
 DrRacket*. After that, I can remove the compiled directory, rebuild, and
 run the program without errors.

 Does anybody know what's going on?

 Neil ⊥
 _
  Racket Developers list:
  http://lists.racket-lang.org/dev



-- 
--
Jens Axel Søgaard

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] [plt] Push #28009: master branch updated

2014-01-03 Thread Neil Toronto

On 01/03/2014 06:12 PM, mfl...@racket-lang.org wrote:

bd4d0b7 Matthew Flatt mfl...@racket-lang.org 2014-01-03 17:57
:
| if a bitmap has a non-1 backing scale, always draw smoothly to other contexts
:
   M pkgs/draw-pkgs/draw-lib/racket/draw/private/dc.rkt | 11 ++-


Cool. It looks like this solved another issue as well: drawing 2x 
bitmaps in the REPL would smooth only intermittently.


There appears to be a problem with drawing in 'unsmoothed mode onto a 
bitmap with a backing scale. I've attached a program that demonstrates 
using a single polygon and with plots.


In the single polygon test, the triangle drawn onto the 2x bitmap is 
shifted down and to the right one pixel.


The code that draws a plot onto a 2x bitmap simulates the change I would 
make to Plot to take advantage of the new backing scale feature. The 
edge of the sphere looks lumpy, probably because polygons are drawn 
unsmoothed and their vertices are being snapped to the wrong places. The 
second plot shows how it's supposed to look.


The last two plots show how each looks before being scaled down. The 
lumpiness around the edge is probably easier to see this way.


Neil ⊥

#lang racket

(require plot
 racket/draw)

(define (get-backing-bitmap bm)
  (define s (send bm get-backing-scale))
  (define bm2 (make-bitmap (exact-ceiling (* s (send bm get-width)))
   (exact-ceiling (* s (send bm get-height)
  (define dc (make-object bitmap-dc% bm2))
  (send dc set-scale s s)
  (send dc set-smoothing 'unsmoothed)
  (send dc draw-bitmap bm 0 0)
  bm2)

(define (draw-unsmoothed-triangle dc)
  (send dc set-smoothing 'unsmoothed)
  (send dc set-background orange)
  (send dc clear)
  (send dc set-pen (make-object pen% black 1 'transparent))
  (send dc set-brush (make-object brush% black))
  (send dc draw-polygon '((0 . 0) (9 . 3) (4 . 6

(define bm1 (make-bitmap 10 10 #:backing-scale 2))
(define dc1 (make-object bitmap-dc% bm1))
(draw-unsmoothed-triangle dc1)

(define bm2 (make-bitmap 20 20))
(define dc2 (make-object bitmap-dc% bm2))
(send dc2 set-scale 2 2)
(draw-unsmoothed-triangle dc2)

(printf Triangles drawn in unsmoothed mode (top uses backing scale):~n)
(values (get-backing-bitmap bm1) bm2)

(printf Plot rendered to bitmap with backing scale:~n)
(define bm3 (make-bitmap 400 400 #:backing-scale 2))
(define dc3 (make-object bitmap-dc% bm3))
(plot3d/dc (polar3d (λ (θ ρ) 1) #:color 2 #:line-style 'transparent)
   dc3 0 0 400 400
   #:altitude 25)
bm3

(printf Plot rendered 2x and downscaled:~n)
(plot3d-bitmap (polar3d (λ (θ ρ) 1) #:color 2 #:line-style 'transparent)
   #:altitude 25)

(printf Actual 2x bitmap:~n)
(get-backing-bitmap bm3)

(printf Plot rendered 2x:~n)
(define bm4 (make-bitmap 800 800))
(define dc4 (make-object bitmap-dc% bm4))
(plot3d/dc (polar3d (λ (θ ρ) 1) #:color 2 #:line-style 'transparent)
   dc4 0 0 800 800
   #:altitude 25)
bm4
_
  Racket Developers list:
  http://lists.racket-lang.org/dev