Comments (4)
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):
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.
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.
@noelwelsh Worked perfectly. Thank you.
from doodle.
Great!
from doodle.
Related Issues (20)
- Parse hex strings into `Color`
- SVG must not fill open paths HOT 2
- Support perceptually-based color description
- Port minitest tests to munit
- Image saved to file does not have size of Frame HOT 1
- Unexpected behaviour with `Picture` monad and Java2D renderer HOT 2
- BufferedImageConverter cleanup HOT 3
- Consistent naming of writers HOT 2
- Add tests for `BufferedImageWriter`
- Abstract default frame HOT 3
- Writer conveniences
- Java Implementation Cleanup
- Configurable delay between frames in animated GIF HOT 2
- Allow directly setting the width and height of the bounding box
- Create browser canvas backend
- Canvas backend supports text
- Canvas backend Frame supports background colour
- Canvas backend supports blending modes
- Canvas backend supports fills
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 doodle.