gretmn102 / gretmn102/FsharpMyExtension

feat(Graphics): add `fitScale` function

Open Beginner friendly
#25 0 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
F#
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

```fsharp
/// Вычисляет коэффициент масштаба, необходимый, чтобы вписать изображение в указанную область
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)
// ""
```

Contributor guide

No contributing guide indexed for this repository

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.

Assessment

Tech stack
fsharp
Domain
computer-graphics
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.