ホーム › Graphics.Gdi › Arc
Arc
関数指定した矩形と境界点に沿って楕円弧を描画する。
シグネチャ
// GDI32.dll
#include <windows.h>
BOOL Arc(
HDC hdc,
INT x1,
INT y1,
INT x2,
INT y2,
INT x3,
INT y3,
INT x4,
INT y4
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdc | HDC | in | 描画先のデバイスコンテキストへのハンドル。 |
| x1 | INT | in | 境界矩形の左上隅の x 座標(論理単位)。 |
| y1 | INT | in | 境界矩形の左上隅の y 座標(論理単位)。 |
| x2 | INT | in | 境界矩形の右下隅の x 座標(論理単位)。 |
| y2 | INT | in | 境界矩形の右下隅の y 座標(論理単位)。 |
| x3 | INT | in | 弧の始点を定義する半径線の端点の x 座標(論理単位)。 |
| y3 | INT | in | 弧の始点を定義する半径線の端点の y 座標(論理単位)。 |
| x4 | INT | in | 弧の終点を定義する半径線の端点の x 座標(論理単位)。 |
| y4 | INT | in | 弧の終点を定義する半径線の端点の y 座標(論理単位)。 |
戻り値の型: BOOL
公式ドキュメント
Arc 関数は楕円弧を描画します。
戻り値
弧が描画された場合、戻り値は 0 以外になります。
弧が描画されなかった場合、戻り値は 0 になります。
解説(Remarks)
点 (nLeftRect, nTopRect) と (nRightRect, nBottomRect) は境界矩形を指定します。指定した境界矩形によって形成される楕円が弧の曲線を定義します。弧は、境界矩形の中心から (nXStartArc, nYStartArc) 点へ引いた半径線と交わる点から、現在の描画方向に向かって伸びます。弧は、境界矩形の中心から (nXEndArc, nYEndArc) 点へ引いた半径線と交わる点で終わります。始点と終点が同じ場合は、完全な楕円が描画されます。
弧は現在のペンを使用して描画され、塗りつぶされません。
現在の位置は Arc によって使用も更新もされません。
デバイスコンテキストの現在の描画方向を取得および設定するには、GetArcDirection 関数および SetArcDirection 関数を使用します。既定の描画方向は反時計回りです。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// GDI32.dll
#include <windows.h>
BOOL Arc(
HDC hdc,
INT x1,
INT y1,
INT x2,
INT y2,
INT x3,
INT y3,
INT x4,
INT y4
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool Arc(
IntPtr hdc, // HDC
int x1, // INT
int y1, // INT
int x2, // INT
int y2, // INT
int x3, // INT
int y3, // INT
int x4, // INT
int y4 // INT
);<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function Arc(
hdc As IntPtr, ' HDC
x1 As Integer, ' INT
y1 As Integer, ' INT
x2 As Integer, ' INT
y2 As Integer, ' INT
x3 As Integer, ' INT
y3 As Integer, ' INT
x4 As Integer, ' INT
y4 As Integer ' INT
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hdc : HDC
' x1 : INT
' y1 : INT
' x2 : INT
' y2 : INT
' x3 : INT
' y3 : INT
' x4 : INT
' y4 : INT
Declare PtrSafe Function Arc Lib "gdi32" ( _
ByVal hdc As LongPtr, _
ByVal x1 As Long, _
ByVal y1 As Long, _
ByVal x2 As Long, _
ByVal y2 As Long, _
ByVal x3 As Long, _
ByVal y3 As Long, _
ByVal x4 As Long, _
ByVal y4 As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
Arc = ctypes.windll.gdi32.Arc
Arc.restype = wintypes.BOOL
Arc.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_int, # x1 : INT
ctypes.c_int, # y1 : INT
ctypes.c_int, # x2 : INT
ctypes.c_int, # y2 : INT
ctypes.c_int, # x3 : INT
ctypes.c_int, # y3 : INT
ctypes.c_int, # x4 : INT
ctypes.c_int, # y4 : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
Arc = Fiddle::Function.new(
lib['Arc'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_INT, # x1 : INT
Fiddle::TYPE_INT, # y1 : INT
Fiddle::TYPE_INT, # x2 : INT
Fiddle::TYPE_INT, # y2 : INT
Fiddle::TYPE_INT, # x3 : INT
Fiddle::TYPE_INT, # y3 : INT
Fiddle::TYPE_INT, # x4 : INT
Fiddle::TYPE_INT, # y4 : INT
],
Fiddle::TYPE_INT)#[link(name = "gdi32")]
extern "system" {
fn Arc(
hdc: *mut core::ffi::c_void, // HDC
x1: i32, // INT
y1: i32, // INT
x2: i32, // INT
y2: i32, // INT
x3: i32, // INT
y3: i32, // INT
x4: i32, // INT
y4: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool Arc(IntPtr hdc, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_Arc' -Namespace Win32 -PassThru
# $api::Arc(hdc, x1, y1, x2, y2, x3, y3, x4, y4)#uselib "GDI32.dll"
#func global Arc "Arc" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; Arc hdc, x1, y1, x2, y2, x3, y3, x4, y4 ; 戻り値は stat
; hdc : HDC -> "sptr"
; x1 : INT -> "sptr"
; y1 : INT -> "sptr"
; x2 : INT -> "sptr"
; y2 : INT -> "sptr"
; x3 : INT -> "sptr"
; y3 : INT -> "sptr"
; x4 : INT -> "sptr"
; y4 : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "GDI32.dll"
#cfunc global Arc "Arc" sptr, int, int, int, int, int, int, int, int
; res = Arc(hdc, x1, y1, x2, y2, x3, y3, x4, y4)
; hdc : HDC -> "sptr"
; x1 : INT -> "int"
; y1 : INT -> "int"
; x2 : INT -> "int"
; y2 : INT -> "int"
; x3 : INT -> "int"
; y3 : INT -> "int"
; x4 : INT -> "int"
; y4 : INT -> "int"; BOOL Arc(HDC hdc, INT x1, INT y1, INT x2, INT y2, INT x3, INT y3, INT x4, INT y4)
#uselib "GDI32.dll"
#cfunc global Arc "Arc" intptr, int, int, int, int, int, int, int, int
; res = Arc(hdc, x1, y1, x2, y2, x3, y3, x4, y4)
; hdc : HDC -> "intptr"
; x1 : INT -> "int"
; y1 : INT -> "int"
; x2 : INT -> "int"
; y2 : INT -> "int"
; x3 : INT -> "int"
; y3 : INT -> "int"
; x4 : INT -> "int"
; y4 : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procArc = gdi32.NewProc("Arc")
)
// hdc (HDC), x1 (INT), y1 (INT), x2 (INT), y2 (INT), x3 (INT), y3 (INT), x4 (INT), y4 (INT)
r1, _, err := procArc.Call(
uintptr(hdc),
uintptr(x1),
uintptr(y1),
uintptr(x2),
uintptr(y2),
uintptr(x3),
uintptr(y3),
uintptr(x4),
uintptr(y4),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction Arc(
hdc: THandle; // HDC
x1: Integer; // INT
y1: Integer; // INT
x2: Integer; // INT
y2: Integer; // INT
x3: Integer; // INT
y3: Integer; // INT
x4: Integer; // INT
y4: Integer // INT
): BOOL; stdcall;
external 'GDI32.dll' name 'Arc';result := DllCall("GDI32\Arc"
, "Ptr", hdc ; HDC
, "Int", x1 ; INT
, "Int", y1 ; INT
, "Int", x2 ; INT
, "Int", y2 ; INT
, "Int", x3 ; INT
, "Int", y3 ; INT
, "Int", x4 ; INT
, "Int", y4 ; INT
, "Int") ; return: BOOL●Arc(hdc, x1, y1, x2, y2, x3, y3, x4, y4) = DLL("GDI32.dll", "bool Arc(void*, int, int, int, int, int, int, int, int)")
# 呼び出し: Arc(hdc, x1, y1, x2, y2, x3, y3, x4, y4)
# hdc : HDC -> "void*"
# x1 : INT -> "int"
# y1 : INT -> "int"
# x2 : INT -> "int"
# y2 : INT -> "int"
# x3 : INT -> "int"
# y3 : INT -> "int"
# x4 : INT -> "int"
# y4 : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "gdi32" fn Arc(
hdc: ?*anyopaque, // HDC
x1: i32, // INT
y1: i32, // INT
x2: i32, // INT
y2: i32, // INT
x3: i32, // INT
y3: i32, // INT
x4: i32, // INT
y4: i32 // INT
) callconv(std.os.windows.WINAPI) i32;proc Arc(
hdc: pointer, # HDC
x1: int32, # INT
y1: int32, # INT
x2: int32, # INT
y2: int32, # INT
x3: int32, # INT
y3: int32, # INT
x4: int32, # INT
y4: int32 # INT
): int32 {.importc: "Arc", stdcall, dynlib: "GDI32.dll".}pragma(lib, "gdi32");
extern(Windows)
int Arc(
void* hdc, // HDC
int x1, // INT
int y1, // INT
int x2, // INT
int y2, // INT
int x3, // INT
int y3, // INT
int x4, // INT
int y4 // INT
);ccall((:Arc, "GDI32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32),
hdc, x1, y1, x2, y2, x3, y3, x4, y4)
# hdc : HDC -> Ptr{Cvoid}
# x1 : INT -> Int32
# y1 : INT -> Int32
# x2 : INT -> Int32
# y2 : INT -> Int32
# x3 : INT -> Int32
# y3 : INT -> Int32
# x4 : INT -> Int32
# y4 : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t Arc(
void* hdc,
int32_t x1,
int32_t y1,
int32_t x2,
int32_t y2,
int32_t x3,
int32_t y3,
int32_t x4,
int32_t y4);
]]
local gdi32 = ffi.load("gdi32")
-- gdi32.Arc(hdc, x1, y1, x2, y2, x3, y3, x4, y4)
-- hdc : HDC
-- x1 : INT
-- y1 : INT
-- x2 : INT
-- y2 : INT
-- x3 : INT
-- y3 : INT
-- x4 : INT
-- y4 : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GDI32.dll');
const Arc = lib.func('__stdcall', 'Arc', 'int32_t', ['void *', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t']);
// Arc(hdc, x1, y1, x2, y2, x3, y3, x4, y4)
// hdc : HDC -> 'void *'
// x1 : INT -> 'int32_t'
// y1 : INT -> 'int32_t'
// x2 : INT -> 'int32_t'
// y2 : INT -> 'int32_t'
// x3 : INT -> 'int32_t'
// y3 : INT -> 'int32_t'
// x4 : INT -> 'int32_t'
// y4 : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GDI32.dll", {
Arc: { parameters: ["pointer", "i32", "i32", "i32", "i32", "i32", "i32", "i32", "i32"], result: "i32" },
});
// lib.symbols.Arc(hdc, x1, y1, x2, y2, x3, y3, x4, y4)
// hdc : HDC -> "pointer"
// x1 : INT -> "i32"
// y1 : INT -> "i32"
// x2 : INT -> "i32"
// y2 : INT -> "i32"
// x3 : INT -> "i32"
// y3 : INT -> "i32"
// x4 : INT -> "i32"
// y4 : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t Arc(
void* hdc,
int32_t x1,
int32_t y1,
int32_t x2,
int32_t y2,
int32_t x3,
int32_t y3,
int32_t x4,
int32_t y4);
C, "GDI32.dll");
// $ffi->Arc(hdc, x1, y1, x2, y2, x3, y3, x4, y4);
// hdc : HDC
// x1 : INT
// y1 : INT
// x2 : INT
// y2 : INT
// x3 : INT
// y3 : INT
// x4 : INT
// y4 : INT
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Gdi32 extends StdCallLibrary {
Gdi32 INSTANCE = Native.load("gdi32", Gdi32.class);
boolean Arc(
Pointer hdc, // HDC
int x1, // INT
int y1, // INT
int x2, // INT
int y2, // INT
int x3, // INT
int y3, // INT
int x4, // INT
int y4 // INT
);
}@[Link("gdi32")]
lib LibGDI32
fun Arc = Arc(
hdc : Void*, # HDC
x1 : Int32, # INT
y1 : Int32, # INT
x2 : Int32, # INT
y2 : Int32, # INT
x3 : Int32, # INT
y3 : Int32, # INT
x4 : Int32, # INT
y4 : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ArcNative = Int32 Function(Pointer<Void>, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32);
typedef ArcDart = int Function(Pointer<Void>, int, int, int, int, int, int, int, int);
final Arc = DynamicLibrary.open('GDI32.dll')
.lookupFunction<ArcNative, ArcDart>('Arc');
// hdc : HDC -> Pointer<Void>
// x1 : INT -> Int32
// y1 : INT -> Int32
// x2 : INT -> Int32
// y2 : INT -> Int32
// x3 : INT -> Int32
// y3 : INT -> Int32
// x4 : INT -> Int32
// y4 : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function Arc(
hdc: THandle; // HDC
x1: Integer; // INT
y1: Integer; // INT
x2: Integer; // INT
y2: Integer; // INT
x3: Integer; // INT
y3: Integer; // INT
x4: Integer; // INT
y4: Integer // INT
): BOOL; stdcall;
external 'GDI32.dll' name 'Arc';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "Arc"
c_Arc :: Ptr () -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO CInt
-- hdc : HDC -> Ptr ()
-- x1 : INT -> Int32
-- y1 : INT -> Int32
-- x2 : INT -> Int32
-- y2 : INT -> Int32
-- x3 : INT -> Int32
-- y3 : INT -> Int32
-- x4 : INT -> Int32
-- y4 : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let arc =
foreign "Arc"
((ptr void) @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* x1 : INT -> int32_t *)
(* y1 : INT -> int32_t *)
(* x2 : INT -> int32_t *)
(* y2 : INT -> int32_t *)
(* x3 : INT -> int32_t *)
(* y3 : INT -> int32_t *)
(* x4 : INT -> int32_t *)
(* y4 : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdi32 (t "GDI32.dll"))
(cffi:use-foreign-library gdi32)
(cffi:defcfun ("Arc" arc :convention :stdcall) :int32
(hdc :pointer) ; HDC
(x1 :int32) ; INT
(y1 :int32) ; INT
(x2 :int32) ; INT
(y2 :int32) ; INT
(x3 :int32) ; INT
(y3 :int32) ; INT
(x4 :int32) ; INT
(y4 :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $Arc = Win32::API::More->new('GDI32',
'BOOL Arc(HANDLE hdc, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)');
# my $ret = $Arc->Call($hdc, $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4);
# hdc : HDC -> HANDLE
# x1 : INT -> int
# y1 : INT -> int
# x2 : INT -> int
# y2 : INT -> int
# x3 : INT -> int
# y3 : INT -> int
# x4 : INT -> int
# y4 : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f AngleArc — 中心と半径、開始角と掃引角で指定した円弧を描画する。
- f ArcTo — 現在位置から円弧を描画し現在位置を更新する。
- f Chord — 楕円と直線で囲まれた弦(コード)図形を描画する。
- f Ellipse — 指定矩形に内接する楕円を描画する。
- f GetArcDirection — DCの現在の円弧描画方向を取得する。
- f Pie — 楕円の一部からなる扇形(パイ)を描画する。
- f SetArcDirection — 円弧や矩形を描画する際の回転方向を設定する。