Last active
December 8, 2017 09:04
-
-
Save luce80/e34516e5248b629badfd4016dda6cbb8 to your computer and use it in GitHub Desktop.
Draw Image Resizing Test with reaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Title: "Draw Image Resizing Test" | |
Author: [REBOL version "Carl Sassenrath" Red port "Gregg Irwin" Reacting version "Marco Antoniazzi"] | |
Version: 0.0.2 | |
File: %resize-image.red | |
Needs: View | |
] | |
img: load/as any [ | |
attempt [read/binary img-url: https://pbs.twimg.com/profile_images/501701094032941056/R-a4YJ5K.png] | |
attempt [read/binary img-url: https://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png] | |
attempt [read/binary img-url: %ukiah.jpg] | |
] 'jpeg | |
draw-blk: [image img 0x0 img/size] | |
view compose [ | |
title "Draw Image Resizing Test" | |
backdrop water | |
style nub: base 10x10 glass loose draw [pen yellow fill-pen yellow circle 4x4 4] | |
text water bold font-color white "Red resize image test" | |
text 200 water bold font-color yellow "Drag the grab handles" | |
return | |
; resizing drawn image | |
canvas: base 960x720 black draw draw-blk react [ | |
face/draw/3: n1/offset + 5x5 - face/offset | |
face/draw/4: n2/offset + 5x5 - face/offset | |
] | |
at 100x100 | |
n1: nub | |
at (100x100 + img/size - 5x5) | |
n2: nub | |
; resizing face | |
at 450x50 | |
image img react [face/offset: n3/offset + 5x5 face/size: n4/offset - n3/offset] | |
at 450x50 | |
n3: nub | |
at 850x450 | |
n4: nub | |
] |
Thanks. In fact it was not meant to be loose so I simply disabled loose behavior. But now I have something to think about...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very cool! If I drag the loose image, the handles don't stick with it though.