Changeset 1388f7f0 in mainline for uspace/lib/gfx/src/coord.c
- Timestamp:
- 2020-02-21T10:50:48Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 265989d
- Parents:
- 6c2aba3
- git-author:
- Jiri Svoboda <jiri@…> (2020-02-19 19:38:03)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-02-21 10:50:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfx/src/coord.c
r6c2aba3 r1388f7f0 62 62 } 63 63 64 /** Clip point coordinates to be within a rectangle. 65 * 66 * @param a Pixel coordinates 67 * @param clip Clipping rectangle 68 * @param d Place to store clipped coordinates 69 */ 64 70 void gfx_coord2_clip(gfx_coord2_t *a, gfx_rect_t *clip, gfx_coord2_t *d) 65 71 { … … 74 80 d->x = max(clip->p0.x, t.x); 75 81 d->y = max(clip->p0.y, t.y); 82 } 83 84 /** Transform coordinates via rectangle to rectangle projection. 85 * 86 * Transform pixel coordinate via a projection that maps one rectangle 87 * onto another rectangle. The source rectangle must have both dimensions 88 * greater than one. 89 * 90 * @param a Pixel coordinates 91 * @param srect Source rectangle 92 * @param drect Destination rectangle 93 * @param d Place to store resulting coordinates. 94 */ 95 void gfx_coord2_project(gfx_coord2_t *a, gfx_rect_t *srect, gfx_rect_t *drect, 96 gfx_coord2_t *d) 97 { 98 gfx_rect_t sr; 99 gfx_rect_t dr; 100 101 gfx_rect_points_sort(srect, &sr); 102 gfx_rect_points_sort(drect, &dr); 103 104 d->x = dr.p0.x + (a->x - sr.p0.x) * (dr.p1.x - dr.p0.x - 1) / 105 (sr.p1.x - sr.p0.x - 1); 106 d->y = dr.p0.y + (a->y - sr.p0.y) * (dr.p1.y - dr.p0.y - 1) / 107 (sr.p1.y - sr.p0.y - 1); 76 108 } 77 109
Note:
See TracChangeset
for help on using the changeset viewer.