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

Support for flipping text? for emojis #161

Open
jestarray opened this issue Oct 15, 2021 · 3 comments
Open

Support for flipping text? for emojis #161

jestarray opened this issue Oct 15, 2021 · 3 comments
Labels
good first issue someone with decent experience new to racket can do it

Comments

@jestarray
Copy link

jestarray commented Oct 15, 2021

(require 2htdp/image)

(flip-horizontal (text "🦈" 100 "red"))

; ERROR: flip: cannot flip shapes that contain text

is it possible to make flip-horizontal and flip-vertical work with text images in 2htdp/image ? Arguably the color parameter is not needed for emojis. I can think of a few emoji centric games that could be fun to students.
🚣‍♂️ A fun game I can think of is rowing a boat left and right to avoid a shark from underneath or something, and getting flip-horizontal to change the boat facing direction.
Thanks

@samth
Copy link
Member

samth commented Oct 15, 2021

Note that rotate works on text, so it should be relatively easy to do some things here.

@jestarray
Copy link
Author

jestarray commented Oct 27, 2021

I think all we need to do is to delete this check? :

(error 'flip "cannot flip shapes that contain text")]

    [(text? atomic-shape)
     (error 'flip "cannot flip shapes that contain text")]

but I don't know how to have racket require my local modified version of htdp. Can someone test this? Thanks.

By removing said check above I get:

../../usr/share/racket/pkgs/htdp-lib/2htdp/private/image-more.rkt:964:21: flip-atomic: broke its own contract
  promised: np-atomic-shape?
  produced: #<void>
  in: the range of
      (-> np-atomic-shape? np-atomic-shape?)
  contract from: (function flip-atomic)
  blaming: (function flip-atomic)
   (assuming the contract is correct)
  at: <pkgs>/htdp-lib/2htdp/private/image-more.rkt:966:18

So it's not just removing 1 line..
Edit: so it seems cairo can do these text flipping transformations since im testing it atm in C.

@rfindler
Copy link
Member

There are a number of methods for flipped text that need to be implemented, notably image equality. I believe the internal data structure has to change to accommodate flipped text. (It isn't just about drawing things.)

@rfindler rfindler added the good first issue someone with decent experience new to racket can do it label Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue someone with decent experience new to racket can do it
Projects
None yet
Development

No branches or pull requests

3 participants