Skip to content
Permalink
Browse files

Initial commit

  • Loading branch information...
voximity committed Aug 10, 2019
0 parents commit fabea567743a7dd77b607484b55d9987a92c8e7c
@@ -0,0 +1,9 @@
root = true

[*.cr]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
@@ -0,0 +1,10 @@
/docs/
/lib/
/bin/
/.shards/
*.dwarf
test.cr

# Libraries don't need dependency lock
# Dependencies will be locked in applications that use them
/shard.lock
@@ -0,0 +1,6 @@
language: crystal

# Uncomment the following if you'd like Travis to run specs and check code formatting
# script:
# - crystal spec
# - crystal tool format --check
21 LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 your-name-here

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -0,0 +1,7 @@
# blend2d-cr

Ridiclously unfinished Blend2D bindings for Crystal.

## Usage

Don't.
@@ -0,0 +1,9 @@
name: blend2d-cr
version: 0.1.0

authors:
- voximity <vox@voximity.net>

crystal: 0.30.0

license: MIT
@@ -0,0 +1,9 @@
require "./spec_helper"

describe Blend2d::Cr do
# TODO: Write tests

it "works" do
false.should eq(true)
end
end
@@ -0,0 +1,2 @@
require "spec"
require "../src/blend2d-cr"
@@ -0,0 +1 @@
require "./blend2d/blend2d.cr"
@@ -0,0 +1 @@
require "./c/lib-blend2d.cr"
@@ -0,0 +1,109 @@
module Blend2D::C
@[Link("blend2d")]
lib LibBlend2D
fun context_init = blContextInit(self : BLContextCore*) : BLResult
fun context_init_as = blContextInitAs(self : BLContextCore*, image : BLContextCore*, options : BLContextCreateInfo*) : BLResult
fun context_reset = blContextReset(self : BLContextCore*) : BLResult
fun context_assign_move = blContextAssignMove(self : BLContextCore*, other : BLContextCore*) : BLResult
fun context_assign_weak = blContextAssignMove(self : BLContextCore*, other : BLContextCore*) : BLResult
fun context_get_type = blContextGetType(self : BLContextCore*) : BLResult
fun context_begin = blContextBegin(self : BLContextCore*, image : BLImageCore*, options : BLContextCreateInfo*) : BLResult
fun context_end = blContextEnd(self : BLContextCore*) : BLResult
fun context_flush = blContextFlush(self : BLContextCore*, flags : UInt32) : BLResult
fun context_save = blContextSave(self : BLContextCore*, cookie : BLContextCookie*) : BLResult
fun context_restore = blContextRestore(self : BLContextCore*, cookie : BLContextCookie*) : BLResult
# fun context_get_meta_matrix = blContextGetMetaMatrix(self : BLContextCore*, m : BLMatrix2D*) : BLResult
# fun context_get_user_matrix = blContextGetUserMatrix(self : BLContextCore*, m : BLMatrix2D*) : BLResult
fun context_user_to_meta = blContextUserToMeta(self : BLContextCore*) : BLResult
fun context_matrix_op = blContextMatrixOp(self : BLContextCore*, opType : UInt32, opData : Void*) : BLResult
fun context_set_hint = blContextSetHint(self : BLContextCore*, hintType : UInt32, value : UInt32) : BLResult
# fun context_set_hints = blContextSetHints(self : BLContextCore*, hints : BLContextHints*)
fun context_set_flatten_mode = blContextSetFlattenMode(self : BLContextCore*, mode : UInt32) : BLResult
fun context_set_flatten_tolerance = blContextSetFlattenTolerance(self : BLContextCore*, tolerance : Float64) : BLResult
fun context_set_approximation_options = blContextSetApproximationOptions(self : BLContextCore*, options : BLApproximationOptions*) : BLResult
fun context_set_comp_op = blContextSetCompOp(self : BLContextCore*, compOp : UInt32) : BLResult
fun context_set_global_alpha = blContextSetGlobalAlpha(self : BLContextCore*, alpha : Float64) : BLResult
fun context_set_fill_alpha = blContextSetFillAlpha(self : BLContextCore*, alpha : Float64) : BLResult
fun context_get_fill_style = blContextGetFillStyle(self : BLContextCore*, object : Void*) : BLResult
fun context_get_fill_style_rgba32 = blContextGetFillStyleRgba32(self : BLContextCore*, rgba32 : UInt32*) : BLResult
fun context_get_fill_style_rgba64 = blContextGetFillStyleRgba64(self : BLContextCore*, rgba64 : UInt64*) : BLResult
fun context_set_fill_style = blContextSetFillStyle(self : BLContextCore*, object : Void*) : BLResult
fun context_set_fill_style_rgba32 = blContextSetFillStyleRgba32(self : BLContextCore*, rgba32 : UInt32) : BLResult
fun context_set_fill_style_rgba64 = blContextSetFillStyleRgba64(self : BLContextCore*, rgba64 : UInt64) : BLResult
fun context_set_fill_rule = blContextSetFillRule(self : BLContextCore*, fillRule : UInt32) : BLResult
fun context_set_stroke_alpha = blContextSetStrokeAlpha(self : BLContextCore*, alpha : Float64) : BLResult
fun context_get_stroke_style_rgba32 = blContextGetStrokeStyleRgba32(self : BLContextCore*, rgba32 : UInt32*) : BLResult
fun context_get_stroke_style_rgba64 = blContextGetStrokeStyleRgba64(self : BLContextCore*, rgba64 : UInt64*) : BLResult
fun context_set_stroke_style = blContextSetStrokeStyle(self : BLContextCore*, object : Void*) : BLResult
fun context_set_stroke_style_rgba32 = blContextSetStrokeStyleRgba32(self : BLContextCore*, rgba32 : UInt32) : BLResult
fun context_set_stroke_style_rgba64 = blContextSetStrokeStyleRgba64(self : BLContextCore*, rgba64 : UInt64) : BLResult
fun context_set_stroke_width = blContextSetStrokeWidth(self : BLContextCore*, width : Float64) : BLResult
fun context_set_stroke_miter_limit = blContextSetStrokeMiterLimit(self : BLContextCore*, miterLimit : Float64) : BLResult
fun context_set_stroke_cap = blContextSetStrokeCap(self : BLContextCore*, position : UInt32, strokeCap : UInt32) : BLResult
fun context_set_stroke_caps = blContextSetStrokeCaps(self : BLContextCore*, strokeCap : UInt32) : BLResult
fun context_set_stroke_join = blContextSetStrokeJoin(self : BLContextCore*, strokeJoin : UInt32) : BLResult
fun context_set_stroke_dash_offset = blContextSetStrokeDashOffset(self : BLContextCore*, dashOffset : Float64) : BLResult
# fun context_set_stroke_dash_array = blContextSetStrokeDashArray(self : BLContextCore*, dashArray : BLArrayCore*) : BLResult
fun context_set_stroke_transform_order = blContextSetStrokeTransformOrder(self : BLContextCore*, transformOrder : UInt32) : BLResult
# fun context_get_stroke_options = blContextGetStrokeOptions(self : BLContextCore*, options : BLStrokeOptionsCore*) : BLResult
# fun context_set_stroke_options = blContestSetStrokeOptions(self : BLContextCore*, options : BLStrokeOptionsCore*) : BLResult
# fun context_clip_to_rect_i = blContextClipToRectI(self : BLContextCore*, rect : BLRectI*) : BLResult
# fun context_clip_to_rect_d = blContextClipToRectD(self : BLContextCore*, rect : BLRect*) : BLResult
fun context_restore_clipping = blContextRestoreClipping(self : BLContextCore*) : BLResult
fun context_clear_all = blContextClearAll(self : BLContextCore*) : BLResult
fun context_clear_rect_i = blContextClearRectI(self : BLContextCore*, rect : BLRectI*) : BLResult
fun context_clear_rect_d = blContextClearRectD(self : BLContextCore*, rect : BLRect*) : BLResult
fun context_fill_all = blContextFillAll(self : BLContextCore*) : BLResult
fun context_fill_rect_i = blContextFillRectI(self : BLContextCore*, rect : BLRectI*) : BLResult
fun context_fill_rect_d = blContextFillRectD(self : BLContextCore*, rect : BLRect*) : BLResult
fun context_fill_path_d = blContextFillPathD(self : BLContextCore*, path : BLPathCore*) : BLResult
fun context_fill_geometry = blContextFillGeometry(self : BLContextCore*, geometryType : UInt32, geometryData : Void*) : BLResult
# fun context_fill_text_i = blContextFillTextI(self : BLContextCore*, pt : BLPointI*, font : BLFontCore*, text : Void*, size : UInt32, encoding : UInt32) : BLResult
# fun context_fill_text_d = blContextFillTextD(self : BLContextCore*, pt : BLPoint*, font : BLFontCore*, text : Void*, size : UInt32, encoding : UInt32) : BLResult
# fun context_fill_glyph_run_i = blContextFillGlyphRunI(self : BLContextCore*, pt : BLPointI*, font : BLFontCore*, glyphRun : BLGlyphRun*) : BLResult
# fun context_fill_glyph_run_d = blContextFillGlyphRunD(self : BLContextCore*, pt : BLPoint*, font : BLFontCore*, glyphRun : BLGlyphRun*) : BLResult
fun context_stroke_rect_i = blContextStrokeRectI(self : BLContextCore*, rect : BLRectI*) : BLResult
fun context_stroke_rect_d = blContextStrokeRectD(self : BLContextCore*, rect : BLRect*) : BLResult
# fun context_stroke_path_d = blContextStrokePathD(self : BLContextCore*, path : BLPathCore*) : BLResult
fun context_stroke_geometry = blContextStrokeGeometry(self : BLContextCore*, geometryType : UInt32, geometryData : Void*) : BLResult
# fun context_stroke_text_i = blContextStrokeTextI(self : BLContextCore*, pt : BLPointI*, font : BLFontCore*, text : Void*, size : UInt32, encoding : UInt32) : BLResult
# fun context_stroke_text_d = blContextStrokeTextD(self : BLContextCore*, pt : BLPoint*, font : BLFontCore*, text : Void*, size : UInt32, encoding : UInt32) : BLResult
# fun context_stroke_glyph_run_i = blContextStrokeGlyphRunI(self : BLContextCore*, pt : BLPointI*, font : BLFontCore*, glyphRun : BLGlyphRun*) : BLResult
# fun context_stroke_glyph_run_d = blContextStrokeGlyphRunD(self : BLContextCore*, pt : BLPoint*, font : BLFontCore*, glyphRun : BLGlyphRun*) : BLResult
fun context_blit_image_i = blContextBlitImageI(self : BLContextCore*, rect : BLRectI*, img : BLImageCore*, imgArea : BLRectI*) : BLResult
fun context_blit_image_d = blContextBlitImageD(self : BLContextCore*, rect : BLRect*, img : BLImageCore*, imgArea : BLRectI*) : BLResult
fun context_blit_scaled_image_i = blContextBlitScaledImageI(self : BLContextCore*, rect : BLRectI*, img : BLImageCore*, imgArea : BLRectI*) : BLResult
fun context_blit_scaled_image_d = blContextBlitScaledImageD(self : BLContextCore*, rect : BLRect*, img : BLImageCore*, imgArea : BLRectI*) : BLResult

