Skip to content

Commit

Permalink
Release v2.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sammycage committed Oct 9, 2022
1 parent e0f786c commit 41f21cc
Show file tree
Hide file tree
Showing 31 changed files with 718 additions and 677 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.3)

project(lunasvg VERSION 2.3.2 LANGUAGES CXX C)
project(lunasvg VERSION 2.3.3 LANGUAGES CXX C)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)

option(BUILD_SHARED_LIBS "Builds as shared library" OFF)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Releases](https://img.shields.io/badge/Version-2.3.2-orange.svg)](https://github.com/sammycage/lunasvg/releases)
[![Releases](https://img.shields.io/badge/Version-2.3.3-orange.svg)](https://github.com/sammycage/lunasvg/releases)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/sammycage/lunasvg/blob/master/LICENSE)
[![Build Status](https://github.com/sammycage/lunasvg/actions/workflows/ci.yml/badge.svg)](https://github.com/sammycage/lunasvg/actions)

Expand Down
12 changes: 6 additions & 6 deletions source/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static plutovg_fill_rule_t to_plutovg_fill_rule(WindRule winding);
static plutovg_operator_t to_plutovg_operator(BlendMode mode);
static plutovg_line_cap_t to_plutovg_line_cap(LineCap cap);
static plutovg_line_join_t to_plutovg_line_join(LineJoin join);
static plutovg_spread_method_t to_plutovg_spread_methood(SpreadMethod spread);
static plutovg_spread_method_t to_plutovg_spread_method(SpreadMethod spread);
static void to_plutovg_stops(plutovg_gradient_t* gradient, const GradientStops& stops);
static void to_plutovg_path(plutovg_t* pluto, const Path& path);

Expand Down Expand Up @@ -59,15 +59,15 @@ Canvas::~Canvas()

void Canvas::setColor(const Color& color)
{
plutovg_set_source_rgba(pluto, color.r, color.g, color.b, color.a);
plutovg_set_source_rgba(pluto, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0);
}

void Canvas::setLinearGradient(double x1, double y1, double x2, double y2, const GradientStops& stops, SpreadMethod spread, const Transform& transform)
{
auto gradient = plutovg_gradient_create_linear(x1, y1, x2, y2);
auto matrix = to_plutovg_matrix(transform);
to_plutovg_stops(gradient, stops);
plutovg_gradient_set_spread(gradient, to_plutovg_spread_methood(spread));
plutovg_gradient_set_spread(gradient, to_plutovg_spread_method(spread));
plutovg_gradient_set_matrix(gradient, &matrix);
plutovg_set_source_gradient(pluto, gradient);
plutovg_gradient_destroy(gradient);
Expand All @@ -78,7 +78,7 @@ void Canvas::setRadialGradient(double cx, double cy, double r, double fx, double
auto gradient = plutovg_gradient_create_radial(cx, cy, r, fx, fy, 0);
auto matrix = to_plutovg_matrix(transform);
to_plutovg_stops(gradient, stops);
plutovg_gradient_set_spread(gradient, to_plutovg_spread_methood(spread));
plutovg_gradient_set_spread(gradient, to_plutovg_spread_method(spread));
plutovg_gradient_set_matrix(gradient, &matrix);
plutovg_set_source_gradient(pluto, gradient);
plutovg_gradient_destroy(gradient);
Expand Down Expand Up @@ -227,7 +227,7 @@ plutovg_line_join_t to_plutovg_line_join(LineJoin join)
return join == LineJoin::Miter ? plutovg_line_join_miter : join == LineJoin::Round ? plutovg_line_join_round : plutovg_line_join_bevel;
}

static plutovg_spread_method_t to_plutovg_spread_methood(SpreadMethod spread)
static plutovg_spread_method_t to_plutovg_spread_method(SpreadMethod spread)
{
return spread == SpreadMethod::Pad ? plutovg_spread_method_pad : spread == SpreadMethod::Reflect ? plutovg_spread_method_reflect : plutovg_spread_method_repeat;
}
Expand All @@ -238,7 +238,7 @@ static void to_plutovg_stops(plutovg_gradient_t* gradient, const GradientStops&
{
auto offset = std::get<0>(stop);
auto& color = std::get<1>(stop);
plutovg_gradient_add_stop_rgba(gradient, offset, color.r, color.g, color.b, color.a);
plutovg_gradient_add_stop_rgba(gradient, offset, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0);
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/clippathelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace lunasvg {

ClipPathElement::ClipPathElement()
: GraphicsElement(ElementId::ClipPath)
: GraphicsElement(ElementID::ClipPath)
{
}

Units ClipPathElement::clipPathUnits() const
{
auto& value = get(PropertyId::ClipPathUnits);
auto& value = get(PropertyID::ClipPathUnits);
return Parser::parseUnits(value, Units::UserSpaceOnUse);
}

Expand Down
2 changes: 1 addition & 1 deletion source/defselement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace lunasvg {

DefsElement::DefsElement()
: GraphicsElement(ElementId::Defs)
: GraphicsElement(ElementID::Defs)
{
}

Expand Down
24 changes: 12 additions & 12 deletions source/element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace lunasvg {

void PropertyList::set(PropertyId id, const std::string& value, int specificity)
void PropertyList::set(PropertyID id, const std::string& value, int specificity)
{
auto property = get(id);
if(property == nullptr)
Expand All @@ -21,7 +21,7 @@ void PropertyList::set(PropertyId id, const std::string& value, int specificity)
property->value = value;
}

Property* PropertyList::get(PropertyId id) const
Property* PropertyList::get(PropertyID id) const
{
auto data = m_properties.data();
auto end = data + m_properties.size();
Expand Down Expand Up @@ -59,19 +59,19 @@ std::unique_ptr<Node> TextNode::clone() const
return std::move(node);
}

Element::Element(ElementId id)
Element::Element(ElementID id)
: id(id)
{
}

void Element::set(PropertyId id, const std::string& value, int specificity)
void Element::set(PropertyID id, const std::string& value, int specificity)
{
properties.set(id, value, specificity);
}

static const std::string EmptyString;

const std::string& Element::get(PropertyId id) const
const std::string& Element::get(PropertyID id) const
{
auto property = properties.get(id);
if(property == nullptr)
Expand All @@ -82,7 +82,7 @@ const std::string& Element::get(PropertyId id) const

static const std::string InheritString{"inherit"};

const std::string& Element::find(PropertyId id) const
const std::string& Element::find(PropertyID id) const
{
auto element = this;
do {
Expand All @@ -95,12 +95,12 @@ const std::string& Element::find(PropertyId id) const
return EmptyString;
}

bool Element::has(PropertyId id) const
bool Element::has(PropertyID id) const
{
return properties.get(id);
}

Element* Element::previousSibling() const
Element* Element::previousElement() const
{
if(parent == nullptr)
return nullptr;
Expand All @@ -122,7 +122,7 @@ Element* Element::previousSibling() const
return nullptr;
}

Element* Element::nextSibling() const
Element* Element::nextElement() const
{
if(parent == nullptr)
return nullptr;
Expand Down Expand Up @@ -162,15 +162,15 @@ Rect Element::currentViewport() const
if(parent == nullptr)
{
auto element = static_cast<const SVGElement*>(this);
if(element->has(PropertyId::ViewBox))
if(element->has(PropertyID::ViewBox))
return element->viewBox();
return Rect{0, 0, 300, 150};
}

if(parent->id == ElementId::Svg)
if(parent->id == ElementID::Svg)
{
auto element = static_cast<SVGElement*>(parent);
if(element->has(PropertyId::ViewBox))
if(element->has(PropertyID::ViewBox))
return element->viewBox();

LengthContext lengthContext(element);
Expand Down
27 changes: 14 additions & 13 deletions source/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace lunasvg {

enum class ElementId
enum class ElementID
{
Unknown = 0,
Star,
Expand All @@ -35,7 +35,7 @@ enum class ElementId
Use
};

enum class PropertyId
enum class PropertyID
{
Unknown = 0,
Class,
Expand Down Expand Up @@ -108,7 +108,7 @@ enum class PropertyId

struct Property
{
PropertyId id;
PropertyID id;
std::string value;
int specificity;
};
Expand All @@ -118,10 +118,11 @@ class PropertyList
public:
PropertyList() = default;

void set(PropertyId id, const std::string& value, int specificity);
Property* get(PropertyId id) const;
void set(PropertyID id, const std::string& value, int specificity);
Property* get(PropertyID id) const;
void add(const Property& property);
void add(const PropertyList& properties);
void clear() { m_properties.clear(); }

private:
std::vector<Property> m_properties;
Expand Down Expand Up @@ -164,15 +165,15 @@ using NodeList = std::list<std::unique_ptr<Node>>;
class Element : public Node
{
public:
Element(ElementId id);
Element(ElementID id);

void set(PropertyId id, const std::string& value, int specificity);
const std::string& get(PropertyId id) const;
const std::string& find(PropertyId id) const;
bool has(PropertyId id) const;
void set(PropertyID id, const std::string& value, int specificity);
const std::string& get(PropertyID id) const;
const std::string& find(PropertyID id) const;
bool has(PropertyID id) const;

Element* previousSibling() const;
Element* nextSibling() const;
Element* previousElement() const;
Element* nextElement() const;
Node* addChild(std::unique_ptr<Node> child);
void layoutChildren(LayoutContext* context, LayoutContainer* current) const;
Rect currentViewport() const;
Expand Down Expand Up @@ -208,7 +209,7 @@ class Element : public Node
}

public:
ElementId id;
ElementID id;
NodeList children;
PropertyList properties;
};
Expand Down
2 changes: 1 addition & 1 deletion source/gelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace lunasvg {

GElement::GElement()
: GraphicsElement(ElementId::G)
: GraphicsElement(ElementID::G)
{
}

Expand Down

0 comments on commit 41f21cc

Please sign in to comment.