Comments (4)
Please could you add screenshots to show the behaviour and another for the desired output?
from drawkit.
when i drag in a very large photo
i'd like to be able to auto scale the photo to fit the dkdrawingview.
it appears from the demo this functionality is in DKImageShape class but i'm not sure how to derive these functions from the layer/object that was just added. currently i'm using hit test to get the object that was added but this is not right .
var canvasDrawing:DKDrawing!
.
.
let obj = canvasDrawing.objectInLayers(at: 1)
let drawableObj = obj.hitTest(NSPoint.init(x: 100.0, y: 100.0))
drawableObj?.resizeBy(width: 0.1, height: 0.1)
so i need some kind of delegate method that is called when an object is dropped into the view. i'm already implementing DKDrawingDelegate methods, but i don't think any of these notify when an object is added. then i need to reference that object some way other than using hittest
from drawkit.
I am unsure of the best approach because I have not used DrawKit for a while.
However, I suspect a reasonable approach is to use Key Value Observation (KVO) of the drawing layer's objects. The observer is then notified when an object is added. From there you can access the object and resize it according the parent DrawingView's size.
Does this make sense?
from drawkit.
Awesome. Thank you!
from drawkit.
Related Issues (20)
- Load styles from file HOT 1
- Intent to move to new licence (MPLv2)
- scrollWheel jerky zoom behavior fix: event delta of 0 means 'stop gesture' HOT 1
- Carthage support for DrawKit? HOT 2
- Swift Support HOT 4
- DKTextShape does not increase the size when text is too big. HOT 1
- Looking for contributors and pull requests HOT 2
- Where's the right place to instantiate `DKUndoManager`? HOT 1
- Black Rectangle when placed in Containing View HOT 1
- Question - SVG support? HOT 4
- Question - notification for when object clicked (not double clicked)? HOT 1
- Documentation? HOT 3
- How to set an NSAttributedString? HOT 1
- Xcode 10 / Mojave / Swift 4.2 issue? HOT 9
- DKImageShape - Drag and Drop - CGContextSetCTM: invalid context 0x0
- Implementation of DKSecretSelectorsDrawingLayer. HOT 2
- Performance issues on retina display HOT 1
- Edit Text is not working
- Separate Layers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drawkit.