struct BLContextCookie
data : UInt64[2]
end

struct BLContextCreateInfo
flags : UInt32
threadCount : UInt32
cpuFeatures : UInt32
reserved : UInt32[5] # keep zero!
end

#struct BLContextState
#
#end

struct BLContextImpl
# virt : BLContextVirt*
# state : BLContextState*
reservedHeader : Void*
refCount : UInt32
implType : UInt8
implTraits : UInt8
memPoolData : UInt16
contextType : UInt32
targetSize : BLSize
end

struct BLContextCore
impl : BLContextImpl*
end
end
end
@@ -0,0 +1,59 @@
require "./blresult.cr"

module Blend2D::C
@[Link("blend2d")]
lib LibBlend2D
enum BLFormat
BL_FORMAT_NONE,
BL_FORMAT_PRGB32,
BL_FORMAT_XRGB32,
BL_FORMAT_A8,
BL_FORMAT_COUNT,
BL_FORMAAT_RESERVED_COUNT
end

fun image_init = blImageInit(self : BLImageCore*) : BLResult
fun image_init_as = blImageInitAs(self : BLImageCore*, w : Int32, h : Int32, format : UInt32) : BLResult
# fun image_init_as_from_data = blImageInitAsFromData(self : BLImageCore*, w : Int, h : Int, format : UInt32, pixelData : Void*, stride : Void*, destroyFunc : BLDestroyImplFunc, destroyData : Void*) : BLResult
fun image_reset = blImageReset(self : BLImageCore*) : BLResult
fun image_assign_move = blImageAssignMove(self : BLImageCore*, other : BLImageCore*) : BLResult
fun image_assign_weak = blImageAssignWeak(self : BLImageCore*, other : BLImageCore*) : BLResult
fun image_assign_deep = blImageAssignDeep(self : BLImageCore*, other : BLImageCore*) : BLResult
fun image_create = blImageCreate(self : BLImageCore*, w : Int32, h : Int32, format : UInt32) : BLResult
# fun image_create_from_data = blImageCreateFromData(self : BLImageCore*, w : Int, h : Int, format : UInt32, pixelData : Void*, stride : Void*, destroyFunc : BLDestroyImplFunc, destroyData : Void*) : BLResult
fun image_get_data = blImageGetData(self : BLImageCore*, dataOut : BLImageData*) : BLResult
fun image_make_mutable = blImageMakeMutable(self : BLImageCore*, dataOut : BLImageData*) : BLResult
fun image_equals = blImageEquals(a : BLImageCore*, b : BLImageCore*) : Bool
# fun image_scale = blImageScale(dst : BLImageCore*, src : BLImageCore*, size : BLSizeI*, filter : UInt32, options : BLImageScaleOptions*) : BLResult
# fun image_read_from_file = blImageReadFromFile(self : BLImageCore*, fileName : Char*, codecs : BLArrayCore*)
# fun image_read_from_data = blImageReadFromData(self : BLImageCore*, data, size, codecs)
# fun image_write_to_file = blImageWriteToFile
# fun image_write_to_data = blImageWriteToData

