Commit cc2af759 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

update the examples list, update readme, delete obsolete files

parent 02b5d50d
Loading
Loading
Loading
Loading

CHANGELOG

deleted100644 → 0
+0 −24
Original line number Diff line number Diff line
fviz v0.4.0; unreleased

  * Renamed the project from "FnordMetric" to "fviz", set version to "0.2.0"

  * Changed the license to 3-Clause BSD

  * Removed the old ChartSQL SQL engine

  * Added a new configuration frontend with a CSS-like syntax

  * Added support for reading input data from CSV files

  * Added support for embedding fviz as a library

  * Added support for exporting images as bitmaps (PNG) and PDF files through
    libcairo

  * Added support for non-latin text shaping through libharfbuzz

  * Ported the existing elements from the old codebase (see git): areas, axis,
    bars, gridlines, legend, lines, points

  * Added the new 'box' element and a simple box layout model
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ include_directories(${CAIRO_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS} ${HARFBUZZ_IN
file(GLOB source_files "core/*.cc" "core/**/*.cc" "elements/*.cc" "elements/**/*.cc")
list(REMOVE_ITEM source_files "core/cli.cc")
add_library(fviz STATIC ${source_files})
set_target_properties(fviz PROPERTIES PUBLIC_HEADER "source/fviz.h;source/fviz_sdl.h")
set_target_properties(fviz PROPERTIES PUBLIC_HEADER "core/fviz.h")
set(fviz_LDFLAGS fviz ${CAIRO_LIBRARIES} ${FREETYPE_LIBRARIES} ${HARFBUZZ_LIBRARIES} ${HARFBUZZ_ICU_LIBRARIES} ${PNG_LIBRARIES} ${FONTCONFIG_LIBRARIES} fmt)


+2 −3
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ output files. Additionally, you can embed it into your own application using the
C API.

<h4>
  <a href="https://fviz.org/documentation/getting-started">Getting Started</a> &middot;
  <a href="https://fviz.org/examples">Examples</a> &middot;
  <a href="https://fviz.org">Documentation</a>
</h4>
@@ -40,11 +39,11 @@ Here is how you can run the above example file through fviz:
    $ fviz --in example_chart.fvz --out example_chart.svg

When running the example locally, you can use your own input CSV file, or you
can download the example CSV file [from here](/tests/testdata/measurement.csv).
can download the example CSV file [from here](/tests/testdata/gauss2d.csv).
If everything works, you should get an output file similar to the one below
(`example_chart.svg`):

[![A simple scatterplot](/examples/charts/scatterplot.svg)](./examples/charts/scatterplot.fvz)
[![A simple scatterplot](/examples/charts-basic/scatterplot.svg)](./examples/charts-basic/scatterplot.fvz)

More examples can be found on [the examples page](https://fviz.org/examples).
For a more detailed introduction to fviz, see the [Getting Started](https://fviz.org/documentation/getting-started) page.

core/element_factory_impl.h

deleted100644 → 0
+0 −53
Original line number Diff line number Diff line
/**
 * This file is part of the "fviz" project
 *   Copyright (c) 2018 Paul Asmuth
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#pragma once

namespace fviz {

template <typename T>
ElementBuilder elem_builder(
    ElementConfigureAsFn<T> config_fn,
    ElementDrawAsFn<T> draw_fn) {
  return elem_builder(config_fn, ElementReflowAsFn<T>(nullptr), draw_fn);
}

template <typename T>
ElementBuilder elem_builder(
    ElementConfigureAsFn<T> config_fn,
    ElementReflowAsFn<T> reflow_fn,
    ElementDrawAsFn<T> draw_fn) {
  using namespace std::placeholders;

  return [=] (
      const plist::PropertyList& prop,
      const Environment& env,
      ElementRef* elem) -> ReturnCode {
    auto e = std::make_unique<ElementInstance<T>>();

    if (auto rc = config_fn(prop, env, &e->config); !rc) {
      return rc;
    }

    e->draw = bind(draw_fn, e->config, _1, _2);
    e->reflow = reflow_fn ? 
        bind(reflow_fn, e->config, _1, _2, _3, _4, _5) :
        ElementReflowFn(nullptr);

    *elem = std::move(e);
    return OK;
  };
}

} // namespace fviz

core/fviz_sdl.cc

deleted100644 → 0
+0 −74
Original line number Diff line number Diff line
/**
 * This file is part of the "fviz" project
 *   Copyright (c) 2018 Paul Asmuth
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "fviz_sdl.h"
#include "return_code.h"
#include "graphics/layer.h"
#include "graphics/layer_pixmap.h"
#include "SDL2/SDL.h"

using namespace fviz;

static void blit(
    const unsigned char* image_data,
    size_t image_width,
    size_t image_height,
    SDL_Surface* output_surface) {
  auto image = SDL_CreateRGBSurfaceWithFormatFrom(
      (void*) image_data,
      image_width,
      image_height,
      32,
      4 * image_width,
      SDL_PIXELFORMAT_ARGB32);

   SDL_BlitSurface(image, NULL, output_surface, NULL);
   SDL_FreeSurface(image);
}

/*
int fviz_render_sdl2(fviz_t* ctx, SDL_Surface* surface) {
  const auto& doc = static_cast<const Context*>(ctx)->document;
  if (!doc) {
    ctx_seterrf(ctx, "no configuration loaded");
    return ERROR;
  }

  auto w = surface->w;
  auto h = surface->h;

  LayerRef layer;
  auto rc = layer_bind_img(
      w,
      h,
      doc->dpi,
      doc->font_size,
      doc->background_color,
      [w, h, surface] (const unsigned char* data, size_t data_len) {
        blit(data, w, h, surface);
        return OK;
      },
      &layer);

  if (!rc) {
    return rc;
  }

  if (auto rc = document_render_to(*doc, layer.get()); !rc) {
    return rc;
  }

  return OK;
}
*/
Loading