core/viewmanager
뷰 매니저.
- canvas_native_size: 창 안쪽의 논리 크기. (물리 픽셀 / 배율)
- canvas_pixel_size: 창 안쪽의 실제 렌더링 픽셀 크기. (드로잉 버퍼)
- view_native_rect: 실제 사용되는 뷰 영역. (canvas_native_size 기준의 부분 영역)
- view_size: 실제 사용되는 뷰 크기. (씬이 그리는 좌표계의 크기)
- 원본의 device_pixel_ratio 는 창의 배율(scale factor)이다.
- 렌더 배율 상한(set_max_render_pixel_ratio): 원본과 같이 값만 적고(같은 값이면 하지 않는다) is_view_rect_pending 을 세운다. 다음 프레임 첫머리에 창 크기 바뀜과 같은 길(Engine::resize)로 상한을 건 배율로 다시 맞추고, calculate_view_rect 가 내린다. (프레임 가운데에서 캔버스 크기를 바꾸면 그 프레임이 까맣다) 웹은 캔버스 드로잉 버퍼를 줄이고, 데스크탑은 기본 프레임버퍼의 왼쪽 아래에 줄인 크기로 그린 뒤 창 크기로 늘인다. (platform/desktop/renderscaler.rs)
- 세이프 에어리어 인셋(get_safe_area_insets, set_safe_area_override)은 원본 { top, right, bottom, left } 처럼 이름 붙은 칸을 가진 SafeAreaInsets 다. 주소의 ?safeArea=위,오른쪽,아래,왼쪽 자리는 데스크탑에서 환경 변수 VANILLA_SAFE_AREA=위,오른쪽,아래,왼쪽 이다. CSS env(safe-area-inset-*) 는 웹에서 읽고 데스크탑은 0 이다. 크롬 데스크탑도 0 이다. (0 이 아닌 값은 안드로이드에서만 들어온다, platform/desktop.rs read_safe_area_insets) set_safe_area_override 는 둘 다에서 먹는다.
- get_client_native_size: 원본처럼 페이지 전체 크기(window.innerWidth, innerHeight)다. 데스크탑은 페이지가 없어 창 안쪽 논리 크기다.
- convert_client_to_view: 화면(client) 좌표를 뷰 좌표로. 웹은 캔버스의 지금 자리를 빼고, 데스크탑은 창의 논리 좌표가 곧 client 좌표다.
- 무시할 세이프 에어리어 쪽(set_ignored_safe_area_sides)은 원본의 "top" 같은 글 대신 SafeAreaSide 열거형으로 받는다.
- get_css_pixel_scale 의 캔버스 CSS 높이는 canvas_native_size.y 다. (웹은 캔버스의 CSS 높이, 데스크탑은 창의 논리 높이)
- apply_aspect_view_scale_mode 는 캔버스 논리 크기로 비를 잰다. (원본은 캔버스 크기가 0 이면 창 안쪽 크기를 쓴다. 러스트 판은 씬이 돌기 전에 플랫폼이 캔버스 크기를 맞춰 두어 0 일 때는 창도 0 이다)
View manager.
- canvas_native_size: Logical size of the window interior. (physical pixels / scale)
- canvas_pixel_size: Actual rendering pixel size of the window interior. (drawing buffer)
- view_native_rect: The view area actually used. (a sub-area relative to canvas_native_size)
- view_size: The view size actually used. (size of the coordinate system the scene draws in)
- The original's device_pixel_ratio is the window's scale factor.
- Render scale limit (set_max_render_pixel_ratio): as in the original, only the value is stored (nothing happens for the same value) and is_view_rect_pending is raised. At the start of the next frame it refits with the limited scale through the same path as a window resize (Engine::resize), and calculate_view_rect lowers it. (Changing the canvas size in the middle of a frame makes that frame black) The web shrinks the canvas drawing buffer, and desktop draws at the reduced size in the bottom-left of the default framebuffer, then stretches it to the window size. (platform/desktop/renderscaler.rs)
- Safe area insets (get_safe_area_insets, set_safe_area_override) are SafeAreaInsets with named fields like the original { top, right, bottom, left }. The address's ?safeArea=top,right,bottom,left corresponds on desktop to the environment variable VANILLA_SAFE_AREA=top,right,bottom,left. CSS env(safe-area-inset-*) is read on the web and is 0 on desktop. Chrome desktop is 0 too. (nonzero values only come in on Android, platform/desktop.rs read_safe_area_insets) set_safe_area_override takes effect on both.
- get_client_native_size: the whole page size (window.innerWidth, innerHeight) as in the original. Desktop has no page, so it is the logical size of the window interior.
- convert_client_to_view: screen (client) coordinates to view coordinates. The web subtracts the canvas's current position, and on desktop the window's logical coordinates are the client coordinates.
- Safe area sides to ignore (set_ignored_safe_area_sides) are taken as the SafeAreaSide enum instead of the original's strings like "top".
- The canvas CSS height in get_css_pixel_scale is canvas_native_size.y. (the canvas's CSS height on the web, the window's logical height on desktop)
- apply_aspect_view_scale_mode measures the ratio with the canvas logical size. (the original uses the window interior size if the canvas size is 0. In the Rust version the platform fits the canvas size before the scene runs, so when it is 0 the window is 0 too)
SafeAreaInsetsstruct traits Clone, Copy, Debug, Default, PartialEq
세이프 에어리어 인셋. (원본 { top, right, bottom, left })
- set_safe_area_override 에 넘길 때는 CSS 픽셀, get_safe_area_insets 가 돌려줄 때는 뷰 좌표다.
Safe area insets. (the original { top, right, bottom, left })
- CSS pixels when passed to set_safe_area_override, view coordinates when returned by get_safe_area_insets.
use vanilla::{SafeAreaInsets, Vector2, ViewManager, ViewScaleMode};
let mut view_manager = ViewManager::new(Vector2::create(1280.0, 720.0), ViewScaleMode::StretchShort);
view_manager.calculate_view_rect(1280, 720, 2.0);
view_manager.set_safe_area_override(Some(SafeAreaInsets::create(44.0, 0.0, 34.0, 0.0)));
let insets = view_manager.get_safe_area_insets();
assert_eq!(insets, SafeAreaInsets::create(88.0, 0.0, 68.0, 0.0));
assert_eq!(insets.top, 88.0);생성. (원본 { top, right, bottom, left } 의 차례)
Creates. (in the order of the original { top, right, bottom, left })
- topf64
- 위 쪽 인셋.Top inset.
- rightf64
- 오른쪽 인셋.Right inset.
- bottomf64
- 아래 쪽 인셋.Bottom inset.
- leftf64
- 왼쪽 인셋.Left inset.
반환ReturnsSafeAreaInsets 네 칸을 채운 인셋.Insets with all four sides filled.
ViewManagerstruct
뷰 매니저. (창 크기와 배율, 기준 해상도, 뷰 스케일 모드로 씬이 그리는 뷰 영역을 셈한다, 엔진이 하나 든다)
View manager. (computes the view area the scene draws from the window size, scale, reference resolution and view scale mode, held by the engine)
use vanilla::{Rect, Vector2, ViewManager, ViewScaleMode};
let mut view_manager = ViewManager::new(Vector2::create(1280.0, 720.0), ViewScaleMode::StretchShort);
view_manager.calculate_view_rect(1600, 720, 1.0);
assert_eq!(view_manager.get_canvas_native_size(), Vector2::create(1600.0, 720.0));
assert_eq!(view_manager.get_view_size(), Vector2::create(1280.0, 720.0));
assert_eq!(view_manager.get_view_native_rect(), Rect::create(160.0, 0.0, 1280.0, 720.0));
assert_eq!(view_manager.get_target_resolution_scale(), 1.0);
assert_eq!(view_manager.canvas_position_to_view_position(Vector2::create(160.0, 0.0)), Vector2::zero());use vanilla::{Engine, Vector2};
fn read_view_center(engine: &Engine) -> Vector2 {
let view_size = engine.get_view_manager().get_view_size();
Vector2::create(view_size.x * 0.5, view_size.y * 0.5)
}pub fn new(reference_resolution_size: Vector2, view_scale_mode: ViewScaleMode) -> ViewManager#생성.
Constructor.
- reference_resolution_sizeVector2
- 기준 해상도. (씬이 그릴 좌표계의 크기, 픽셀)Reference resolution. (size of the coordinate system the scene draws in, pixels)
- view_scale_modeViewScaleMode
- 뷰 스케일 모드.View scale mode.
반환ReturnsViewManager 새 뷰 매니저. (배율 1, 크기와 뷰 영역은 0, calculate_view_rect 를 불러야 뷰 영역이 생긴다)New view manager. (scale 1, size and view area 0, the view area appears only after calling calculate_view_rect)
짝Counterpart: vanilla.js ViewManager.constructor
pub fn calculate_view_rect(&mut self, physical_width: u32, physical_height: u32, scale_factor: f64)#뷰 영역 계산. (창 크기나 배율이 바뀔 때 엔진이 부른다)
- 창 안쪽 논리 크기는 물리 픽셀을 배율로 나눠 반올림한 값이다.
Computes the view area. (called by the engine when the window size or scale changes)
- The logical size inside the window is the physical pixels divided by the scale, rounded.
- physical_widthu32
- 창 안쪽 너비. (물리 픽셀)Inner width of the window. (physical pixels)
- physical_heightu32
- 창 안쪽 높이. (물리 픽셀)Inner height of the window. (physical pixels)
- scale_factorf64
- 창의 배율. (원본 devicePixelRatio, 0 이하면 1)Window scale factor. (the original devicePixelRatio, 1 if 0 or less)
짝Counterpart: vanilla.js ViewManager.calculateViewRect
use vanilla::{Vector2, ViewManager, ViewScaleMode};
let mut view_manager = ViewManager::new(Vector2::create(1280.0, 720.0), ViewScaleMode::StretchWidthExpandHeight);
view_manager.calculate_view_rect(1500, 2000, 2.0);
assert_eq!(view_manager.get_canvas_native_size(), Vector2::create(750.0, 1000.0));
assert_eq!(view_manager.get_view_size(), Vector2::create(1280.0, 1707.0));pub fn apply_transform(&self, graphic: &mut Graphic, scale_x: f64, scale_y: f64, skew_x: f64, skew_y: f64, translate_x: f64, translate_y: f64)#좌표계 적용.
- graphic.set_transform(scale_x, skew_y, skew_x, scale_y, translate_x, translate_y) 와 같다. (Canvas2D 의 a, b, c, d, e, f 차례)
Applies the coordinate system.
- Same as graphic.set_transform(scale_x, skew_y, skew_x, scale_y, translate_x, translate_y). (Canvas2D order a, b, c, d, e, f)
- graphic&mut Graphic
- 좌표계를 걸 그래픽.Graphic to set the coordinate system on.
- scale_xf64
- 가로 배율. (행렬의 a)Horizontal scale. (matrix a)
- scale_yf64
- 세로 배율. (행렬의 d)Vertical scale. (matrix d)
- skew_xf64
- 가로 기울임. (행렬의 c)Horizontal skew. (matrix c)
- skew_yf64
- 세로 기울임. (행렬의 b)Vertical skew. (matrix b)
- translate_xf64
- 가로 이동. (그리기 버퍼 픽셀, 행렬의 e)Horizontal translation. (drawing buffer pixels, matrix e)
- translate_yf64
- 세로 이동. (그리기 버퍼 픽셀, 행렬의 f)Vertical translation. (drawing buffer pixels, matrix f)
짝Counterpart: vanilla.js ViewManager.applyTransform
화면 전체 영역 적용. (좌표 단위 = canvas_native_size)
Applies the full screen area. (coordinate unit = canvas_native_size)
- graphic&mut Graphic
- 좌표계를 걸 그래픽.Graphic to set the coordinate system on.
짝Counterpart: vanilla.js ViewManager.applyCanvasNativeRect
뷰 영역 적용. (좌표 단위 = get_view_size(), 모드를 가리지 않고 같은 코드로 그린다)
Applies the view area. (coordinate unit = get_view_size(), draws with the same code regardless of mode)
- graphic&mut Graphic
- 좌표계를 걸 그래픽.Graphic to set the coordinate system on.
짝Counterpart: vanilla.js ViewManager.applyViewRect
기준 해상도 재설정.
- 뷰 영역은 다음 calculate_view_rect 부터 바뀐다.
Resets the reference resolution.
- The view area changes from the next calculate_view_rect.
- reference_resolution_sizeVector2
- 새 기준 해상도. (픽셀)New reference resolution. (pixels)
짝Counterpart: vanilla.js ViewManager.applyReferenceResolutionSize
배율. (원본 devicePixelRatio)
Scale factor. (the original devicePixelRatio)
반환Returnsf64 창의 배율. (calculate_view_rect 에 넘긴 값, 0 이하였으면 1, 처음 1)Scale of the window. (the value passed to calculate_view_rect, 1 if it was 0 or less, initially 1)
짝Counterpart: vanilla.js ViewManager.getDevicePixelRatio
뷰 스케일 모드 설정. (다음 calculate_view_rect 부터 반영)
Sets the view scale mode. (applied from the next calculate_view_rect)
- view_scale_modeViewScaleMode
- 새 뷰 스케일 모드.New view scale mode.
짝Counterpart: vanilla.js ViewManager.setViewScaleMode
뷰 스케일 모드 반환.
Returns the view scale mode.
반환ReturnsViewScaleMode 지금 뷰 스케일 모드.Current view scale mode.
짝Counterpart: vanilla.js ViewManager.getViewScaleMode
페이지 전체 크기. (원본 window.innerWidth, innerHeight, 데스크탑은 창 안쪽 논리 크기)
Full page size. (the original window.innerWidth, innerHeight, the logical inner window size on desktop)
반환ReturnsVector2 페이지 전체의 논리 크기. (calculate_view_rect 전에는 0)Logical size of the whole page. (0 before calculate_view_rect)
짝Counterpart: vanilla.js ViewManager.getClientNativeSize
창 안쪽 논리 크기.
Logical inner window size.
반환ReturnsVector2 창 안쪽 크기. (논리 픽셀, 물리 픽셀 / 배율을 반올림, calculate_view_rect 전에는 0)Inner window size. (logical pixels, physical pixels / scale rounded, 0 before calculate_view_rect)
짝Counterpart: vanilla.js ViewManager.getCanvasNativeSize
창 안쪽 물리 픽셀 크기.
Inner window size in physical pixels.
반환ReturnsVector2 그리기 버퍼 크기. (물리 픽셀, calculate_view_rect 에 넘긴 값)Drawing buffer size. (physical pixels, the value passed to calculate_view_rect)
짝Counterpart: vanilla.js ViewManager.getCanvasPixelSize
기준 해상도.
Reference resolution.
반환ReturnsVector2 기준 해상도. (픽셀)Reference resolution. (pixels)
짝Counterpart: vanilla.js ViewManager.getReferenceResolutionSize
뷰 크기.
View size.
반환ReturnsVector2 씬이 그리는 좌표계의 크기. (None 모드는 창 안쪽 논리 크기, ExpandHeight 와 ExpandWidth 와 ExpandLong 은 창 비율로 셈한 크기, 그 밖은 기준 해상도)Size of the coordinate system the scene draws in. (the logical inner window size in None mode, a size computed from the window ratio in ExpandHeight, ExpandWidth and ExpandLong, otherwise the reference resolution)
짝Counterpart: vanilla.js ViewManager.getViewSize
뷰 영역. (창 안쪽 논리 좌표)
View area. (logical inner window coordinates)
반환ReturnsRect 창 안에서 뷰가 차지하는 영역. (논리 픽셀, 남는 여백은 영역 밖)Area the view takes up inside the window. (logical pixels, leftover margins are outside the area)
짝Counterpart: vanilla.js ViewManager.getViewNativeRect
기준 해상도 → 화면 배율.
Reference resolution → screen scale.
반환Returnsf64 뷰 한 단위가 창 안쪽 논리 픽셀 몇 개인지. (None 과 ReferenceResolution 모드는 1)How many logical inner window pixels one view unit is. (1 in None and ReferenceResolution modes)
짝Counterpart: vanilla.js ViewManager.getTargetResolutionScale
뷰 한 단위가 화면에서 몇 CSS 픽셀인지. (캔버스의 CSS 높이 / 뷰 높이, 못 재면 1)
- 뷰의 고정된 쪽은 늘 같은 길이라, 작은 화면(포털의 PC iframe 등)에서는 한 단위가 1 CSS 픽셀보다 한참 작아져 글자가 읽히지 않는다. UI 층만 키울 배율을 셈할 때 쓴다. (예: 최소 CSS 배율 / 이 값)
How many CSS pixels one view unit is on screen. (CSS height of the canvas / view height, 1 if it cannot be measured)
- The fixed side of the view is always the same length, so on a small screen (a portal's PC iframe and so on) one unit becomes much smaller than 1 CSS pixel and text becomes unreadable. Used to compute a scale that enlarges only the UI layer. (e.g. minimum CSS scale / this value)
반환Returnsf64 창 안쪽 논리 높이 / 뷰 높이. (둘 가운데 하나라도 0 이하면 1)Logical inner window height / view height. (1 if either is 0 or less)
짝Counterpart: vanilla.js ViewManager.getCssPixelScale
렌더 배율 상한 설정. (고DPI 기기에서 캔버스가 지나치게 커지지 않게, 0 이면 제한하지 않는다)
- 같은 값이면 아무것도 하지 않는다. 바뀌면 값만 적고 is_view_rect_pending 을 세운다.
- 캔버스 크기는 다음 프레임 머리에서 창 크기 바뀜과 같은 길(Engine::resize)로 맞춘다. (씬도 화면 영역이 바뀐 것을 받는다) 프레임 가운데(tick, draw)에서 캔버스 크기를 바꾸면 그리기 버퍼가 비워지는데 그 프레임은 앞서 맞춘 뷰포트로 그려 한 프레임이 까맣다.
- 웹은 캔버스 드로잉 버퍼를 줄이고, 데스크탑은 그 배율로 줄인 크기로 그리고 프레임 끝에 창 크기로 늘인다. (desktop/renderscaler.rs)
Sets the maximum render pixel ratio. (Keeps the canvas from growing too large on high-DPI devices, 0 means no limit)
- Does nothing for the same value. When it changes, only the value is stored and is_view_rect_pending is raised.
- The canvas size is fitted at the head of the next frame through the same path as a window resize (Engine::resize). (Scenes also receive the changed screen area) Changing the canvas size in the middle of a frame (tick, draw) clears the drawing buffer, and that frame is drawn with the viewport set earlier, so one frame turned black.
- The web shrinks the canvas drawing buffer; the desktop draws at the size reduced by that ratio and stretches it to the window size at the end of the frame. (desktop/renderscaler.rs)
- max_render_pixel_ratiof64
- 렌더 배율 상한. (0 이면 제한 없음, 음수는 0 으로 둔다)Render scale cap. (0 means no limit, negative values become 0)
짝Counterpart: vanilla.js ViewManager.setMaxRenderPixelRatio
다음 프레임 머리에 뷰 영역을 다시 셈할지 반환. (렌더 배율 상한을 바꾼 뒤 아직 맞추지 않았으면 true)
Returns whether the view area should be recalculated at the head of the next frame. (true if the maximum render pixel ratio was changed and not yet applied)
반환Returnsbool 다시 셈할 것이 남았으면 true. (calculate_view_rect 가 맞추면 false)true if a recalculation is still pending. (false once calculate_view_rect has fitted it)
짝Counterpart: vanilla.js ViewManager.isViewRectPending
use vanilla::{Vector2, ViewManager, ViewScaleMode};
let mut view_manager = ViewManager::new(Vector2::create(1280.0, 720.0), ViewScaleMode::StretchShort);
view_manager.set_max_render_pixel_ratio(1.0);
assert!(view_manager.is_view_rect_pending());
view_manager.calculate_view_rect(1280, 720, 1.0);
assert!(!view_manager.is_view_rect_pending());렌더 배율 상한 반환.
Returns the render scale upper limit.
반환Returnsf64 렌더 배율 상한. (0 이면 제한 없음, 기본 0)Render scale cap. (0 means no limit, default 0)
짝Counterpart: vanilla.js ViewManager.getMaxRenderPixelRatio
장치 배율에 렌더 배율 상한 걸기. (상한이 0 이거나 배율이 상한 이하면 그대로, 웹은 캔버스 크기를, 데스크탑은 그릴 크기를 정할 때 부른다)
Applies the render scale cap to the device scale factor. (unchanged if the cap is 0 or the scale is at or below the cap, called by the web when setting the canvas size and by desktop when setting the draw size)
- device_pixel_ratiof64
- 장치 배율.Device scale.
반환Returnsf64 상한을 건 배율.Capped scale.
짝Counterpart: vanilla.js ViewManager.limitRenderPixelRatio
use vanilla::{Vector2, ViewManager, ViewScaleMode};
let mut view_manager = ViewManager::new(Vector2::create(1280.0, 720.0), ViewScaleMode::StretchShort);
view_manager.set_max_render_pixel_ratio(2.0);
assert_eq!(view_manager.limit_render_pixel_ratio(3.0), 2.0);
assert_eq!(view_manager.limit_render_pixel_ratio(1.5), 1.5);종횡비에 맞는 뷰 스케일 모드 자동 선택. (바뀌면 바로 뷰 영역을 다시 셈한다)
- 화면이 기준 해상도보다 세로로 길면 가로를 고정하고 세로를 늘리고(StretchWidthExpandHeight), 가로로 길면 세로를 고정하고 가로를 늘린다(StretchHeightExpandWidth). (여러 게임이 복붙하던 로직)
Automatically picks the view scale mode that fits the aspect ratio. (recomputes the view area right away if it changes)
- If the screen is taller than the reference resolution, it fixes the width and expands the height (StretchWidthExpandHeight), and if it is wider, it fixes the height and expands the width (StretchHeightExpandWidth). (logic several games used to copy and paste)
짝Counterpart: vanilla.js ViewManager.applyAspectViewScaleMode
use vanilla::{Vector2, ViewManager, ViewScaleMode};
let mut view_manager = ViewManager::new(Vector2::create(1280.0, 720.0), ViewScaleMode::StretchShort);
view_manager.calculate_view_rect(1500, 2000, 2.0);
view_manager.apply_aspect_view_scale_mode();
assert_eq!(view_manager.get_view_scale_mode(), ViewScaleMode::StretchWidthExpandHeight);
assert_eq!(view_manager.get_view_size(), Vector2::create(1280.0, 1707.0));세이프 에어리어 강제값 설정. (CSS 픽셀, 데스크탑에서 노치를 흉내 낼 때, None 이면 풀기)
Sets a forced safe area value. (CSS pixels, for mimicking a notch on desktop, None clears it)
- insetsOption<SafeAreaInsets>
- 강제할 인셋. (CSS 픽셀) None 이면 풀고 주소 값이나 CSS 값을 쓴다.Insets to force. (CSS pixels) None clears it and uses the URL value or the CSS value.
짝Counterpart: vanilla.js ViewManager.setSafeAreaOverride
세이프 에어리어 인셋. (뷰 좌표)
- 우선순위: set_safe_area_override > 주소 ?safeArea=위,오른쪽,아래,왼쪽 > CSS env(safe-area-inset-*) 실측.
- CSS 픽셀을 기준 해상도 배율로 나눠 뷰 좌표로 바꾼다.
Safe area insets. (view coordinates)
- Priority: set_safe_area_override > URL ?safeArea=top,right,bottom,left > measured CSS env(safe-area-inset-*).
- Converts CSS pixels to view coordinates by dividing by the reference resolution scale.
반환ReturnsSafeAreaInsets 뷰 좌표의 인셋. (무시할 쪽은 0, 배율이 0 이하면 CSS 픽셀 그대로)Insets in view coordinates. (0 for ignored sides, CSS pixels as they are if the scale is 0 or less)
짝Counterpart: vanilla.js ViewManager.getSafeAreaInsets
무시할 세이프 에어리어 쪽 설정. (get_safe_area_insets 가 그 쪽을 0 으로 돌려준다, 빈 목록이면 모두 쓴다)
- 플랫폼의 앱이 그 쪽을 이미 비켜 그리는 웹뷰처럼, 어느 쪽을 무시할지는 게임이 정해 넘긴다.
Sets the safe area sides to ignore. (get_safe_area_insets returns 0 for those sides, an empty list uses all of them)
- The game decides which sides to ignore and passes them in, as with a web view where the platform's app already draws around those sides.
- sides&[SafeAreaSide]
- 무시할 쪽 목록. (복사해 든다)List of sides to ignore. (copied and kept)
짝Counterpart: vanilla.js ViewManager.setIgnoredSafeAreaSides
use vanilla::{SafeAreaInsets, SafeAreaSide, Vector2, ViewManager, ViewScaleMode};
let mut view_manager = ViewManager::new(Vector2::create(1280.0, 720.0), ViewScaleMode::None);
view_manager.calculate_view_rect(1280, 720, 1.0);
view_manager.set_safe_area_override(Some(SafeAreaInsets::create(40.0, 10.0, 30.0, 20.0)));
view_manager.set_ignored_safe_area_sides(&[SafeAreaSide::Top, SafeAreaSide::Left]);
assert_eq!(view_manager.get_safe_area_insets(), SafeAreaInsets::create(0.0, 10.0, 30.0, 0.0));무시할 세이프 에어리어 쪽 반환.
Returns the safe area sides to ignore.
반환Returns&[SafeAreaSide] 무시할 쪽 목록. (기본 빈 목록)List of sides to ignore. (empty list by default)
짝Counterpart: vanilla.js ViewManager.getIgnoredSafeAreaSides
창 안쪽 논리 좌표 → 뷰 좌표.
Logical inner window coordinates → view coordinates.
- canvas_positionVector2
- 창 안쪽 논리 좌표. (왼쪽 위 0)Logical inner window coordinates. (top left is 0)
반환ReturnsVector2 뷰 좌표. (반올림한 값, 배율이 0 이면 (0, 0))View coordinates. (rounded, (0, 0) if the scale is 0)
짝Counterpart: vanilla.js ViewManager.canvasPositionToViewPosition
화면(client) 좌표를 뷰 좌표로. (캔버스의 지금 자리를 빼서 canvas_position_to_view_position 으로 바꾼다)
Converts screen (client) coordinates to view coordinates. (subtracts the canvas's current position and converts with canvas_position_to_view_position)
- client_xf64
- 화면 x. (논리 픽셀, 웹은 페이지 기준, 데스크탑은 창 안쪽 기준)Screen x. (logical pixels, relative to the page on the web, relative to the inner window on desktop)
- client_yf64
- 화면 y. (논리 픽셀)Screen y. (logical pixels)
반환ReturnsVector2 뷰 좌표. (반올림한 값)View coordinates. (rounded)
짝Counterpart: vanilla.js ViewManager.convertClientToView
SafeAreaSideenum traits Clone, Copy, Debug, PartialEq, Eq
세이프 에어리어의 쪽. (원본 "top", "right", "bottom", "left")
A side of the safe area. (the original "top", "right", "bottom", "left")
| 이름Name | 설명Description |
|---|---|
Top | 위 쪽. (원본 "top")Top. (the original "top") |
Right | 오른쪽. (원본 "right")Right. (the original "right") |
Bottom | 아래 쪽. (원본 "bottom")Bottom. (the original "bottom") |
Left | 왼쪽. (원본 "left")Left. (the original "left") |
ViewScaleModeenum traits Clone, Copy, Debug, PartialEq, Eq
뷰 스케일 모드.
View scale mode.
| 이름Name | 설명Description |
|---|---|
None | 사용안함 (창 크기가 바뀌면 뷰 영역도 바뀐다)Disabled (the view area also changes when the window size changes) |
ReferenceResolution | 기준해상도로 뷰 영역 정의 (양쪽 축이 잘리거나 남을 수 있음)Defines the view area by the reference resolution (both axes may be cropped or have leftover space) |
StretchWidth | 기준해상도 + 비율을 유지한채 가로축으로 늘여붙임. (반대 축은 잘리거나 남을 수 있음)Reference resolution + stretches to fit along the horizontal axis while keeping the aspect ratio. (The opposite axis may be cropped or have leftover space) |
StretchHeight | 기준해상도 + 비율을 유지한채 세로축으로 늘여붙임. (반대 축은 잘리거나 남을 수 있음)Reference resolution + stretches to fit along the vertical axis while keeping the aspect ratio. (The opposite axis may be cropped or have leftover space) |
StretchShort | 기준해상도 + 비율을 유지한채 가로세로 중에서 짧은 축으로 늘여붙임. (반대 축은 남을 수 있음)Reference resolution + stretches to fit along the shorter of the two axes while keeping the aspect ratio. (The opposite axis may have leftover space) |
StretchWidthExpandHeight | 가로를 화면 전체에 늘여붙임. 세로는 화면 비율에 따라 자동 산출. 여백 없음.Stretches the width across the whole screen. The height is computed automatically from the screen ratio. No margins. |
StretchHeightExpandWidth | 세로를 화면 전체에 늘여붙임. 가로는 화면 비율에 따라 자동 산출. 여백 없음.Stretches the height across the whole screen. The width is computed automatically from the screen ratio. No margins. |
StretchShortExpandLong | 짧은 축 기준 스케일. 긴 축도 화면 전체에 늘여붙임. 여백 없음.Scales by the short axis. The long axis is also stretched across the whole screen. No margins. |
원본과 같은 이름 글. (원본 ViewScaleMode 의 값, "stretchShort" 같은 낙타 꼴)
Name text same as the original. (the value of the original ViewScaleMode, camel case like "stretchShort")
반환Returns&'static str 이름 글. ("none", "referenceResolution", "stretchWidth", "stretchHeight", "stretchShort", "stretchWidthExpandHeight", "stretchHeightExpandWidth", "stretchShortExpandLong")Name text. ("none", "referenceResolution", "stretchWidth", "stretchHeight", "stretchShort", "stretchWidthExpandHeight", "stretchHeightExpandWidth", "stretchShortExpandLong")
use vanilla::ViewScaleMode;
assert_eq!(ViewScaleMode::StretchShort.get_name(), "stretchShort");
assert_eq!(format!("viewScaleMode: {}", ViewScaleMode::ReferenceResolution.get_name()), "viewScaleMode: referenceResolution");