struct BLImageData
pixelData : Void*
stride : Int32*
size : BLSizeI
format : UInt32
flags : UInt32
end

struct BLImageImpl
pixelData : Void*
stride : Int32*
writer : Void*
refCount : UInt32
implType : UInt8
implTraits : UInt8
memPoolData : UInt16
format : UInt8
flags : UInt8
depth : UInt16
size : BLSizeI
end

struct BLImageCore
impl : BLImageImpl*
end
end
end
@@ -0,0 +1,12 @@
module Blend2D::C
@[Link("blend2d")]
lib LibBlend2D
struct BLPathImpl

end

struct BLPathCore
impl : BLPathImpl*
end
end
end
@@ -0,0 +1,84 @@
module Blend2D::C
@[Link("blend2d")]
lib LibBlend2D
enum BLResultCode : UInt32
BL_SUCCESS,
BL_ERROR_OUT_OF_MEMORY,
BL_ERROR_INVALID_VALUE,
BL_ERROR_INVALID_STATE,
BL_ERROR_INVALID_HANDLE,
BL_ERROR_VALUE_TOO_LARGE,
BL_ERROR_NOT_INITIALIZED,
BL_ERROR_NOT_IMPLEMENTED,
BL_ERROR_NOT_PERMITTED,
BL_ERROR_IO,
BL_ERROR_BUSY,
BL_ERROR_INTERRUPTED,
BL_ERROR_TRY_AGAIN,
BL_ERROR_TIMED_OUT,
BL_ERROR_BROKEN_PIPE,
BL_ERROR_INVALID_SEEK,
BL_ERROR_SYMLINK_LOOP,
BL_ERROR_FILE_TOO_LARGE,
BL_ERROR_ALREADY_EXISTS,
BL_ERROR_ACCESS_DENIED,
BL_ERROR_MEDIA_CHANGED,
BL_ERROR_READ_ONLY_FS,
BL_ERROR_NO_DEVICE,
BL_ERROR_NO_ENTRY,
BL_ERROR_NO_MEDIA,
BL_ERROR_NO_MORE_FILES,
BL_ERROR_NO_SPACE_LEFT,
BL_ERROR_NOT_EMPTY,
BL_ERROR_NOT_FILE,
BL_ERROR_NOT_DIRECTORY,
BL_ERROR_NOT_SAME_DEVICE,
BL_ERROR_NOT_BLOCK_DEVICE,
BL_ERROR_INVALID_FILE_NAME,
BL_ERROR_FILE_NAME_TOO_LONG,
BL_ERROR_TOO_MANY_OPEN_FILES,
BL_ERROR_TOO_MANY_OPEN_FILES_BY_OS,
BL_ERROR_TOO_MANY_LINKS,
BL_ERROR_TOO_MANY_THREADS,
BL_ERROR_FILE_EMPTY,
BL_ERROR_OPEN_FAILED,
BL_ERROR_NOT_ROOT_DEVICE,
BL_ERROR_UNKNOWN_SYSTEM_ERROR,
BL_ERROR_INVALID_ALIGNMENT,
BL_ERROR_INVALID_SIGNATURE,
BL_ERROR_INVALID_DATA,
BL_ERROR_INVALID_STRING,
BL_ERROR_DATA_TRUNCATED,
BL_ERROR_DATA_TOO_LARGE,
BL_ERROR_DECOMPRESSION_FAILED,
BL_ERROR_INVALID_GEOMETRY,
BL_ERROR_NO_MATCHING_VERTEX,
BL_ERROR_NO_MATCHING_COOKIE,
BL_ERROR_NO_STATES_TO_RESTORE,
BL_ERROR_IMAGE_TOO_LARGE,
BL_ERROR_IMAGE_NO_MATCHING_CODEC,
BL_ERROR_IMAGE_UNKNOWN_FILE_FORMAT,
BL_ERROR_IMAGE_DECODER_NOT_PROVIDED,
BL_ERROR_IMAGE_ENCODER_NOT_PROVIDED,
BL_ERROR_PNG_MULTIPLE_IHDR,
BL_ERROR_PNG_INVALID_IDAT,
BL_ERROR_PNG_INVALID_IEND,
BL_ERROR_PNG_INVALID_PLTE,
BL_ERROR_PNG_INVALID_TRNS,
BL_ERROR_PNG_INVALID_FILTER,
BL_ERROR_JPEG_UNSUPPORTED_FEATURE,
BL_ERROR_JPEG_INVALID_SOS,
BL_ERROR_JPEG_INVALID_SOF,
BL_ERROR_JPEG_MULTIPLE_SOF,
BL_ERROR_JPEG_UNSUPPORTED_SOF,
BL_ERROR_FONT_NO_CHARACTER_MAPPING,
BL_ERROR_FONT_MISSING_IMPORTANT_TABLE,
BL_ERROR_FONT_FEATURE_NOT_AVAILABLE,
BL_ERROR_FONT_CFF_INVALID_DATA,
BL_ERROR_FONT_PROGRAM_TERMINATED,
BL_ERROR_INVALID_GLYPH
end

alias BLResult = BLResultCode
end
end
@@ -0,0 +1,28 @@
module Blend2D::C
@[Link("blend2d")]
lib LibBlend2D
struct BLRectI
x : Int32
y : Int32
w : Int32
h : Int32
end

struct BLRect
x : Float64
y : Float64
w : Float64
h : Float64
end

struct BLPointI
x : Int32
y : Int32
end

struct BLPoint
x : Float64
y : Float64
end
end
end

0 comments on commit fabea56

Please sign in to comment.
You can’t perform that action at this time.