Win32 API 日本語リファレンス
ホームGraphics.DirectWrite › DWRITE_COLOR_F

DWRITE_COLOR_F

構造体
サイズx64: 16 バイト / x86: 16 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
rFLOAT4+0+0赤成分の値。0.0~1.0の範囲の浮動小数で示す。
gFLOAT4+4+4緑成分の値。0.0~1.0の範囲の浮動小数で示す。
bFLOAT4+8+8青成分の値。0.0~1.0の範囲の浮動小数で示す。
aFLOAT4+12+12アルファ(不透明度)の値。0.0~1.0の範囲の浮動小数で示す。

各言語での定義

#include <windows.h>

// DWRITE_COLOR_F  (x64 16 / x86 16 バイト)
typedef struct DWRITE_COLOR_F {
    FLOAT r;
    FLOAT g;
    FLOAT b;
    FLOAT a;
} DWRITE_COLOR_F;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DWRITE_COLOR_F
{
    public float r;
    public float g;
    public float b;
    public float a;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DWRITE_COLOR_F
    Public r As Single
    Public g As Single
    Public b As Single
    Public a As Single
End Structure
import ctypes
from ctypes import wintypes

class DWRITE_COLOR_F(ctypes.Structure):
    _fields_ = [
        ("r", ctypes.c_float),
        ("g", ctypes.c_float),
        ("b", ctypes.c_float),
        ("a", ctypes.c_float),
    ]
#[repr(C)]
pub struct DWRITE_COLOR_F {
    pub r: f32,
    pub g: f32,
    pub b: f32,
    pub a: f32,
}
import "golang.org/x/sys/windows"

type DWRITE_COLOR_F struct {
	r float32
	g float32
	b float32
	a float32
}
type
  DWRITE_COLOR_F = record
    r: Single;
    g: Single;
    b: Single;
    a: Single;
  end;
const DWRITE_COLOR_F = extern struct {
    r: f32,
    g: f32,
    b: f32,
    a: f32,
};
type
  DWRITE_COLOR_F {.bycopy.} = object
    r: float32
    g: float32
    b: float32
    a: float32
struct DWRITE_COLOR_F
{
    float r;
    float g;
    float b;
    float a;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DWRITE_COLOR_F サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; r : FLOAT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; g : FLOAT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; b : FLOAT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; a : FLOAT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DWRITE_COLOR_F
    #field float r
    #field float g
    #field float b
    #field float a
#endstruct

stdim st, DWRITE_COLOR_F        ; NSTRUCT 変数を確保
st->r = 100
mes "r=" + st->r