Commit 180d27a4 authored by Jeremy Soller's avatar Jeremy Soller

Allow building without std for Renderer usage

parent 4a315379
......@@ -12,8 +12,12 @@ authors = ["Jeremy Soller <jackpot51@gmail.com>"]
name = "orbclient"
path = "src/lib.rs"
[target.'cfg(not(target_os = "redox"))'.dependencies]
sdl2 = "0.29"
[features]
default = []
no_std = []
[target.'cfg(target_os = "redox")'.dependencies]
[target.'cfg(all(not(feature="no_std"), target_os = "redox"))'.dependencies]
redox_syscall = "0.1"
[target.'cfg(all(not(feature="no_std"), not(target_os = "redox")))'.dependencies]
sdl2 = "0.29"
use collections::Vec;
/// point type (is the point a new position or a connection point)
pub enum PointType {
......@@ -9,7 +10,7 @@ pub enum PointType {
/// graphic path with similar functions like html canvas
pub struct GraphicsPath {
x: i32,
y: i32,
y: i32,
pub points: Vec<(i32, i32, PointType)>,
}
......@@ -19,7 +20,7 @@ impl GraphicsPath {
GraphicsPath {
x : 0,
y : 0,
points: vec![],
points: Vec::new(),
}
}
......@@ -37,7 +38,7 @@ impl GraphicsPath {
self.y = y;
}
/// quadratic bezier curve
/// quadratic bezier curve
pub fn quadratic_curve_to(&mut self, argx1: i32, argy1: i32, argx2: i32, argy2: i32){
let mut t:f32 = 0.0;
let mut u:f32;
......@@ -54,7 +55,7 @@ impl GraphicsPath {
x = (self.x as f32) * uu;
y = (self.y as f32) * uu;
x += 2.0 * u * t * (argx1 as f32);
x += 2.0 * u * t * (argx1 as f32);
y += 2.0 * u * t * (argy1 as f32);
x += tt * (argx2 as f32);
......@@ -104,5 +105,5 @@ impl GraphicsPath {
self.x = argx3;
self.y = argy3;
}
}
\ No newline at end of file
}
}
#![crate_name="orbclient"]
#![crate_type="lib"]
#![feature(asm)]
#![feature(collections)]
#![feature(const_fn)]
#![cfg_attr(feature="no_std", no_std)]
#![deny(warnings)]
#[cfg(not(feature="no_std"))]
extern crate core;
extern crate collections;
pub static FONT: &'static [u8] = include_bytes!("../res/unifont.font");
pub use color::Color;
pub use event::*;
#[cfg(not(feature="no_std"))]
pub use imp::{get_display_size, EventIter, Window};
pub use graphicspath::GraphicsPath;
pub use renderer::Renderer;
......@@ -27,10 +32,10 @@ pub enum WindowFlag {
Unclosable
}
#[cfg(target_os = "redox")]
#[cfg(all(not(feature="no_std"), target_os = "redox"))]
#[path="imp/orbital.rs"]
mod imp;
#[cfg(not(target_os = "redox"))]
#[cfg(all(not(feature="no_std"), not(target_os = "redox")))]
#[path="imp/sdl2.rs"]
mod imp;
use std::cmp;
use core::cmp;
use FONT;
use color::Color;
......@@ -281,6 +281,7 @@ pub trait Renderer {
/// Draw a linear gradient in a rectangular region
#[cfg(not(feature="no_std"))]
fn linear_gradient(&mut self, rect_x: i32, rect_y: i32, rect_width: u32, rect_height:u32, start_x: i32, start_y: i32, end_x: i32, end_y: i32, start_color: Color, end_color: Color) {
if (start_x == end_x) && (start_y == end_y) {
// Degenerate gradient
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment