Code Monkey home page Code Monkey logo

Comments (12)

j-adel avatar j-adel commented on June 9, 2024 1

Awesome! For the record, I think this worked for me:

function Base.:-(num::Number, p::Point)
    return Point(num - p.x, num - p.y)
end

function Base.:-(p1::Point, num::Number)
    return Point(p1.x - num, p1.y - num)
end

from luxor.jl.

cormullion avatar cormullion commented on June 9, 2024 1

It would be a breaking change.

from luxor.jl.

cormullion avatar cormullion commented on June 9, 2024 1

Perhaps the next version of Luxor should be version 4.0, with some breaking changes, supporting only Julia 1.9 and above (thanks to package extensions). It might be good to wait until Julia 1.10 is released first before releasing 4.0 ... 🤔

from luxor.jl.

cormullion avatar cormullion commented on June 9, 2024

I’m not sure what it’s even supposed to do 😂

Probably this needs to be looked at

-(z::Number, p1::Point) = Point(p1.x - z, p1.y - z)

Cairo doesn’t know about Points 😀

from luxor.jl.

cormullion avatar cormullion commented on June 9, 2024

Thanks for the kind words! I might have fixed this now (on master)... 🤞

Hoping to make another release this week...

from luxor.jl.

cormullion avatar cormullion commented on June 9, 2024

I think I might just have copy-pasted too carelessly back when I wrote this bit... :)

from luxor.jl.

j-adel avatar j-adel commented on June 9, 2024

Haha yeah I just saw it. Btw this wrapper is pretty much perfect for generative art. I've gotten good results really quickly with it. I hope to make an article guide about it soon :D

from luxor.jl.

cormullion avatar cormullion commented on June 9, 2024

Looking forward to that! It’s mostly designed for that kind of use - parameterized graphic design and similar - so I’m happy that you’re getting some results you like!

from luxor.jl.

stale avatar stale commented on June 9, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from luxor.jl.

hyrodium avatar hyrodium commented on June 9, 2024

Is it reasonable to have a method like +(::Point, ::Number)?

julia> using Luxor

julia> Point(1,2) + 1
Point(2.0, 3.0)

julia> [1,2] + 1
ERROR: MethodError: no method matching +(::Vector{Int64}, ::Int64)
For element-wise addition, use broadcasting with dot syntax: array .+ scalar

I think it would be enough with .+ operator.

julia> Point(1,2) .+ 1
Point(2.0, 3.0)

julia> [1,2] .+ 1
2-element Vector{Int64}:
 2
 3

from luxor.jl.

hyrodium avatar hyrodium commented on June 9, 2024

Yeah, should we release the breaking change? If so, I can open a PR to deprecate the methods.

from luxor.jl.

hyrodium avatar hyrodium commented on June 9, 2024

I was planning to release 3.x with deprecated methods (e.g. +(::Point, ::Number)), and then release 4.0 with removing the deprecated methods. However, we have other reasons for the next breaking release, so it would be okay not to release the next 3.x. 🤔

from luxor.jl.

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.