Coder Social home page Coder Social logo

Comments (4)

hmf avatar hmf commented on July 23, 2024

The trick of using a "reference shape" also does not work perfectly. The final image tries to show as much of the 2 shapes as possible. In doing so it shifts the frame shape by several pixels (5 pixels in the example below).

Is their any "magic" call I can use to ensure a shape is never clipped?

Here is the output I get (I expect the origin to be at the bottom left corner of the frame):

circle

Here are the code snippets:

  val width = 100
  val height = 100

  def frameSquare() =
    val picture = Picture.rectangle(width, height)
          .strokeColor(Color.black)
          .margin(0)
          // .originAt(-width/2, -height/2)
          .originAt(Landmark.bottomLeft)
          .at(0,0)
          .debug
    picture

  def randomSquare(frame: Picture[Unit]) =
    frame.on(
      Picture.square(20)
          .strokeColor(Color.black)
          .margin(0)
          .originAt(0, 0)
          .at(0,0)
          .debug
    )

    val framePicture = frameSquare()
    val picture = randomSquare(frame = framePicture )

    val frame = Frame.default.withSize(width , height).withBackground(Color.white)

    val out1 = os.pwd / "circle.png"
    println(out1.toIO)
    picture.write[Png](out1.toIO, frame)

TIA

from doodle.

noelwelsh avatar noelwelsh commented on July 23, 2024

I think you want withCenterAtOrigin: https://www.javadoc.io/doc/org.creativescala/doodle-docs_3/latest/doodle/java2d/effect/Frame.html

This sets the origin of the frame to the origin of the Picture. From that you can do layout in terms of absolute coordinates.

from doodle.

hmf avatar hmf commented on July 23, 2024

@noelwelsh Worked perfectly. Thank you.

from doodle.

noelwelsh avatar noelwelsh commented on July 23, 2024

Great!

from doodle.

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.