Giter VIP home page Giter VIP logo

Comments (4)

grahammiln avatar grahammiln commented on May 31, 2024

Please could you add screenshots to show the behaviour and another for the desired output?

from drawkit.

calebmitcler avatar calebmitcler commented on May 31, 2024

when i drag in a very large photo
image

i'd like to be able to auto scale the photo to fit the dkdrawingview.
image

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.

grahammiln avatar grahammiln commented on May 31, 2024

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.

calebmitcler avatar calebmitcler commented on May 31, 2024

Awesome. Thank you!

from drawkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.