-
-
Notifications
You must be signed in to change notification settings - Fork 24
Add interface for simple compositing layers to dc<%> #27
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
base: master
Are you sure you want to change the base?
Conversation
What is the right way to think of a transformation of a layer? If so, special care is needed for brushes which has their own transformation. A concrete example: Let's say we have a layer in which a circle is filled with a certain checkered brush. |
This API seems generally good to me. I'm unclear on how alignment is meant to interact between the layer and |
Originally I was thinking that if I see a few ways out of this situation:
I’m inclined to try option 2, since it seems like the nicest API by far, and it isn’t clear that the performance difference is relevant—I’m not sure |
I'm ok with either 2 or 3. I almost brought up the atomic-mode issue myself, but I think other methods already have that problem, in which case this change wouldn't make things worse. Any future, general repair to constrain atomicity to the drawing context should work for layers. Then again, if I'm wrong about existing problems, then it may be worth thinking that problem more. |
Would it be possible to use a layer for filling?
Currently `draw` can fill a path using a brush.
The current brushes are either single color, bitmaps, gradients or one of a
fixed set of hatch patterns.
There is currently no way of making a custom hatch pattern.
As a workaround one can fill a path with a custom pict, using a
clipping-region. However normally
a pict doesn't repeat/extend itself so one might need to make a series of
copies of the pict,
before using the clipping region.
Looking at `make-pattern-service` in draw/dc.rkt I think
CAIRO_EXTEND_REPEAT can be
used to make cairo pattens (draw layers) repeat themselves.
The question came to mind after seeing
https://riccardoscalco.it/textures/
a library of "textures" aka hatch patterns. Thinking of ways to implement
this with `draw`,
I realized that we need some kind of "infinite repeat pattern" concept.
/Jens Axel
Den man. 22. jun. 2020 kl. 16.32 skrev Matthew Flatt <
[email protected]>:
… I'm ok with either 2 or 3.
I almost brought up the atomic-mode issue myself, but I think other
methods already have that problem, in which case this change wouldn't make
things worse. Any future, general repair to constrain atomicity to the
drawing context should work for layers. Then again, if I'm wrong about
existing problems, then it may be worth thinking that problem more.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADQXRNKDOOTBJR2XB2U6P3RX5TQFANCNFSM4OBEOYOQ>
.
--
--
Jens Axel Søgaard
|
@lexi-lambda I like your proposal and would hate to see it forgotten. |
After revisiting this, I've added different methods to The After taking a step back, I decided to try again with my first thought, which was just to use The |
@mflatt This PR is a work-in-progress, as it still needs tests and docs. However, before I write those, I wanted to ask if you think I’m on the right track. Here’s a summary of the API so far:
We add two new methods to
dc<%>
:make-layer
creates a newdc<%>
that inherits its backend configuration, pen, brush, font, text foreground/background, alignment scale, and smoothing from the parent.After drawing to the new dc, you can draw it onto the parent dc using
draw-layer
, which applies the current transformation and alpha.In additional to any general comments you might have about the API, here are the implementation details I’m most unsure about:
In
draw-layer
, I don’t do any setup except installing the right smoothing before drawing. I have no idea if I’m missing something.The
record-dc%
implementation seems to work fine, but I’m not totally confident about it.Finally, here’s an example program that uses layers:
This produces the following output: