feat(Graphics): add `fitScale` function
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- fsharp
- Domain
- computer-graphics
Research direction
Start from the proposed fitScale definition and the commented Assert.equal example in issue #25. Locate the project entry point for the Size-related graphics code, add the function there, and run the project tests; done means the shown 4×3 image in a 3×4 viewport satisfies the asserted result.
Written by the indexing model from the issue text.
Description
/// Вычисляет коэффициент масштаба, необходимый, чтобы вписать изображение в указанную область
let fitScale (viewportSize: Size) (imageSize: Size) =
let dw = imageSize.Width - viewportSize.Width
let dh = imageSize.Height - viewportSize.Height
if dw > dh then
if dw > 0 then
float viewportSize.Width / float imageSize.Width
else
1.0
else
if dh > 0 then
float viewportSize.Height / float imageSize.Height
else
1.0
// Assert.equal
// (
// let imageSize = Size.create 4 3
// let scale = fitScale (Size.create 3 4) imageSize
// imageSize * scale
// )
// (Size.create 3 2)
// ""
- Dominant language
- F#
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from gretmn102/FsharpMyExtension
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gretmn102/FsharpMyExtension#20 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
All issues in gretmn102/FsharpMyExtension
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
libsdl-org/SDL#16360 ·
-
Area:Math p5.js 2.0+
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
processing/p5.js#9197 · 3 comments · 1 assignee ·
-
priority:low refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
CyberAgent/psd2svg#382 ·
-
Template: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100