Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add universe-inset parameter #237

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

a11ce
Copy link
Contributor

@a11ce a11ce commented Dec 13, 2024

Resolves #235.

I'm not sure about the phrasing or location of the documentation but I think it's clear enough for curious *SL users.

@mfelleisen
Copy link
Contributor

What uses do you have in mind? Actually what users?

@a11ce
Copy link
Contributor Author

a11ce commented Dec 13, 2024

My partner and I are writing a visual novel and I'm using universe for the engine. The end goal for the engine is to be vaguely like Ren'Py which is widely used for indie VNs. We plan to self-publish our game commercially and document the engine for anyone to use.

In general, the intended user is anyone who wants to use universe to make graphical applications that are more stylized than racket/gui. Having a white border limits the freedom of stylization.

I know this direction was not the intent for 2htdp/universe, so I'm happy to maintain a non-student-focused fork instead. However, this is currently the only change I expect to make so it would be much simpler to add it here.

5
(λ (v)
(unless (and (integer? v)
(<= 0 v 1000))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1000 really? Did you try to run a big-bang program with such an inset?

(Very minor: this is a world-inset not a universe-insert.)

(unless (and (integer? v)
(<= 0 v 1000))
(raise-argument-error 'universe-inset "an integer between 0 and 1000 (inclusive)" v))
v)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever you really choose for an inset (1) name the max constant and (2) use the name instead of the constant.

@@ -53,8 +60,8 @@
;; MouseEvent% -> [List Nat Nat MouseEventType]
;; turn a mouse event into its pieces
(define (mouse-event->parts e)
(define x (- (send e get-x) INSET))
(define y (- (send e get-y) INSET))
(define x (- (send e get-x) (universe-inset)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use (define INSET (universe-inset)) and then leave these lines alone. (It's not like INSET will change during the course of the big-bang program. (Yes this is a "contract" that we don't enforce right now.))

(define x (- (send e get-x) INSET))
(define y (- (send e get-y) INSET))
(define x (- (send e get-x) (universe-inset)))
(define y (- (send e get-y) (universe-inset)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INSET

@@ -220,6 +220,7 @@
(define/pubment (create-frame/universe)
(define play-back:cust (make-custodian))

(define inset (universe-inset))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INSET

This section documents features of the universe teachpack not available in
the HtDP student languages.

@defparam[universe-inset inset-width (integer-in 0 1000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the named constant instead of 1000.

@a11ce
Copy link
Contributor Author

a11ce commented Dec 13, 2024

Thank you for the feedback, I'll make those changes.

The limit of 1000 apparently comes from editor-canvas%. Without the guard, you get

initialization for editor-canvas%: contract violation
  expected: (integer-in 0 1000)
  given: 1001

But the limit is documented as 10000 so I'm not sure. 1000 does work; I can't imagine why anyone would want it but there's no reason to restrict it imo. It could also just be a true/false parameter for 5/0 inset.

Screen Shot 2024-12-13 at 17 08 55

@mfelleisen
Copy link
Contributor

mfelleisen commented Dec 13, 2024 via email

@a11ce
Copy link
Contributor Author

a11ce commented Dec 13, 2024

How about on (5, current)/off (0)?

@mfelleisen
Copy link
Contributor

I am not sure what you mean. But (1) a numeric parameter is fine and (2) something like 10 or 20 or 100 for the inset feels right.

@shhyou
Copy link
Collaborator

shhyou commented Dec 14, 2024

Any reason to use a guard for universe-inset over putting (contract-out [universe-inset (parameter/c (integer-in ... ...))]) in htdp-lib/2htdp/universe.rkt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for removing the inset in 2htdp/universe
3 participants